summaryrefslogtreecommitdiff
path: root/constructor.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-02-18 17:50:19 +0100
committerAnthon van der Neut <anthon@mnt.org>2016-02-18 17:50:19 +0100
commitb8845506796879b1a756471a977ef60eb53f444e (patch)
tree7e6dcc6dc5939dfd78603a1590179d081dc50a63 /constructor.py
parentd588fa199a087020d1c1346d54f24b0972f1fbed (diff)
downloadruamel.yaml-b8845506796879b1a756471a977ef60eb53f444e.tar.gz
- introducing version support and differentiation for RoundTripLoader0.11.0
1.2 no longer interprets sexagesimals, octals wihtout 0o, Yes/No/On/Off by default - added round_trip_load/round_trip_load_all
Diffstat (limited to 'constructor.py')
-rw-r--r--constructor.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/constructor.py b/constructor.py
index c3b5a59..9ae2e23 100644
--- a/constructor.py
+++ b/constructor.py
@@ -73,6 +73,9 @@ class BaseConstructor(object):
return data
def construct_object(self, node, deep=False):
+ """deep is True when creating an object/mapping recursively,
+ in that case want the underlying elements available during construction
+ """
if node in self.constructed_objects:
return self.constructed_objects[node]
if deep:
@@ -132,6 +135,9 @@ class BaseConstructor(object):
return node.value
def construct_sequence(self, node, deep=False):
+ """deep is True when creating an object/mapping recursively,
+ in that case want the underlying elements available during construction
+ """
if not isinstance(node, SequenceNode):
raise ConstructorError(
None, None,
@@ -141,6 +147,9 @@ class BaseConstructor(object):
for child in node.value]
def construct_mapping(self, node, deep=False):
+ """deep is True when creating an object/mapping recursively,
+ in that case want the underlying elements available during construction
+ """
if not isinstance(node, MappingNode):
raise ConstructorError(
None, None,
@@ -250,6 +259,9 @@ class SafeConstructor(BaseConstructor):
node.value = merge + node.value
def construct_mapping(self, node, deep=False):
+ """deep is True when creating an object/mapping recursively,
+ in that case want the underlying elements available during construction
+ """
if isinstance(node, MappingNode):
self.flatten_mapping(node)
return BaseConstructor.construct_mapping(self, node, deep=deep)
@@ -288,9 +300,9 @@ class SafeConstructor(BaseConstructor):
return sign*int(value[2:], 16)
elif value.startswith('0o'):
return sign*int(value[2:], 8)
- elif value[0] == '0':
+ elif self.processing_version != (1, 2) and value[0] == '0':
return sign*int(value, 8)
- elif ':' in value:
+ elif self.processing_version != (1, 2) and ':' in value:
digits = [int(part) for part in value.split(':')]
digits.reverse()
base = 1