From c716679edf348ba59d7551600c9cf139e23961ef Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Wed, 27 Feb 2019 22:57:46 +0100 Subject: fix issue #279 block sequence elements with flow mapping collapsed *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))* --- CHANGES | 6 ++++++ README.rst | 8 +++++--- __init__.py | 4 ++-- _doc/_static/pypi.svg | 2 +- _test/test_issues.py | 23 ++++++++++++++++++++--- emitter.py | 4 ++++ setup.py | 6 ++++-- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 272d72e..3d283ef 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +[0, 15, 89]: 2019-02-27 + - fix for items with flow-mapping in block sequence output on single line + (reported by `Zahari Dim `__) + - fix for safe dumping erroring in creation of representereror when dumping namedtuple + (reported and solution by `Jaakko Kantojärvi `__) + [0, 15, 88]: 2019-02-12 - fix inclusing of python code from the subpackage data (containing extra tests, reported by `Florian Apolloner `__) diff --git a/README.rst b/README.rst index 6a8cf16..4b43bc5 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.88 -:updated: 2019-02-12 +:version: 0.15.89 +:updated: 2019-02-27 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :pypi: https://pypi.org/project/ruamel.yaml/ @@ -54,7 +54,9 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) -NEXT: +0.15.89 (2019-02-27): + - fix for items with flow-mapping in block sequence output on single line + (reported by `Zahari Dim `__) - fix for safe dumping erroring in creation of representereror when dumping namedtuple (reported and solution by `Jaakko Kantojärvi `__) diff --git a/__init__.py b/__init__.py index b94b3ff..c10c606 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, 88), - __version__='0.15.88', + version_info=(0, 15, 89), + __version__='0.15.89', 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 59e461f..c18afa1 100644 --- a/_doc/_static/pypi.svg +++ b/_doc/_static/pypi.svg @@ -1 +1 @@ - pypipypi0.15.880.15.88 + pypipypi0.15.890.15.89 diff --git a/_test/test_issues.py b/_test/test_issues.py index d5913f6..4780da5 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -560,6 +560,26 @@ class TestIssues: """ d = round_trip(inp) # NOQA + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) + def test_issue_279(self): + from ruamel.yaml import YAML + from ruamel.yaml.compat import StringIO + + yaml = YAML() + yaml.indent(sequence=4, offset=2) + inp = dedent("""\ + experiments: + - datasets: + # ATLAS EWK + - {dataset: ATLASWZRAP36PB, frac: 1.0} + - {dataset: ATLASZHIGHMASS49FB, frac: 1.0} + """) + a = yaml.load(inp) + buf = StringIO() + yaml.dump(a, buf) + print(buf.getvalue()) + assert buf.getvalue() == inp + def test_issue_280(self): from ruamel.yaml import YAML from ruamel.yaml.representer import RepresenterError @@ -576,6 +596,3 @@ class TestIssues: # inp = """ # """ # d = round_trip(inp) # NOQA - - - diff --git a/emitter.py b/emitter.py index 690cbc5..d4884bd 100644 --- a/emitter.py +++ b/emitter.py @@ -546,6 +546,8 @@ class Emitter(object): if self.event.comment and self.event.comment[0]: # eol comment on empty mapping self.write_post_comment(self.event) + elif self.flow_level == 0: + self.write_line_break() self.state = self.states.pop() else: if self.canonical or self.column > self.best_width: @@ -574,6 +576,8 @@ class Emitter(object): if self.event.comment and self.event.comment[0]: # eol comment on flow mapping, never reached on empty mappings self.write_post_comment(self.event) + else: + self.no_newline = False self.state = self.states.pop() else: self.write_indicator(u',', False) diff --git a/setup.py b/setup.py index 5b60dd1..9b15f4e 100644 --- a/setup.py +++ b/setup.py @@ -434,7 +434,7 @@ class NameSpacePackager(object): while fpn: self._split.insert(0, '.'.join(fpn)) fpn = fpn[:-1] - for d in os.listdir('.'): + for d in sorted(os.listdir('.')): if not os.path.isdir(d) or d == self._split[0] or d[0] in '._': continue # prevent sub-packages in namespace from being included @@ -450,7 +450,9 @@ class NameSpacePackager(object): (y.encode('utf-8') if isinstance(y, unicode) else y) for y in self._split ] if skip: - print('skipping sub-packages:', ', '.join(skip)) + # this interferes with output checking + # print('skipping sub-packages:', ', '.join(skip)) + pass return self._split @property -- cgit v1.2.1