diff options
-rw-r--r-- | .appveyor.yaml | 3 | ||||
-rw-r--r-- | CHANGES | 7 | ||||
-rw-r--r-- | Dockerfile | 2 | ||||
-rw-r--r-- | README.rst | 11 | ||||
-rw-r--r-- | __init__.py | 7 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _test/test_issues.py | 31 | ||||
-rw-r--r-- | emitter.py | 5 | ||||
-rw-r--r-- | scanner.py | 22 | ||||
-rwxr-xr-x | tox.ini | 2 |
10 files changed, 77 insertions, 15 deletions
diff --git a/.appveyor.yaml b/.appveyor.yaml index fcc4086..4f53ba4 100644 --- a/.appveyor.yaml +++ b/.appveyor.yaml @@ -4,9 +4,6 @@ environment: matrix: - PYTHON: C:\Python27 - PYTHON: C:\Python27-x64 - - PYTHON: C:\Python34 - - PYTHON: C:\Python34-x64 - DISTUTILS_USE_SDK: '1' - PYTHON: C:\Python35 - PYTHON: C:\Python35-x64 - PYTHON: C:\Python36 @@ -1,3 +1,10 @@ +[0, 15, 95]: 2019-05-16 + - fix failure to round-trip anchored scalars in block sequence + (reported by `William Kimball + <https://bitbucket.org/%7Bba35ed20-4bb0-46f8-bb5d-c29871e86a22%7D/>`__) + - wheel files for Python 3.4 no longer provided (`Python 3.4 EOL 2019-03-18 + <https://www.python.org/dev/peps/pep-0429/>`__) + [0, 15, 94]: 2019-04-23 - fix missing line-break after end-of-file comments not ending in line-break (reported by `Philip Thompson @@ -24,6 +24,6 @@ RUN echo 'done' >> /usr/bin/makewheel RUN chmod 755 /usr/bin/makewheel -CMD /usr/bin/makewheel 27 34 35 36 37 +CMD /usr/bin/makewheel 27 35 36 37 # cp27-cp27m p27-cp27mu cp34-cp34m cp35-cp35m cp36-cp36m cp37-cp37m @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.94 -:updated: 2019-04-23 +:version: 0.15.95 +:updated: 2019-05-16 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :pypi: https://pypi.org/project/ruamel.yaml/ @@ -54,6 +54,13 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) +0.15.95 (2019-05-16): + - fix failure to round-trip anchored scalars in block sequence + (reported by `William Kimball + <https://bitbucket.org/%7Bba35ed20-4bb0-46f8-bb5d-c29871e86a22%7D/>`__) + - wheel files for Python 3.4 no longer provided (`Python 3.4 EOL 2019-03-18 + <https://www.python.org/dev/peps/pep-0429/>`__) + 0.15.94 (2019-04-23): - fix missing line-break after end-of-file comments not ending in line-break (reported by `Philip Thompson diff --git a/__init__.py b/__init__.py index c7aa6c8..82769bb 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, 94), - __version__='0.15.94', + version_info=(0, 15, 95), + __version__='0.15.95', 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 @@ -49,7 +49,6 @@ _package_data = dict( # test='#include "ext/yaml.h"\n\nint main(int argc, char* argv[])\n{\nyaml_parser_t parser;\nparser = parser; /* prevent warning */\nreturn 0;\n}\n', # NOQA classifiers=[ 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', @@ -62,7 +61,7 @@ _package_data = dict( keywords='yaml 1.2 parser round-trip preserve quotes order config', wheels=dict(windows='appveyor', linux='libyaml-devel', macos='builder@macos'), read_the_docs='yaml', - supported=[(2, 7), (3, 4)], # minimum + supported=[(2, 7), (3, 5)], # minimum tox=dict( env='*pn', # also test narrow Python 2.7.15 for unicode patterns deps='ruamel.std.pathlib', diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg index 10d8154..1c1ffd2 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.94</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.94</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.95</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.95</text></g> </svg> diff --git a/_test/test_issues.py b/_test/test_issues.py index dd534ca..ec7d95d 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -664,6 +664,37 @@ class TestIssues: yaml.dump(a, buf) assert buf.getvalue().endswith('xxx\nnew_key: new_value\n') + def test_issue_288(self): + import sys + from ruamel.yaml.compat import StringIO + from ruamel.yaml import YAML + + yamldoc = dedent("""\ + --- + # Reusable values + aliases: + # First-element comment + - &firstEntry First entry + # Second-element comment + - &secondEntry Second entry + + # Third-element comment is + # a multi-line value + - &thirdEntry Third entry + + # EOF Comment + """) + + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.explicit_start = True + yaml.preserve_quotes = True + yaml.width = sys.maxsize + data = yaml.load(yamldoc) + buf = StringIO() + yaml.dump(data, buf) + assert buf.getvalue() == yamldoc + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): # inp = """ @@ -421,7 +421,6 @@ class Emitter(object): self.indention = False self.no_newline = True if self.write_pre_comment(self.event): - pass self.indention = i2 self.no_newline = not self.indention if ( @@ -780,6 +779,8 @@ class Emitter(object): self.prepared_anchor = self.prepare_anchor(self.event.anchor) if self.prepared_anchor: self.write_indicator(indicator + self.prepared_anchor, True) + # issue 288 + self.no_newline = False self.prepared_anchor = None return True @@ -1631,7 +1632,7 @@ class Emitter(object): # at least one space if the current column >= the start column of the comment # but not at the start of a line nr_spaces = col - self.column - if self.column and value.strip() and nr_spaces < 1: + if self.column and value.strip() and nr_spaces < 1 and value[0] != '\n': nr_spaces = 1 value = ' ' * nr_spaces + value try: @@ -1794,7 +1794,7 @@ class RoundTripScanner(Scanner): if isinstance(self.tokens[0], CommentToken): self.tokens_taken += 1 comment = self.tokens.pop(0) - # print 'dropping2', comment + # nprint('dropping2', comment) comments.append(comment) if len(comments) >= 1: self.tokens[0].add_pre_comments(comments) @@ -1825,6 +1825,26 @@ class RoundTripScanner(Scanner): ): self.tokens_taken += 1 self.tokens[0].add_post_comment(self.tokens.pop(1)) + elif ( + len(self.tokens) > 1 + and isinstance(self.tokens[0], ScalarToken) + and isinstance(self.tokens[1], CommentToken) + and self.tokens[0].end_mark.line != self.tokens[1].start_mark.line + ): + self.tokens_taken += 1 + c = self.tokens.pop(1) + c.value = ( + '\n' * (c.start_mark.line - self.tokens[0].end_mark.line) + + (' ' * c.start_mark.column) + + c.value + ) + self.tokens[0].add_post_comment(c) + self.fetch_more_tokens() + while len(self.tokens) > 1 and isinstance(self.tokens[1], CommentToken): + self.tokens_taken += 1 + c1 = self.tokens.pop(1) + c.value = c.value + (' ' * c.start_mark.column) + c1.value + self.fetch_more_tokens() self.tokens_taken += 1 return self.tokens.pop(0) return None @@ -1,6 +1,6 @@ [tox] # toxworkdir = /data1/DATA/tox/ruamel.yaml -envlist = cs,py37,py27,py36,py35,py34,py38,pypy,py27m +envlist = cs,py37,py27,py36,py35,py38,pypy,py27m [testenv] commands = |