Lines Matching refs:self
24 def __init__(self):
25 self.constructed_objects = {}
26 self.recursive_objects = {}
27 self.state_generators = []
28 self.deep_construct = False
30 def check_data(self):
32 return self.check_node()
34 def check_state_key(self, key):
38 if self.get_state_keys_blacklist_regexp().match(key):
42 def get_data(self):
44 if self.check_node():
45 return self.construct_document(self.get_node())
47 def get_single_data(self):
49 node = self.get_single_node()
51 return self.construct_document(node)
54 def construct_document(self, node):
55 data = self.construct_object(node)
56 while self.state_generators:
57 state_generators = self.state_generators
58 self.state_generators = []
62 self.constructed_objects = {}
63 self.recursive_objects = {}
64 self.deep_construct = False
67 def construct_object(self, node, deep=False):
68 if node in self.constructed_objects:
69 return self.constructed_objects[node]
71 old_deep = self.deep_construct
72 self.deep_construct = True
73 if node in self.recursive_objects:
76 self.recursive_objects[node] = None
79 if node.tag in self.yaml_constructors:
80 constructor = self.yaml_constructors[node.tag]
82 for tag_prefix in self.yaml_multi_constructors:
85 constructor = self.yaml_multi_constructors[tag_prefix]
88 if None in self.yaml_multi_constructors:
90 constructor = self.yaml_multi_constructors[None]
91 elif None in self.yaml_constructors:
92 constructor = self.yaml_constructors[None]
94 constructor = self.__class__.construct_scalar
96 constructor = self.__class__.construct_sequence
98 constructor = self.__class__.construct_mapping
100 data = constructor(self, node)
102 data = constructor(self, tag_suffix, node)
106 if self.deep_construct:
110 self.state_generators.append(generator)
111 self.constructed_objects[node] = data
112 del self.recursive_objects[node]
114 self.deep_construct = old_deep
117 def construct_scalar(self, node):
124 def construct_sequence(self, node, deep=False):
129 return [self.construct_object(child, deep=deep)
132 def construct_mapping(self, node, deep=False):
139 key = self.construct_object(key_node, deep=deep)
143 value = self.construct_object(value_node, deep=deep)
147 def construct_pairs(self, node, deep=False):
154 key = self.construct_object(key_node, deep=deep)
155 value = self.construct_object(value_node, deep=deep)
173 def construct_scalar(self, node):
177 return self.construct_scalar(value_node)
180 def flatten_mapping(self, node):
188 self.flatten_mapping(value_node)
198 self.flatten_mapping(subnode)
215 def construct_mapping(self, node, deep=False):
217 self.flatten_mapping(node)
220 def construct_yaml_null(self, node):
221 self.construct_scalar(node)
233 def construct_yaml_bool(self, node):
234 value = self.construct_scalar(node)
235 return self.bool_values[value.lower()]
237 def construct_yaml_int(self, node):
238 value = self.construct_scalar(node)
270 def construct_yaml_float(self, node):
271 value = self.construct_scalar(node)
279 return sign*self.inf_value
281 return self.nan_value
294 def construct_yaml_binary(self, node):
296 value = self.construct_scalar(node).encode('ascii')
322 def construct_yaml_timestamp(self, node):
323 value = self.construct_scalar(node)
324 match = self.timestamp_regexp.match(node.value)
353 def construct_yaml_omap(self, node):
371 key = self.construct_object(key_node)
372 value = self.construct_object(value_node)
375 def construct_yaml_pairs(self, node):
392 key = self.construct_object(key_node)
393 value = self.construct_object(value_node)
396 def construct_yaml_set(self, node):
399 value = self.construct_mapping(node)
402 def construct_yaml_str(self, node):
403 return self.construct_scalar(node)
405 def construct_yaml_seq(self, node):
408 data.extend(self.construct_sequence(node))
410 def construct_yaml_map(self, node):
413 value = self.construct_mapping(node)
416 def construct_yaml_object(self, node, cls):
420 state = self.construct_mapping(node, deep=True)
423 state = self.construct_mapping(node)
426 def construct_undefined(self, node):
486 def get_state_keys_blacklist(self):
489 def get_state_keys_blacklist_regexp(self):
490 if not hasattr(self, 'state_keys_blacklist_regexp'):
491 self.state_keys_blacklist_regexp = re.compile('(' + '|'.join(self.get_state_keys_blacklist()) + ')')
492 return self.state_keys_blacklist_regexp
494 def construct_python_str(self, node):
495 return self.construct_scalar(node)
497 def construct_python_unicode(self, node):
498 return self.construct_scalar(node)
500 def construct_python_bytes(self, node):
502 value = self.construct_scalar(node).encode('ascii')
516 def construct_python_long(self, node):
517 return self.construct_yaml_int(node)
519 def construct_python_complex(self, node):
520 return complex(self.construct_scalar(node))
522 def construct_python_tuple(self, node):
523 return tuple(self.construct_sequence(node))
525 def find_python_module(self, name, mark, unsafe=False):
540 def find_python_name(self, name, mark, unsafe=False):
565 def construct_python_name(self, suffix, node):
566 value = self.construct_scalar(node)
570 return self.find_python_name(suffix, node.start_mark)
572 def construct_python_module(self, suffix, node):
573 value = self.construct_scalar(node)
577 return self.find_python_module(suffix, node.start_mark)
579 def make_python_instance(self, suffix, node,
585 cls = self.find_python_name(suffix, node.start_mark)
595 def set_python_instance_state(self, instance, state, unsafe=False):
605 self.check_state_key(key)
611 self.check_state_key(key)
614 def construct_python_object(self, suffix, node):
617 instance = self.make_python_instance(suffix, node, newobj=True)
620 state = self.construct_mapping(node, deep=deep)
621 self.set_python_instance_state(instance, state)
623 def construct_python_object_apply(self, suffix, node, newobj=False):
636 args = self.construct_sequence(node, deep=True)
642 value = self.construct_mapping(node, deep=True)
648 instance = self.make_python_instance(suffix, node, args, kwds, newobj)
650 self.set_python_instance_state(instance, state)
658 def construct_python_object_new(self, suffix, node):
659 return self.construct_python_object_apply(suffix, node, newobj=True)
715 def find_python_module(self, name, mark):
716 return super(UnsafeConstructor, self).find_python_module(name, mark, unsafe=True)
718 def find_python_name(self, name, mark):
719 return super(UnsafeConstructor, self).find_python_name(name, mark, unsafe=True)
721 def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False):
722 return super(UnsafeConstructor, self).make_python_instance(
725 def set_python_instance_state(self, instance, state):
726 return super(UnsafeConstructor, self).set_python_instance_state(