diff options
-rw-r--r-- | CHANGES | 22 | ||||
-rw-r--r-- | README.rst | 14 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _test/test_issues.py | 2 | ||||
-rw-r--r-- | resolver.py | 64 |
6 files changed, 39 insertions, 69 deletions
@@ -1,3 +1,25 @@ +[0, 15, 58]: 2018-08-17 + - simple mappings can now be used as keys when round-tripping:: + + {a: 1, b: 2}: hello world + + although using the obvious operations (del, popitem) on the key will + fail, you can mutilate it by going through its attributes. If you load the + above YAML in `d`, then changing the value is cumbersome: + + d = {CommentedKeyMap([('a', 1), ('b', 2)]): "goodbye"} + + and changing the key even more so: + + d[CommentedKeyMap([('b', 1), ('a', 2)])] = d.pop( + CommentedKeyMap([('a', 1), ('b', 2)])) + + (you can use a `dict` instead of a list of tuples (or ordereddict), but that might result + in a different order, of the keys of the key, in the output) + - check integers to dump with 1.2 patterns instead of 1.1 (reported by + `Lele Gaifax <https://bitbucket.org/lele/>`__) + + [0, 15, 57]: 2018-08-15 - Fix that CommentedSeq could no longer be used in adding or do a copy (reported by `Christopher Wright <https://bitbucket.org/CJ-Wright4242/>`__) @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.57 -:updated: 2018-08-15 +:version: 0.15.58 +:updated: 2018-08-17 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :pypi: https://pypi.org/project/ruamel.yaml/ @@ -54,7 +54,7 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) -NEXT: +0.15.58 (2018-08-17): - simple mappings can now be used as keys when round-tripping:: {a: 1, b: 2}: hello world @@ -64,11 +64,17 @@ NEXT: above YAML in `d`, then changing the value is cumbersome: d = {CommentedKeyMap([('a', 1), ('b', 2)]): "goodbye"} + and changing the key even more so: - d[CommentedKeyMap([('b', 1), ('a', 2)])]= d.pop(CommentedKeyMap([('a', 1), ('b', 2)])) + d[CommentedKeyMap([('b', 1), ('a', 2)])] = d.pop( + CommentedKeyMap([('a', 1), ('b', 2)])) + (you can use a `dict` instead of a list of tuples (or ordereddict), but that might result in a different order, of the keys of the key, in the output) + - check integers to dump with 1.2 patterns instead of 1.1 (reported by + `Lele Gaifax <https://bitbucket.org/lele/>`__) + 0.15.57 (2018-08-15): - Fix that CommentedSeq could no longer be used in adding or do a sort diff --git a/__init__.py b/__init__.py index 7bfc69e..c2c86f4 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, 57), - __version__='0.15.57', + version_info=(0, 15, 58), + __version__='0.15.58', 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 0e2e85f..d1b22aa 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.57</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.57</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.58</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.58</text></g> </svg> diff --git a/_test/test_issues.py b/_test/test_issues.py index 76fae01..cd9521c 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -282,7 +282,7 @@ class TestIssues: def test_issue_22(self): import ruamel.yaml from ruamel.yaml.compat import StringIO + buf = StringIO() ruamel.yaml.safe_dump(['012923'], buf) assert buf.getvalue() == "['012923']\n" - diff --git a/resolver.py b/resolver.py index 44e7b27..13cc33d 100644 --- a/resolver.py +++ b/resolver.py @@ -305,67 +305,9 @@ class Resolver(BaseResolver): pass -# fmt: off -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:bool', - RegExp(u'''^(?:yes|Yes|YES|no|No|NO - |true|True|TRUE|false|False|FALSE - |on|On|ON|off|Off|OFF)$''', re.X), - list(u'yYnNtTfFoO')) - -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:float', - RegExp(u'''^(?: - [-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+]?[0-9]+)? - |[-+]?(?:[0-9][0-9_]*)(?:[eE][-+]?[0-9]+) - |\\.[0-9_]+(?:[eE][-+][0-9]+)? - |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]* - |[-+]?\\.(?:inf|Inf|INF) - |\\.(?:nan|NaN|NAN))$''', re.X), - list(u'-+0123456789.')) - -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:int', - RegExp(u'''^(?:[-+]?0b[0-1_]+ - |[-+]?0o?[0-7_]+ - |[-+]?(?:0|[1-9][0-9_]*) - |[-+]?0x[0-9a-fA-F_]+ - |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X), - list(u'-+0123456789')) - -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:merge', - RegExp(u'^(?:<<)$'), - [u'<']) - -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:null', - RegExp(u'''^(?: ~ - |null|Null|NULL - | )$''', re.X), - [u'~', u'n', u'N', u'']) - -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:timestamp', - RegExp(u'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] - |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]? - (?:[Tt]|[ \\t]+)[0-9][0-9]? - :[0-9][0-9] :[0-9][0-9] (?:\\.[0-9]*)? - (?:[ \\t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X), - list(u'0123456789')) - -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:value', - RegExp(u'^(?:=)$'), - [u'=']) - -# The following resolver is only for documentation purposes. It cannot work -# because plain scalars cannot start with '!', '&', or '*'. -Resolver.add_implicit_resolver_base( - u'tag:yaml.org,2002:yaml', - RegExp(u'^(?:!|&|\\*)$'), - list(u'!&*')) -# fmt: on +for ir in implicit_resolvers: + if (1, 2) in ir[0]: + Resolver.add_implicit_resolver_base(*ir[1:]) class VersionedResolver(BaseResolver): |