Created
January 20, 2019 14:45
-
-
Save moreati/8cdefd100c6c5267bc58f7f72cb66c39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cStringIO import StringIO | |
import sys | |
import ruamel.ordereddict | |
import ruamel.yaml | |
s = '''\ | |
foo: | |
bar: baz | |
a: 1 | |
# comment | |
c: |- | |
qwertyuiop | |
asdfghjkl | |
zxcvbnm | |
''' | |
yaml = ruamel.yaml.YAML() | |
yaml.version = 1,1 | |
yaml.indent(sequence=4, offset=2) | |
yaml.sort_base_mapping_type_on_output = True | |
data = yaml.load(StringIO(s)) | |
data['foo'] = dict(data['foo']) | |
yaml.dump(data, sys.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment