summaryrefslogtreecommitdiff
path: root/constructor.py
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 /constructor.py
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
Diffstat (limited to 'constructor.py')
-rw-r--r--constructor.py8
1 files changed, 8 insertions, 0 deletions
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,