pyyaml / lib / yaml /

Diff from to


     yaml_representers = {}
     yaml_multi_representers = {}
-    def __init__(self, default_style=None, default_flow_style=None):
+    def __init__(self, default_style=None, default_flow_style=None,
+            dictorder=None):
         self.default_style = default_style
         self.default_flow_style = default_flow_style
+        self.dictorder = dictorder
         self.represented_objects = {}
         self.object_keeper = []
         self.alias_key = None
                 node.flow_style = best_style
         return node
-    def represent_mapping(self, tag, mapping, flow_style=None):
+    def represent_mapping(self, tag, mapping, flow_style=None, dictorder=None):
         value = []
         node = MappingNode(tag, value, flow_style=flow_style)
         if self.alias_key is not None:
         if hasattr(mapping, 'items'):
             mapping = mapping.items()
+        # dictorder must be a function that does an
+        # in-place sort of a list of pairs.
+            if dictorder:
+                dictorder(mapping)
         for item_key, item_value in mapping:
             node_key = self.represent_data(item_key)
             node_value = self.represent_data(item_value)
         #return SequenceNode(u',2002:pairs', value)
     def represent_dict(self, data):
-        return self.represent_mapping(u',2002:map', data)
+        return self.represent_mapping(u',2002:map', data,
+            dictorder=self.dictorder)
     def represent_set(self, data):
         value = {}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.