diff options
-rw-r--r-- | tools/grit/grit/extern/FP.py | 9 | ||||
-rw-r--r-- | tools/grit/grit/node/io.py | 2 | ||||
-rw-r--r-- | tools/grit/grit/tclib.py | 3 | ||||
-rw-r--r-- | tools/grit/grit/xtb_reader.py | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/tools/grit/grit/extern/FP.py b/tools/grit/grit/extern/FP.py index 782a473..1e0bce8 100644 --- a/tools/grit/grit/extern/FP.py +++ b/tools/grit/grit/extern/FP.py @@ -3,7 +3,12 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import md5 +try: + import hashlib + _new_md5 = hashlib.md5 +except ImportError: + import md5 + _new_md5 = md5.new """64-bit fingerprint support for strings. @@ -16,7 +21,7 @@ Usage: def UnsignedFingerPrint(str, encoding='utf-8'): """Generate a 64-bit fingerprint by taking the first half of the md5 of the string.""" - hex128 = md5.new(str).hexdigest() + hex128 = _new_md5(str).hexdigest() int64 = long(hex128[:16], 16) return int64 diff --git a/tools/grit/grit/node/io.py b/tools/grit/grit/node/io.py index befd671..3de4e7f 100644 --- a/tools/grit/grit/node/io.py +++ b/tools/grit/grit/node/io.py @@ -48,7 +48,7 @@ class FileNode(base.Node): except: print "Exception during parsing of %s" % self.GetFilePath() raise - assert (lang == self.attrs['lang'], 'The XTB file you ' + assert lang == self.attrs['lang'], ('The XTB file you ' 'reference must contain messages in the language specified\n' 'by the \'lang\' attribute.') diff --git a/tools/grit/grit/tclib.py b/tools/grit/grit/tclib.py index 846ce15..915082c 100644 --- a/tools/grit/grit/tclib.py +++ b/tools/grit/grit/tclib.py @@ -76,9 +76,6 @@ class BaseMessage(object): assert isinstance(placeholder, Placeholder) dup = False for other in self.GetPlaceholders(): - if (other.presentation.find(placeholder.presentation) != -1 or - placeholder.presentation.find(other.presentation) != -1): - assert(False, "Placeholder names must be unique and must not overlap") if other.presentation == placeholder.presentation: assert other.original == placeholder.original dup = True diff --git a/tools/grit/grit/xtb_reader.py b/tools/grit/grit/xtb_reader.py index 83a492a..3d1a42a 100644 --- a/tools/grit/grit/xtb_reader.py +++ b/tools/grit/grit/xtb_reader.py @@ -31,7 +31,7 @@ class XtbContentHandler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == 'translation': - assert (self.current_id == 0 and len(self.current_structure) == 0, + assert self.current_id == 0 and len(self.current_structure) == 0, ( "Didn't expect a <translation> element here.") self.current_id = attrs.getValue('id') elif name == 'ph': |