summaryrefslogtreecommitdiff
path: root/comments.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-08 22:39:09 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-08 22:39:09 +0200
commit593c5df4d4f34c340bfd9f2d7bb12358dabf400f (patch)
tree8b2589e2c4425de7f519660e2e50e2bebce6a8f9 /comments.py
parentfd91cad90c37a36a6574e14feb7c7f2199bba745 (diff)
downloadruamel.yaml-593c5df4d4f34c340bfd9f2d7bb12358dabf400f.tar.gz
fix issue #213 : CommentedMap.copy() incomplete result
Only the "native" keys were copied, not any of the merged keys. Now .copy() is implemented and a "flattened" new dict is returned. *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so usingthe WorkFlow pull-down (close to the top right of this page)*
Diffstat (limited to 'comments.py')
-rw-r--r--comments.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/comments.py b/comments.py
index 84fecbc..88ccea3 100644
--- a/comments.py
+++ b/comments.py
@@ -912,6 +912,13 @@ class CommentedMap(ordereddict, CommentedBase):
setattr(self, merge_attrib, [])
return getattr(self, merge_attrib)
+ def copy(self):
+ x = {} # update doesn't work
+ for k, v in self._items():
+ print(k, v)
+ x[k] = v
+ return x
+
def add_yaml_merge(self, value):
# type: (Any) -> None
self.merge.extend(value)