diff options
author | Anthon van der Neut <anthon@mnt.org> | 2019-08-16 07:24:14 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2019-08-16 07:24:14 +0200 |
commit | 253509a0afc997ab1fc027fc9344aea30dc7632b (patch) | |
tree | 3292b0d2d7a69aef781795002429fd4b59a383b5 | |
parent | 37703e0ceb151d4a96b434626b4851ffe1250bb2 (diff) | |
download | ruamel.yaml-253509a0afc997ab1fc027fc9344aea30dc7632b.tar.gz |
output of # in TAG directive0.16.4
fixes issue #307
*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))*
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | README.rst | 9 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _test/test_issues.py | 10 | ||||
-rw-r--r-- | emitter.py | 21 | ||||
-rw-r--r-- | scanner.py | 2 |
7 files changed, 38 insertions, 15 deletions
@@ -1,3 +1,8 @@ +[0, 16, 4]: 2019-08-16 + - fix output of TAG directives with # (reported by `Thomas Smith + <https://bitbucket.org/%7Bd4c57a72-f041-4843-8217-b4d48b6ece2f%7D/>`__) + + [0, 16, 3]: 2019-08-15 - move setting of version based on YAML directive to scanner, allowing to check for file version during TAG directive scanning @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.16.3 -:updated: 2019-08-15 +:version: 0.16.4 +:updated: 2019-08-16 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/yaml :pypi: https://pypi.org/project/ruamel.yaml/ @@ -54,6 +54,11 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) +0.16.4 (2019-08-16): + - fix output of TAG directives with # (reported by `Thomas Smith + <https://bitbucket.org/%7Bd4c57a72-f041-4843-8217-b4d48b6ece2f%7D/>`__) + + 0.16.3 (2019-08-15): - split construct_object - change stuff back to keep mypy happy diff --git a/__init__.py b/__init__.py index fa58ebc..a04077d 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, 16, 3), - __version__='0.16.3', + version_info=(0, 16, 4), + __version__='0.16.4', 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 7e4cfcd..4b1b796 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.16.3</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.16.3</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.16.4</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.16.4</text></g> </svg> diff --git a/_test/test_issues.py b/_test/test_issues.py index f2b5d74..673ba45 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -869,6 +869,16 @@ class TestIssues: """ d = na_round_trip(inp) # NOQA + def test_issue_307(self): + inp = """ + %YAML 1.2 + %TAG ! tag:example.com,2019/path# + --- + null + ... + """ + d = na_round_trip(inp) # NOQA + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): # inp = """ @@ -169,7 +169,7 @@ class Emitter(object): self.prefixed_colon = self.colon if prefix_colon is None else prefix_colon + self.colon # single entry mappings in flow sequence self.brace_single_entry_mapping_in_flow_sequence = ( - brace_single_entry_mapping_in_flow_sequence + brace_single_entry_mapping_in_flow_sequence ) # NOQA # Formatting details. @@ -410,8 +410,11 @@ class Emitter(object): and self.sequence_context ): self.sequence_context = False - if root and isinstance(self.event, ScalarEvent) \ - and not self.scalar_after_indicator: + if ( + root + and isinstance(self.event, ScalarEvent) + and not self.scalar_after_indicator + ): self.write_indent() self.process_tag() if isinstance(self.event, ScalarEvent): @@ -917,14 +920,14 @@ class Emitter(object): start = end = 0 if prefix[0] == u'!': end = 1 + ch_set = u"-;/?:@&=+$,_.~*'()[]" + if self.dumper: + version = getattr(self.dumper, 'version', (1, 2)) + if version is None or version >= (1, 2): + ch_set += u'#' while end < len(prefix): ch = prefix[end] - if ( - u'0' <= ch <= u'9' - or u'A' <= ch <= u'Z' - or u'a' <= ch <= u'z' - or ch in u"-;/?!:@&=+$,_.~*'()[]" - ): + if u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' or ch in ch_set: end += 1 else: if start < end: @@ -1677,7 +1677,7 @@ class Scanner(object): or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z' or ch in "-;/?:@&=+$,_.!~*'()[]%" - or ((self.scanner_processing_version > (1, 1)) and ch == "#") + or ((self.scanner_processing_version > (1, 1)) and ch == '#') ): if ch == '%': chunks.append(self.reader.prefix(length)) |