summaryrefslogtreecommitdiffstats
path: root/func/yaml/redump.py
blob: eefd68ec47f27ed995b5586697a221826800ef60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)