diff options
-rwxr-xr-x | Tools/i18n/pygettext.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index 275130f..41a0970 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -1,7 +1,7 @@ #! /usr/bin/env python -# Originally written by Barry Warsaw <bwarsaw@python.org> +# Originally written by Barry Warsaw <barry@digicool.com> # -# minimally patched to make it even more xgettext compatible +# Minimally patched to make it even more xgettext compatible # by Peter Funk <pf@artcom-gmbh.de> """pygettext -- Python equivalent of xgettext(1) @@ -313,7 +313,7 @@ class TokenEater: lineno = self.__lineno if not msg in self.__options.toexclude: entry = (self.__curfile, lineno) - self.__messages.setdefault(msg, []).append(entry) + self.__messages.setdefault(msg, {})[entry] = 1 def set_filename(self, filename): self.__curfile = filename @@ -325,6 +325,11 @@ class TokenEater: # generated by xgettext... print >> fp, pot_header % {'time': timestamp, 'version': __version__} for k, v in self.__messages.items(): + # k is the message string, v is a dictionary-set of (filename, + # lineno) tuples. We want to sort the entries in v first by file + # name and then by line number. + v = v.keys() + v.sort() if not options.writelocations: pass # location comments are different b/w Solaris and GNU: @@ -444,8 +449,8 @@ def main(): options.toexclude = fp.readlines() fp.close() except IOError: - sys.stderr.write(_("Can't read --exclude-file: %s") % - options.excludefilename) + print >> sys.stderr, _( + "Can't read --exclude-file: %s") % options.excludefilename sys.exit(1) else: options.toexclude = [] @@ -468,8 +473,8 @@ def main(): try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: - sys.stderr.write('%s: %s, line %d, column %d\n' % - (e[0], filename, e[1][0], e[1][1])) + print >> sys.stderr, '%s: %s, line %d, column %d' % ( + e[0], filename, e[1][0], e[1][1]) finally: if closep: fp.close() |