summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--README.rst8
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/test_issues.py1
-rw-r--r--representer.py19
6 files changed, 31 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index be3d466..cd4b14f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+[0, 15, 74]: 2018-10-17
+ - fix dropping of comment on rt before sequence item that is sequence item
+ (reported by `Thorsten Kampe <https://bitbucket.org/thorstenkampe/>`__)
+
[0, 15, 73]: 2018-10-16
- fix irregular output on pre-comment in sequence within sequence (reported
by `Thorsten Kampe <https://bitbucket.org/thorstenkampe/>`__)
diff --git a/README.rst b/README.rst
index b40e3b4..c82ad08 100644
--- a/README.rst
+++ b/README.rst
@@ -4,8 +4,8 @@ ruamel.yaml
``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.
-:version: 0.15.73
-:updated: 2018-10-16
+:version: 0.15.74
+:updated: 2018-10-17
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
:pypi: https://pypi.org/project/ruamel.yaml/
@@ -54,6 +54,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.74 (2018-10-17):
+ - fix dropping of comment on rt before sequence item that is sequence item
+ (reported by `Thorsten Kampe <https://bitbucket.org/thorstenkampe/>`__)
+
0.15.73 (2018-10-16):
- fix irregular output on pre-comment in sequence within sequence (reported
by `Thorsten Kampe <https://bitbucket.org/thorstenkampe/>`__)
diff --git a/__init__.py b/__init__.py
index e68a11f..06c70a0 100644
--- a/__init__.py
+++ b/__init__.py
@@ -7,8 +7,8 @@ if False: # MYPY
_package_data = dict(
full_package_name='ruamel.yaml',
- version_info=(0, 15, 73),
- __version__='0.15.73',
+ version_info=(0, 15, 74),
+ __version__='0.15.74',
author='Anthon van der Neut',
author_email='a.van.der.neut@ruamel.eu',
description='ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order', # NOQA
diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg
index 4b0bd1b..389f958 100644
--- a/_doc/_static/pypi.svg
+++ b/_doc/_static/pypi.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.73</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.73</text></g> </svg>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.74</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.74</text></g> </svg>
diff --git a/_test/test_issues.py b/_test/test_issues.py
index 157021e..721f3fe 100644
--- a/_test/test_issues.py
+++ b/_test/test_issues.py
@@ -549,7 +549,6 @@ class TestIssues:
""")
yaml.round_trip(inp, outp=exp) # NOQA
- @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError)
def test_issue_250(self):
inp = """
# 1.
diff --git a/representer.py b/representer.py
index 9f7179c..28ec9a2 100644
--- a/representer.py
+++ b/representer.py
@@ -6,6 +6,7 @@ from __future__ import print_function, absolute_import, division
from ruamel.yaml.error import * # NOQA
from ruamel.yaml.nodes import * # NOQA
from ruamel.yaml.compat import text_type, binary_type, to_unicode, PY2, PY3, ordereddict
+from ruamel.yaml.compat import nprint, nprintf # NOQA
from ruamel.yaml.scalarstring import (
LiteralScalarString,
FoldedScalarString,
@@ -889,7 +890,7 @@ class RoundTripRepresenter(SafeRepresenter):
item_comments = {}
for idx, item in enumerate(sequence):
node_item = self.represent_data(item)
- node_item.comment = item_comments.get(idx)
+ self.merge_comments(node_item, item_comments.get(idx))
if not (isinstance(node_item, ScalarNode) and not node_item.style):
best_style = False
value.append(node_item)
@@ -900,6 +901,22 @@ class RoundTripRepresenter(SafeRepresenter):
node.flow_style = best_style
return node
+ def merge_comments(self, node, comments):
+ # type: (Any, Any) -> Any
+ if comments is None:
+ assert hasattr(node, 'comment')
+ return node
+ if getattr(node, 'comment', None) is not None:
+ for idx, val in enumerate(comments):
+ if idx >= len(node.comment):
+ continue
+ nc = node.comment[idx]
+ if nc is not None:
+ assert val is None or val == nc
+ comments[idx] = nc
+ node.comment = comments
+ return node
+
def represent_key(self, data):
# type: (Any) -> Any
if isinstance(data, CommentedKeySeq):