summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2015-05-13 21:16:42 +0200
committerAnthon van der Neut <anthon@mnt.org>2015-05-13 21:16:42 +0200
commitd289ab459be4ae516bed987aab456b95d2dfb917 (patch)
tree0a1761e64aee38999a6a16ee6495fcdae029dcc9
parent377b7a2904a77f96fe05ca26b8e7d4cba34bdfeb (diff)
downloadruamel.yaml-d289ab459be4ae516bed987aab456b95d2dfb917.tar.gz
flow and non-flow style for yaml json
-rw-r--r--py/yaml.py8
-rw-r--r--setup.py2
2 files changed, 7 insertions, 3 deletions
diff --git a/py/yaml.py b/py/yaml.py
index ec0ec46..6974108 100644
--- a/py/yaml.py
+++ b/py/yaml.py
@@ -184,10 +184,12 @@ class YAML:
docs = []
for file_name in self._args.file:
inp = open(file_name).read()
- loader = ruamel.yaml.RoundTripLoader
+ loader = ruamel.yaml.Loader # RoundTripLoader
docs.append(ruamel.yaml.load(inp, loader))
dumper = ruamel.yaml.RoundTripDumper
- print(ruamel.yaml.dump_all(docs, Dumper=dumper))
+ print(ruamel.yaml.dump_all(
+ docs, Dumper=dumper,
+ default_flow_style=self._args.flow))
return 1 if errors else 0
def to_html(self):
@@ -320,6 +322,8 @@ class YAML_Cmd(ProgramBase):
help='convert json to block YAML',
description='convert json to block YAML',
)
+ @option('--flow', action='store_true',
+ help='use flow instead of block style')
@option('file', nargs='+')
def json(self):
return self._yaml.from_json()
diff --git a/setup.py b/setup.py
index aa4da62..1f79a25 100644
--- a/setup.py
+++ b/setup.py
@@ -37,7 +37,7 @@ def _check_convert_version(tup):
if isinstance(x, int):
nr_digits += 1
if nr_digits > 2:
- raise ValueError("to many consecutive digits " + ret_val)
+ raise ValueError("too many consecutive digits " + ret_val)
ret_val += next_sep + str(x)
next_sep = '.'
continue