]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix extraction order 424/head
authorNicolas Grilly <nicolas@gardentechno.com>
Fri, 24 Jun 2016 19:49:06 +0000 (21:49 +0200)
committerNicolas Grilly <nicolas@gardentechno.com>
Fri, 24 Jun 2016 20:06:46 +0000 (22:06 +0200)
Before Babel 2.3, the input directories were always extracted
in the order specified by the command line arguments.

For example, `pybabel extract dir_a dir_b dir_c` would process
`dir_a` first, then `dir_b`, and finally `dir_c`.

Since Babel 2.3, the inputs are stored in a Python dictionary,
and we loop over items in the dictionary using items().
This makes the order unspecified, not matching the order
specified on the command line anymore.

babel/messages/frontend.py

index d190a2c07176c6aac1dca9c4c1c11f9be66ff6c4..d991013346f61ff5604efa68df9e10d2c125bf59 100644 (file)
@@ -416,7 +416,7 @@ class extract_messages(Command):
                               copyright_holder=self.copyright_holder,
                               charset=self.charset)
 
-            for path, (method_map, options_map) in mappings.items():
+            for path, method_map, options_map in mappings:
                 def callback(filename, method, options):
                     if method == 'ignore':
                         return
@@ -468,14 +468,14 @@ class extract_messages(Command):
                      sort_by_file=self.sort_by_file)
 
     def _get_mappings(self):
-        mappings = {}
+        mappings = []
 
         if self.mapping_file:
             fileobj = open(self.mapping_file, 'U')
             try:
                 method_map, options_map = parse_mapping(fileobj)
                 for path in self.input_paths:
-                    mappings[path] = method_map, options_map
+                    mappings.append((path, method_map, options_map))
             finally:
                 fileobj.close()
 
@@ -489,11 +489,11 @@ class extract_messages(Command):
                     for pattern, method, options in mapping:
                         method_map.append((pattern, method))
                         options_map[pattern] = options or {}
-                mappings[path] = method_map, options_map
+                mappings.append((path, method_map, options_map))
 
         else:
             for path in self.input_paths:
-                mappings[path] = DEFAULT_MAPPING, {}
+                mappings.append((path, DEFAULT_MAPPING, {}))
 
         return mappings