summaryrefslogtreecommitdiff
path: root/constructor.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-07-13 23:32:42 +0200
committerAnthon van der Neut <anthon@mnt.org>2017-07-13 23:32:42 +0200
commiteaba7badcb3ce04a9db6e4fe8504950cef832f7d (patch)
treeb6fefde9db338bf03ae0569ad9c4d84bd96aa1ac /constructor.py
parent2ea4de43fe2e0160e27b605f2c65f33c5a2083d7 (diff)
downloadruamel.yaml-eaba7badcb3ce04a9db6e4fe8504950cef832f7d.tar.gz
added register_class/yaml_object0.15.19
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 fd1926e..c957cd0 100644
--- a/constructor.py
+++ b/constructor.py
@@ -1278,6 +1278,17 @@ class RoundTripConstructor(SafeConstructor):
yield data
self.construct_mapping(node, data)
+ def construct_yaml_object(self, node, cls):
+ # type: (Any, Any) -> Any
+ data = cls.__new__(cls)
+ yield data
+ if hasattr(data, '__setstate__'):
+ state = SafeConstructor.construct_mapping(self, node, deep=True)
+ data.__setstate__(state)
+ else:
+ state = SafeConstructor.construct_mapping(self, node)
+ data.__dict__.update(state)
+
def construct_yaml_omap(self, node):
# type: (Any) -> Any
# Note: we do now check for duplicate keys