summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-04-05 22:05:13 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-04-05 22:05:13 +0200
commit44f33876f1b7ca0e1670b6f6f2d52f2992673405 (patch)
treeb1302ada4baeb5ec8cc8d355b9ed35c32cb9e34b
parent025693ddf51960b599ddeed1c2adb999b00dbf32 (diff)
downloadruamel.yaml-44f33876f1b7ca0e1670b6f6f2d52f2992673405.tar.gz
optionally allow duplicate merge keys0.15.91
https://stackoverflow.com/questions/55540686/configuring-ruamel-yaml-to-allow-duplicate-keys reported by mamacdon
-rw-r--r--CHANGES8
-rw-r--r--README.rst10
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--constructor.py8
5 files changed, 26 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 9b46ce2..ab457f6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+[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/>`__
+
+[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/>`__
+
[0, 15, 90]: 2019-04-04
- fix issue with updating `CommentedMap` from list of tuples (reported by
`Peter Henry <https://bitbucket.org/mosbasik/>`__)
diff --git a/README.rst b/README.rst
index 54e3ba7..f359efc 100644
--- a/README.rst
+++ b/README.rst
@@ -4,8 +4,8 @@ ruamel.yaml
``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.
-:version: 0.15.90
-:updated: 2019-04-04
+:version: 0.15.91
+:updated: 2019-04-05
: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.91 (2019-04-05):
+ - allowing duplicate keys would not work for merge keys (reported by mamacdon on
+ `StackOverflow <https://stackoverflow.com/questions/55540686/>`__
+
0.15.90 (2019-04-04):
- fix issue with updating `CommentedMap` from list of tuples (reported by
`Peter Henry <https://bitbucket.org/mosbasik/>`__)
@@ -74,7 +78,7 @@ ChangeLog
0.15.86 (2019-01-16):
- reinsert merge key in its old position (reported by grumbler on
- <Stackoverflow <https://stackoverflow.com/a/54206512/1307905>`__)
+ `StackOverflow <https://stackoverflow.com/a/54206512/1307905>`__)
- fix for issue with non-ASCII anchor names (reported and fix
provided by Dandaleon Flux via email)
- fix for issue when parsing flow mapping value starting with colon (in pure Python only)
diff --git a/__init__.py b/__init__.py
index cb39f68..d1481e1 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, 90),
- __version__='0.15.90',
+ version_info=(0, 15, 91),
+ __version__='0.15.91',
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 eb22633..6bc0f5e 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.90</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.90</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.91</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.91</text></g> </svg>
diff --git a/constructor.py b/constructor.py
index 3f11c56..4e76f18 100644
--- a/constructor.py
+++ b/constructor.py
@@ -362,6 +362,10 @@ class SafeConstructor(BaseConstructor):
key_node, value_node = node.value[index]
if key_node.tag == u'tag:yaml.org,2002:merge':
if merge: # double << key
+ if self.allow_duplicate_keys:
+ del node.value[index]
+ index += 1
+ continue
args = [
'while constructing a mapping',
node.start_mark,
@@ -1330,6 +1334,10 @@ class RoundTripConstructor(SafeConstructor):
key_node, value_node = node.value[index]
if key_node.tag == u'tag:yaml.org,2002:merge':
if merge_map_list: # double << key
+ if self.allow_duplicate_keys:
+ del node.value[index]
+ index += 1
+ continue
args = [
'while constructing a mapping',
node.start_mark,