MCPcopy Create free account
hub / github.com/ablab/spades / construct_object

Method construct_object

ext/src/python_libs/pyyaml3/constructor.py:53–101  ·  view source on GitHub ↗
(self, node, deep=False)

Source from the content-addressed store, hash-verified

51 return data
52
53 def construct_object(self, node, deep=False):
54 if node in self.constructed_objects:
55 return self.constructed_objects[node]
56 if deep:
57 old_deep = self.deep_construct
58 self.deep_construct = True
59 if node in self.recursive_objects:
60 raise ConstructorError(None, None,
61 "found unconstructable recursive node", node.start_mark)
62 self.recursive_objects[node] = None
63 constructor = None
64 tag_suffix = None
65 if node.tag in self.yaml_constructors:
66 constructor = self.yaml_constructors[node.tag]
67 else:
68 for tag_prefix in self.yaml_multi_constructors:
69 if node.tag.startswith(tag_prefix):
70 tag_suffix = node.tag[len(tag_prefix):]
71 constructor = self.yaml_multi_constructors[tag_prefix]
72 break
73 else:
74 if None in self.yaml_multi_constructors:
75 tag_suffix = node.tag
76 constructor = self.yaml_multi_constructors[None]
77 elif None in self.yaml_constructors:
78 constructor = self.yaml_constructors[None]
79 elif isinstance(node, ScalarNode):
80 constructor = self.__class__.construct_scalar
81 elif isinstance(node, SequenceNode):
82 constructor = self.__class__.construct_sequence
83 elif isinstance(node, MappingNode):
84 constructor = self.__class__.construct_mapping
85 if tag_suffix is None:
86 data = constructor(self, node)
87 else:
88 data = constructor(self, tag_suffix, node)
89 if isinstance(data, types.GeneratorType):
90 generator = data
91 data = next(generator)
92 if self.deep_construct:
93 for dummy in generator:
94 pass
95 else:
96 self.state_generators.append(generator)
97 self.constructed_objects[node] = data
98 del self.recursive_objects[node]
99 if deep:
100 self.deep_construct = old_deep
101 return data
102
103 def construct_scalar(self, node):
104 if not isinstance(node, ScalarNode):

Callers 6

construct_documentMethod · 0.95
construct_sequenceMethod · 0.95
construct_mappingMethod · 0.95
construct_pairsMethod · 0.95
construct_yaml_omapMethod · 0.80
construct_yaml_pairsMethod · 0.80

Calls 5

ConstructorErrorClass · 0.85
constructorClass · 0.85
startswithMethod · 0.80
nextFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected