Index: pygettext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/i18n/pygettext.py,v retrieving revision 1.13 diff -u -r1.13 pygettext.py --- pygettext.py 2001/03/01 22:56:17 1.13 +++ pygettext.py 2001/05/21 19:21:22 @@ -1,7 +1,7 @@ #! /usr/bin/env python -# Originally written by Barry Warsaw +# Originally written by Barry Warsaw # -# minimally patched to make it even more xgettext compatible +# Minimally patched to make it even more xgettext compatible # by Peter Funk """pygettext -- Python equivalent of xgettext(1) @@ -313,7 +313,7 @@ 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 @@ # 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 @@ 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 @@ 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()