summaryrefslogtreecommitdiffstats
path: root/func/yaml/redump.py
diff options
context:
space:
mode:
Diffstat (limited to 'func/yaml/redump.py')
-rw-r--r--func/yaml/redump.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/func/yaml/redump.py b/func/yaml/redump.py
new file mode 100644
index 0000000..eefd68e
--- /dev/null
+++ b/func/yaml/redump.py
@@ -0,0 +1,22 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
+from ordered_dict import OrderedDict
+from load import Parser
+from dump import Dumper
+from stream import StringStream
+
+def loadOrdered(stream):
+ parser = Parser(StringStream(stream))
+ parser.dictionary = OrderedDict
+ return iter(parser)
+
+def redump(stream):
+ docs = list(loadOrdered(stream))
+ dumper = Dumper()
+ dumper.alphaSort = 0
+ return dumper.dump(*docs)
+