MCPcopy Create free account
hub / github.com/apache/madlib / construct_python_object_apply

Method construct_python_object_apply

src/madpack/yaml/constructor.py:574–607  ·  view source on GitHub ↗
(self, suffix, node, newobj=False)

Source from the content-addressed store, hash-verified

572 self.set_python_instance_state(instance, state)
573
574 def construct_python_object_apply(self, suffix, node, newobj=False):
575 # Format:
576 # !!python/object/apply # (or !!python/object/new)
577 # args: [ ... arguments ... ]
578 # kwds: { ... keywords ... }
579 # state: ... state ...
580 # listitems: [ ... listitems ... ]
581 # dictitems: { ... dictitems ... }
582 # or short format:
583 # !!python/object/apply [ ... arguments ... ]
584 # The difference between !!python/object/apply and !!python/object/new
585 # is how an object is created, check make_python_instance for details.
586 if isinstance(node, SequenceNode):
587 args = self.construct_sequence(node, deep=True)
588 kwds = {}
589 state = {}
590 listitems = []
591 dictitems = {}
592 else:
593 value = self.construct_mapping(node, deep=True)
594 args = value.get('args', [])
595 kwds = value.get('kwds', {})
596 state = value.get('state', {})
597 listitems = value.get('listitems', [])
598 dictitems = value.get('dictitems', {})
599 instance = self.make_python_instance(suffix, node, args, kwds, newobj)
600 if state:
601 self.set_python_instance_state(instance, state)
602 if listitems:
603 instance.extend(listitems)
604 if dictitems:
605 for key in dictitems:
606 instance[key] = dictitems[key]
607 return instance
608
609 def construct_python_object_new(self, suffix, node):
610 return self.construct_python_object_apply(suffix, node, newobj=True)

Callers 1

Calls 5

make_python_instanceMethod · 0.95
construct_sequenceMethod · 0.80
construct_mappingMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected