diff options
-rw-r--r-- | .readthedocs.yaml (renamed from .readthedocs.yml) | 0 | ||||
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | README.rst | 8 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/Makefile | 2 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _doc/api.ryd | 4 | ||||
-rw-r--r-- | _doc/conf.py | 34 | ||||
-rw-r--r-- | _test/test_issues.py | 17 | ||||
-rw-r--r-- | parser.py | 5 |
10 files changed, 57 insertions, 23 deletions
diff --git a/.readthedocs.yml b/.readthedocs.yaml index 914f036..914f036 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yaml @@ -1,3 +1,7 @@ +[0, 15, 92]: 2019-04-16 + - fix failure to parse empty implicit block mapping key (reported by + `Nolan W <https://bitbucket.org/i2labs/>`__) + [0, 15, 91]: 2019-04-05 - allowing duplicate keys would not work for merge keys (reported by mamacdon on `StackOverflow <https://stackoverflow.com/questions/55540686/>`__ @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.91 -:updated: 2019-04-05 +:version: 0.15.92 +:updated: 2019-04-16 :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.92 (2019-04-16): + - fix failure to parse empty implicit block mapping key (reported by + `Nolan W <https://bitbucket.org/i2labs/>`__) + 0.15.91 (2019-04-05): - allowing duplicate keys would not work for merge keys (reported by mamacdon on `StackOverflow <https://stackoverflow.com/questions/55540686/>`__ diff --git a/__init__.py b/__init__.py index d1481e1..eb374fc 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, 91), - __version__='0.15.91', + version_info=(0, 15, 92), + __version__='0.15.92', 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/Makefile b/_doc/Makefile index 630532d..c5d1aa0 100644 --- a/_doc/Makefile +++ b/_doc/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build -PAPER = +PAPER = a4 BUILDDIR = _build # User-friendly check for sphinx-build diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg index 6bc0f5e..d1ffe22 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.91</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.91</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.92</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.92</text></g> </svg> diff --git a/_doc/api.ryd b/_doc/api.ryd index a295565..314bfbd 100644 --- a/_doc/api.ryd +++ b/_doc/api.ryd @@ -95,7 +95,7 @@ all functionality of the old interface will be available via ``YAML`` instances (if you are using something that isn't let me know). If a parse or dump fails, and throws and exception, the state of the -`YAML()` instance is not guaranteed to be able to handle further +``YAML()`` instance is not guaranteed to be able to handle further processing. You should, at that point to recreate the YAML instance before proceeding. @@ -158,7 +158,7 @@ works for output (dumping) only, requires you to specify the output Within the context manager, you cannot use the ``dump()`` with a second (stream) argument, nor can you use ``dump_all()``. The ``dump()`` within the context of the ``YAML()`` automatically creates - multi-document if called more than once. +multi-document if called more than once. To combine multiple YAML documents from multiple files: diff --git a/_doc/conf.py b/_doc/conf.py index f0fbcad..610eecb 100644 --- a/_doc/conf.py +++ b/_doc/conf.py @@ -36,7 +36,7 @@ templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = {'.rst': 'restructuredtext', '.ryd': 'ryd2rst'} # The encoding of source files. # source_encoding = 'utf-8-sig' @@ -46,7 +46,7 @@ master_doc = 'index' # General information about the project. project = u'yaml' -copyright = u'2017-2018, Anthon van der Neut, Ruamel bvba' +copyright = u'2017-2019, Anthon van der Neut, Ruamel bvba' author = u'Anthon van der Neut' # The version info for the project you're documenting, acts as replacement for @@ -67,20 +67,26 @@ print('ruamel.yaml version', version) # print('cwd:', os.getcwd()) # current working directory is the one with `conf.py` ! -try: - from ryd.__main__ import RYDCmd - from ruamel.std.pathlib import Path - oldargv = sys.argv - for fn in Path('.').glob('*.ryd'): - sys.argv = ['ryd', 'convert', '--no-pdf', str(fn)] - rc = RYDCmd() - rc.parse_args() - print(sys.argv, '->', rc.run()) - sys.argv = oldargv +class ryd2rst: + pass -except Exception as e: - print('ryd exception', e) + +if False: + try: + from ryd.__main__ import RYDCmd + from ruamel.std.pathlib import Path + + oldargv = sys.argv + for fn in Path('.').glob('*.ryd'): + sys.argv = ['ryd', 'convert', '--no-pdf', str(fn)] + rc = RYDCmd() + rc.parse_args() + print(sys.argv, '->', rc.run()) + sys.argv = oldargv + + except Exception as e: + print('ryd exception', e) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/_test/test_issues.py b/_test/test_issues.py index 5007f60..dd6910b 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -612,6 +612,23 @@ class TestIssues: assert 'c' in yaml_data.keys() assert 'c' in yaml_data._ok + def test_issue_284(self): + import ruamel.yaml + inp = dedent("""\ + plain key: in-line value + : # Both empty + "quoted key": + - entry + """) + yaml = ruamel.yaml.YAML(typ='rt') + yaml.version = (1, 2) + d = yaml.load(inp) + assert d[None] is None + + yaml = ruamel.yaml.YAML(typ='rt') + yaml.version = (1, 1) + with pytest.raises(ruamel.yaml.parser.ParserError, match='expected <block end>'): + d = yaml.load(inp) # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): @@ -71,7 +71,7 @@ from __future__ import absolute_import # flow_mapping_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START # FLOW-MAPPING-START KEY } -# need to have full path, as pkg_resources tries to load parser.py in __init__.py +# need to have full path with import, as pkg_resources tries to load parser.py in __init__.py # only to not do anything with the package afterwards # and for Jython too @@ -569,6 +569,9 @@ class Parser(object): else: self.state = self.parse_block_mapping_value return self.process_empty_scalar(token.end_mark) + if self.resolver.processing_version > (1, 1) and self.scanner.check_token(ValueToken): + self.state = self.parse_block_mapping_value + return self.process_empty_scalar(self.scanner.peek_token().start_mark) if not self.scanner.check_token(BlockEndToken): token = self.scanner.peek_token() raise ParserError( |