summaryrefslogtreecommitdiffstats
path: root/tools/grit
diff options
context:
space:
mode:
authorthakis <thakis@chromium.org>2015-11-13 12:27:35 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-13 20:28:10 +0000
commitb804ed4fe87bebdd2665aaedc510d59f0a915afa (patch)
tree84ee476d7f1b9b26e3575eb7a8fc1be03118a6f0 /tools/grit
parent96a915e2679355c93d458699c49b365f0a05c27d (diff)
downloadchromium_src-b804ed4fe87bebdd2665aaedc510d59f0a915afa.zip
chromium_src-b804ed4fe87bebdd2665aaedc510d59f0a915afa.tar.gz
chromium_src-b804ed4fe87bebdd2665aaedc510d59f0a915afa.tar.bz2
Fix presubmit for grit, do some minor cleanups.
Also add the location of the historical repo to README. BUG=553692 Review URL: https://codereview.chromium.org/1441923002 Cr-Commit-Position: refs/heads/master@{#359622}
Diffstat (limited to 'tools/grit')
-rw-r--r--tools/grit/README6
-rwxr-xr-xtools/grit/grit/clique.py13
-rwxr-xr-xtools/grit/grit/clique_unittest.py3
-rwxr-xr-xtools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py2
-rwxr-xr-xtools/grit/grit/tclib_unittest.py3
-rwxr-xr-xtools/grit/grit/tool/build_unittest.py12
-rwxr-xr-xtools/grit/grit/tool/resize.py64
7 files changed, 56 insertions, 47 deletions
diff --git a/tools/grit/README b/tools/grit/README
index 8fcdafe..aa7d946 100644
--- a/tools/grit/README
+++ b/tools/grit/README
@@ -1,2 +1,8 @@
GRIT (Google Resource and Internationalization Tool) is a tool for Windows
projects to manage resources and simplify the localization workflow.
+
+This code previously used to live at
+https://code.google.com/p/grit-i18n/source/checkout which still contains the
+project's history. https://chromium.googlesource.com/external/grit-i18n/ is
+a git mirror of the SVN repository that's identical except for the last two
+commits.
diff --git a/tools/grit/grit/clique.py b/tools/grit/grit/clique.py
index 3a979890..7d920a8 100755
--- a/tools/grit/grit/clique.py
+++ b/tools/grit/grit/clique.py
@@ -275,8 +275,8 @@ class CustomType(object):
class OneOffCustomType(CustomType):
'''A very simple custom type that performs the validation expressed by
the input expression on all languages including the source language.
- The expression can access the variables 'lang', 'msg' and 'text()' where 'lang'
- is the language of 'msg', 'msg' is the message or translation being
+ The expression can access the variables 'lang', 'msg' and 'text()' where
+ 'lang' is the language of 'msg', 'msg' is the message or translation being
validated and 'text()' returns the real contents of 'msg' (for shorthand).
'''
def __init__(self, expression):
@@ -308,7 +308,8 @@ class MessageClique(object):
# A pattern to match messages that are empty or whitespace only.
WHITESPACE_MESSAGE = lazy_re.compile(u'^\s*$')
- def __init__(self, uber_clique, message, translateable=True, custom_type=None):
+ def __init__(self, uber_clique, message, translateable=True,
+ custom_type=None):
'''Create a new clique initialized with just a message.
Note that messages with a body comprised only of whitespace will implicitly
@@ -365,7 +366,8 @@ class MessageClique(object):
if custom_type and not custom_type.Validate(self.GetMessage()):
raise exception.InvalidMessage(self.GetMessage().GetRealContent())
- def MessageForLanguage(self, lang, pseudo_if_no_match=True, fallback_to_english=False):
+ def MessageForLanguage(self, lang, pseudo_if_no_match=True,
+ fallback_to_english=False):
'''Returns the message/translation for the specified language, providing
a pseudotranslation if there is no available translation and a pseudo-
translation is requested.
@@ -475,7 +477,8 @@ class MessageClique(object):
text=translation.GetPresentableContent(),
placeholders=original.GetPlaceholders())
- if self.custom_type and not self.custom_type.ValidateAndModify(language, transl_msg):
+ if (self.custom_type and
+ not self.custom_type.ValidateAndModify(language, transl_msg)):
print "WARNING: %s translation failed validation: %s" % (
language, transl_msg.GetId())
diff --git a/tools/grit/grit/clique_unittest.py b/tools/grit/grit/clique_unittest.py
index faf54833..ff2c3a3 100755
--- a/tools/grit/grit/clique_unittest.py
+++ b/tools/grit/grit/clique_unittest.py
@@ -59,7 +59,8 @@ class MessageCliqueUnittest(unittest.TestCase):
rex = re.compile('fr|de|bingo')
self.failUnless(len(c.AllMessagesThatMatch(rex, False)) == 2)
- self.failUnless(c.AllMessagesThatMatch(rex, True)[pseudo.PSEUDO_LANG] != None)
+ self.failUnless(
+ c.AllMessagesThatMatch(rex, True)[pseudo.PSEUDO_LANG] is not None)
def testBestClique(self):
factory = clique.UberClique()
diff --git a/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py b/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py
index cfa5dc2..8d7a7f2 100755
--- a/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/xml_writer_base_unittest.py
@@ -28,7 +28,7 @@ class XmlWriterBaseTest(unittest.TestCase):
# function which produces new lines around string literals. This has been
# fixed in Precise which has Python 2.7.3 but we have to keep compatibility
# with both for now.
- text_re = re.compile('>\n\s+([^<>\s].*?)\n\s*</', re.DOTALL)
+ text_re = re.compile('>\n\s+([^<>\s].*?)\n\s*</', re.DOTALL)
return text_re.sub('>\g<1></', raw_pretty_xml)
def AssertXMLEquals(self, output, expected_output):
diff --git a/tools/grit/grit/tclib_unittest.py b/tools/grit/grit/tclib_unittest.py
index e85bb94..87849c5 100755
--- a/tools/grit/grit/tclib_unittest.py
+++ b/tools/grit/grit/tclib_unittest.py
@@ -70,7 +70,6 @@ class TclibUnittest(unittest.TestCase):
# This has Windows line endings. That is on purpose.
id = grit.extern.tclib.GenerateMessageId(
'Google Desktop for Enterprise\r\n'
- 'Copyright (C) 2006 Google Inc.\r\n'
'All Rights Reserved\r\n'
'\r\n'
'---------\r\n'
@@ -155,7 +154,7 @@ class TclibUnittest(unittest.TestCase):
'you can get to the preferences, add the following line to your \r\n'
'notes.ini file:\r\n'
'GDSNoIndexHistory=1\r\n')
- self.failUnless(id == '8961534701379422820')
+ self.failUnless(id == '3138901326664699350')
def testPlaceholderNameChecking(self):
try:
diff --git a/tools/grit/grit/tool/build_unittest.py b/tools/grit/grit/tool/build_unittest.py
index bf65724..952eff9 100755
--- a/tools/grit/grit/tool/build_unittest.py
+++ b/tools/grit/grit/tool/build_unittest.py
@@ -57,7 +57,7 @@ class BuildUnittest(unittest.TestCase):
self.failUnlessEqual(1, len(deps))
self.failUnlessEqual(deps[0],
util.PathFromRoot('grit/testdata/substitute.xmb'))
-
+
def testGenerateDepFileWithResourceIds(self):
output_dir = tempfile.mkdtemp()
builder = build.RcBuilder()
@@ -67,11 +67,11 @@ class BuildUnittest(unittest.TestCase):
self.verbose = False
self.extra_verbose = False
expected_dep_file = os.path.join(output_dir, 'substitute_no_ids.grd.d')
- builder.Run(DummyOpts(),
- ['-f', util.PathFromRoot('grit/testdata/resource_ids'),
- '-o', output_dir,
- '--depdir', output_dir,
- '--depfile', expected_dep_file])
+ builder.Run(DummyOpts(),
+ ['-f', util.PathFromRoot('grit/testdata/resource_ids'),
+ '-o', output_dir,
+ '--depdir', output_dir,
+ '--depfile', expected_dep_file])
self.failUnless(os.path.isfile(expected_dep_file))
with open(expected_dep_file) as f:
diff --git a/tools/grit/grit/tool/resize.py b/tools/grit/grit/tool/resize.py
index 8b9bdb9..3daffa4 100755
--- a/tools/grit/grit/tool/resize.py
+++ b/tools/grit/grit/tool/resize.py
@@ -22,38 +22,38 @@ from grit.tool import interface
PROJECT_TEMPLATE = '''\
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="[[DIALOG_NAME]]"
- ProjectGUID="[[PROJECT_GUID]]"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- CharacterSet="2">
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
- <File
- RelativePath=".\[[DIALOG_NAME]].rc">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="[[DIALOG_NAME]]"
+ ProjectGUID="[[PROJECT_GUID]]"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ <File
+ RelativePath=".\[[DIALOG_NAME]].rc">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
</VisualStudioProject>'''