diff options
author | Anthon van der Neut <anthon@mnt.org> | 2019-08-15 13:14:08 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2019-08-15 13:14:08 +0200 |
commit | c3ac95be03b0166b5910675f1d07c4d00db9dff8 (patch) | |
tree | 4f176d05d3ae63b68a50b7bbcf027d4fb2088de3 | |
parent | ff8e03fe5542a9d7930a5720450c59bb9e9eaaf3 (diff) | |
download | ruamel.yaml-c3ac95be03b0166b5910675f1d07c4d00db9dff8.tar.gz |
allow # in 1.2 URI's0.16.2
fixes issue #305
*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-- | Dockerfile | 25 | ||||
-rw-r--r-- | README.rst | 9 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _test/roundtrip.py | 6 | ||||
-rw-r--r-- | _test/test_issues.py | 19 | ||||
-rw-r--r-- | docker-compose.yaml | 13 | ||||
-rw-r--r-- | emitter.py | 10 | ||||
-rw-r--r-- | main.py | 3 |
10 files changed, 41 insertions, 55 deletions
@@ -1,3 +1,8 @@ +[0, 16, 2]: 2019-08-15 + - preserve YAML and TAG directives on roundtrip, correctly output # + in URL for YAML 1.2 (both reported by `Thomas Smith + <https://bitbucket.org/%7Bd4c57a72-f041-4843-8217-b4d48b6ece2f%7D/>`__) + [0, 16, 1]: 2019-08-08 - Force the use of new version of ruamel.yaml.clib (reported by `Alex Joz <https://bitbucket.org/%7B9af55900-2534-4212-976c-61339b6ffe14%7D/>`__) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4906b2e..0000000 --- a/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM quay.io/pypa/manylinux1_x86_64:latest - -MAINTAINER Anthon van der Neut <a.van.der.neut@ruamel.eu> - -RUN echo '[global]' > /etc/pip.conf -RUN echo 'disable-pip-version-check = true' >> /etc/pip.conf - -RUN echo 'cd /src' > /usr/bin/makewheel -RUN echo 'rm -f /tmp/*.whl' >> /usr/bin/makewheel -RUN echo 'for PYVER in $*; do' >> /usr/bin/makewheel -RUN echo ' for PYBIN in /opt/python/cp$PYVER*/bin/; do' >> /usr/bin/makewheel -RUN echo ' echo "$PYBIN"' >> /usr/bin/makewheel -RUN echo ' ${PYBIN}/pip install -Uq pip' >> /usr/bin/makewheel -RUN echo ' ${PYBIN}/pip wheel . -w /tmp' >> /usr/bin/makewheel -RUN echo ' done' >> /usr/bin/makewheel -RUN echo 'done' >> /usr/bin/makewheel -RUN echo '' >> /usr/bin/makewheel -RUN echo 'for whl in /tmp/*.whl; do' >> /usr/bin/makewheel -RUN echo ' echo processing "$whl"' >> /usr/bin/makewheel -RUN echo ' auditwheel show "$whl"' >> /usr/bin/makewheel -RUN echo ' auditwheel repair "$whl" -w /src/dist/' >> /usr/bin/makewheel -RUN echo 'done' >> /usr/bin/makewheel -RUN chmod 755 /usr/bin/makewheel - -CMD /usr/bin/makewheel 27 35 36 37 @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.16.1 -:updated: 2019-08-08 +:version: 0.16.2 +:updated: 2019-08-15 :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.2 (2019-08-15): + - preserve YAML and TAG directives on roundtrip, correctly output # + in URL for YAML 1.2 (both reported by `Thomas Smith + <https://bitbucket.org/%7Bd4c57a72-f041-4843-8217-b4d48b6ece2f%7D/>`__) + 0.16.1 (2019-08-08): - Force the use of new version of ruamel.yaml.clib (reported by `Alex Joz <https://bitbucket.org/%7B9af55900-2534-4212-976c-61339b6ffe14%7D/>`__) diff --git a/__init__.py b/__init__.py index 995bca9..7e1b208 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, 1), - __version__='0.16.1', + version_info=(0, 16, 2), + __version__='0.16.2', 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 aa448d9..dc4abf1 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.1</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.16.1</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.2</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.16.2</text></g> </svg> diff --git a/_test/roundtrip.py b/_test/roundtrip.py index 090b9e0..af8a555 100644 --- a/_test/roundtrip.py +++ b/_test/roundtrip.py @@ -169,6 +169,7 @@ def na_round_trip( inp: input string to parse outp: expected output (equals input if not specified) """ + inp = dedent(inp) if outp is None: outp = inp if version is not None: @@ -194,10 +195,7 @@ def na_round_trip( yaml.explicit_start = explicit_start yaml.explicit_end = explicit_end res = yaml.dump(data, compare=doutp) - #if res != doutp: - # diff(doutp, res, 'input string') - #print('\nroundtrip data:\n', res, sep="") - #assert res == doutp + return res def YAML(**kw): diff --git a/_test/test_issues.py b/_test/test_issues.py index 9b301a9..5606122 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -853,11 +853,20 @@ class TestIssues: def test_issue_304(self): inp = """ - %YAML 1.2 - %TAG ! tag:example.com,2019: - --- - !foo null - ... + %YAML 1.2 + %TAG ! tag:example.com,2019: + --- + !foo null + ... + """ + d = na_round_trip(inp) # NOQA + + def test_issue_305(self): + inp = """ + %YAML 1.2 + --- + !<tag:example.com,2019/path#foo> null + ... """ d = na_round_trip(inp) # NOQA diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 1b1e6c4..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,13 +0,0 @@ -version: '2' -user-data: - author: Anthon van der Neut <a.van.der.neut@ruamel.eu> - description: manylinux wheel build container for ruamel.yaml - env-defaults: - PYDISTBASE: /tmp # for building, normally set by `dv --distbase` -services: - ruamel_yaml_manylinux1: - container_name: ruamel_yaml - build: . - volumes: - - ${PYDISTBASE}/ruamel.yaml:/src/dist - - .:/src @@ -410,7 +410,8 @@ 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): @@ -951,13 +952,18 @@ class Emitter(object): suffix = tag[len(prefix) :] chunks = [] # type: List[Any] start = end = 0 + 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(suffix): ch = suffix[end] if ( u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' - or ch in u"-;/?:@&=+$,_.~*'()[]" + or ch in ch_set or (ch == u'!' and handle != u'!') ): end += 1 @@ -161,7 +161,8 @@ class YAML(object): self.tags = None self.default_style = None self.top_level_block_style_scalar_no_indent_error_1_1 = False - self.scalar_after_indicator = None # directives end indicator with single scalar document + # directives end indicator with single scalar document + self.scalar_after_indicator = None # [a, b: 1, c: {d: 2}] vs. [a, {b: 1}, {c: {d: 2}}] self.brace_single_entry_mapping_in_flow_sequence = False |