]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
write(): Do two levels of sorting: first sort the individual location
authorBarry Warsaw <barry@python.org>
Wed, 23 May 2001 16:59:45 +0000 (16:59 +0000)
committerBarry Warsaw <barry@python.org>
Wed, 23 May 2001 16:59:45 +0000 (16:59 +0000)
tuples by filename/lineno, then sort the catalog entries by their
location tuples.

Tools/i18n/pygettext.py

index 804c98c5e9ed84d39327faac7a1ddf01fdd8790f..14a83b4f7bae7e51bb69db15d62f403011b47f6b 100755 (executable)
@@ -325,7 +325,17 @@ class TokenEater:
         # The time stamp in the header doesn't have the same format as that
         # generated by xgettext...
         print >> fp, pot_header % {'time': timestamp, 'version': __version__}
+        # Sort the entries.  First sort each particular entry's keys, then
+        # sort all the entries by their first item.
+        reverse = {}
         for k, v in self.__messages.items():
+            keys = v.keys()
+            keys.sort()
+            reverse[tuple(keys)] = (k, v)
+        rkeys = reverse.keys()
+        rkeys.sort()
+        for rkey in rkeys:
+            k, v = reverse[rkey]
             # If the entry was gleaned out of a docstring, then add a comment
             # stating so.  This is to aid translators who may wish to skip
             # translating some unimportant docstrings.