diff options
author | Anthon van der Neut <anthon@mnt.org> | 2015-09-14 21:00:34 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2015-09-14 21:00:34 +0200 |
commit | 458b666f85b015b328b2d70c4072e3804dd3903a (patch) | |
tree | bfcad575211664482f3809994d4513294e8c143f /representer.py | |
parent | 23294d8492459f0268c02191cccee955bee8c206 (diff) | |
download | ruamel.yaml-458b666f85b015b328b2d70c4072e3804dd3903a.tar.gz |
Fix Issue 11, double dump lost comments
The state 'pre_done' to keep comments from being printed twice
was not cleared and on second dump would result in non-printing
Diffstat (limited to 'representer.py')
-rw-r--r-- | representer.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/representer.py b/representer.py index 63c0d0d..c1bbb8b 100644 --- a/representer.py +++ b/representer.py @@ -650,7 +650,14 @@ class RoundTripRepresenter(SafeRepresenter): try: comment = getattr(mapping, comment_attrib) node.comment = comment.comment + if node.comment and node.comment[1]: + for ct in node.comment[1]: + ct.reset() item_comments = comment.items + for v in item_comments.values(): + if v and v[1]: + for ct in v[1]: + ct.reset() try: node.comment.append(comment.end) except AttributeError: @@ -711,7 +718,14 @@ class RoundTripRepresenter(SafeRepresenter): try: comment = getattr(omap, comment_attrib) node.comment = comment.comment + if node.comment and node.comment[1]: + for ct in node.comment[1]: + ct.reset() item_comments = comment.items + for v in item_comments.values(): + if v and v[1]: + for ct in v[1]: + ct.reset() try: node.comment.append(comment.end) except AttributeError: @@ -763,7 +777,14 @@ class RoundTripRepresenter(SafeRepresenter): try: comment = getattr(setting, comment_attrib) node.comment = comment.comment + if node.comment and node.comment[1]: + for ct in node.comment[1]: + ct.reset() item_comments = comment.items + for v in item_comments.values(): + if v and v[1]: + for ct in v[1]: + ct.reset() try: node.comment.append(comment.end) except AttributeError: |