diff options
author | Anthon van der Neut <anthon@mnt.org> | 2015-04-14 17:45:40 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2015-04-14 17:45:40 +0200 |
commit | 505435a7f1bbd919c4d8ec0b25885f212bb61731 (patch) | |
tree | 361571b2c3d72b7410223d58eed5b34a6891e596 | |
parent | edce39776d0eb697d22087169d150e65db270ba4 (diff) | |
download | ruamel.yaml-505435a7f1bbd919c4d8ec0b25885f212bb61731.tar.gz |
roundtrip ordereddict bug
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | py/__init__.py | 2 | ||||
-rw-r--r-- | py/representer.py | 12 | ||||
-rw-r--r-- | py/yaml.py | 37 |
4 files changed, 21 insertions, 32 deletions
@@ -1,3 +1,5 @@ +0.7.3: 2015-04 +- bug fix for non-roundtrip save of ordereddict 0.7.2: 2015-03-29 - support for end-of-line comments on flow style sequences and mappings diff --git a/py/__init__.py b/py/__init__.py index 3757997..9e1c057 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -21,7 +21,7 @@ def _convert_version(tup): return ret_val -version_info = (0, 7, 2) +version_info = (0, 7, 3) __version__ = _convert_version(version_info) del _convert_version diff --git a/py/representer.py b/py/representer.py index 1a5f922..6e55cd4 100644 --- a/py/representer.py +++ b/py/representer.py @@ -597,7 +597,10 @@ class RoundTripRepresenter(SafeRepresenter): # if the flow_style is None, the flow style tacked on to the object # explicitly will be taken. If that is None as well the default flow # style rules - flow_style = sequence.fa.flow_style(flow_style) + try: + flow_style = sequence.fa.flow_style(flow_style) + except AttributeError: + flow_style = flow_style node = SequenceNode(tag, value, flow_style=flow_style) if self.alias_key is not None: self.represented_objects[self.alias_key] = node @@ -630,7 +633,7 @@ class RoundTripRepresenter(SafeRepresenter): try: flow_style = mapping.fa.flow_style(flow_style) except AttributeError: - pass + flow_style = flow_style node = MappingNode(tag, value, flow_style=flow_style) if self.alias_key is not None: self.represented_objects[self.alias_key] = node @@ -674,7 +677,10 @@ class RoundTripRepresenter(SafeRepresenter): def represent_omap(self, tag, omap, flow_style=None): value = [] - flow_style = omap.fa.flow_style(flow_style) + try: + flow_style = omap.fa.flow_style(flow_style) + except AttributeError: + flow_style = flow_style node = SequenceNode(tag, value, flow_style=flow_style) if self.alias_key is not None: self.represented_objects[self.alias_key] = node @@ -143,31 +143,9 @@ class YAML: """) input = dedent("""\ - # comment A - a: [b, c, d] # comment B - j: [k, l, m] # comment C - """) - - Xinput = dedent("""\ - # comment A - - {a: 1, b: hallo} # comment B - - {j: fka, k: 42} # comment C - """) - - Xinput = dedent("""\ - # comment A - - {a: 1, b: hallo} - - {j: fka, k: 42} - """) - - Xinput = dedent("""\ - # C start a - # C start b - - abc # abc comment - - ghi - - klm # klm comment - # C end a - # C end b + a: + b: foo + c: bar """) print_input(input) @@ -191,7 +169,10 @@ class YAML: print('>>>>>>>>>>') # print(ruamel.yaml.dump(data, default_flow_style=False, # Dumper=dumper), '===========') - print("{0}=========".format(ruamel.yaml.dump(data, Dumper=dumper))) + print("{0}=========".format(ruamel.yaml.dump( + data, + indent=4, + Dumper=dumper))) comment = getattr(l, '_yaml_comment', None) print('comment_2', comment) @@ -357,9 +338,9 @@ class YAML_Cmd(ProgramBase): @sub_parser( aliases=['to-html'], - help='convert YAML ot html tables', + help='convert YAML to html tables', description="""convert YAML to html tables. If hierarchy is two deep ( - list/mapping over list/mapping) this is mapped to one table + sequence/mapping over sequence/mapping) this is mapped to one table If the hierarchy is three deep, a list of 2 deep tables is assumed, but any non-list/mapp second level items are considered text. Row level keys are inserted in first column (unless --no-row-key), |