diff options
author | Anthon van der Neut <anthon@mnt.org> | 2019-04-05 22:05:13 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2019-04-05 22:05:13 +0200 |
commit | 44f33876f1b7ca0e1670b6f6f2d52f2992673405 (patch) | |
tree | b1302ada4baeb5ec8cc8d355b9ed35c32cb9e34b /constructor.py | |
parent | 025693ddf51960b599ddeed1c2adb999b00dbf32 (diff) | |
download | ruamel.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.py | 8 |
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, |