(self, suffix, node, newobj=False)
| 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) |
no test coverage detected