summaryrefslogtreecommitdiff
path: root/constructor.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2021-08-21 14:20:29 +0200
committerAnthon van der Neut <anthon@mnt.org>2021-08-21 14:20:29 +0200
commitd97574a94bca9a6b62511ee14bb633a5fdc2e32e (patch)
tree70f59ec02c9336f107c18fd38f2c017dc42de1af /constructor.py
parent15e7b487ef04fe617ec695cf7980763b0b8e170f (diff)
downloadruamel.yaml-d97574a94bca9a6b62511ee14bb633a5fdc2e32e.tar.gz
fix for issue 393
Diffstat (limited to 'constructor.py')
-rw-r--r--constructor.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/constructor.py b/constructor.py
index 563f07b..3cc76a3 100644
--- a/constructor.py
+++ b/constructor.py
@@ -1636,6 +1636,17 @@ class RoundTripConstructor(SafeConstructor):
else:
state = SafeConstructor.construct_mapping(self, node)
data.__dict__.update(state)
+ if node.anchor:
+ from ruamel.yaml.serializer import templated_id
+ from ruamel.yaml.anchor import Anchor
+
+ if not templated_id(node.anchor):
+ if not hasattr(data, Anchor.attrib):
+ a = Anchor()
+ setattr(data, Anchor.attrib, a)
+ else:
+ a = getattr(data, Anchor.attrib)
+ a.value = node.anchor
def construct_yaml_omap(self, node):
# type: (Any) -> Any