MCPcopy Create free account
hub / github.com/scanny/python-pptx / OneOrMore

Class OneOrMore

src/pptx/oxml/xmlchemy.py:503–538  ·  view source on GitHub ↗

Defines a repeating child element for MetaOxmlElement that must appear at least once.

Source from the content-addressed store, hash-verified

501
502
503class OneOrMore(_BaseChildElement):
504 """Defines a repeating child element for MetaOxmlElement that must appear at least once."""
505
506 def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
507 """Add the appropriate methods to *element_cls*."""
508 super(OneOrMore, self).populate_class_members(element_cls, prop_name)
509 self._add_list_getter()
510 self._add_creator()
511 self._add_inserter()
512 self._add_adder()
513 self._add_public_adder()
514 delattr(element_cls, prop_name)
515
516 def _add_public_adder(self) -> None:
517 """Add a public `.add_x()` method to the parent element class."""
518
519 def add_child(obj: BaseOxmlElement) -> BaseOxmlElement:
520 private_add_method = getattr(obj, self._add_method_name)
521 child = private_add_method()
522 return child
523
524 add_child.__doc__ = (
525 "Add a new ``<%s>`` child element unconditionally, inserted in t"
526 "he correct sequence." % self._nsptagname
527 )
528 self._add_to_class(self._public_add_method_name, add_child)
529
530 @lazyproperty
531 def _public_add_method_name(self):
532 """
533 add_childElement() is public API for a repeating element, allowing
534 new elements to be added to the sequence. May be overridden to
535 provide a friendlier API to clients having domain appropriate
536 parameter names for required attributes.
537 """
538 return "add_%s" % self._prop_name
539
540
541class ZeroOrMore(_BaseChildElement):

Callers 3

CT_TextBodyClass · 0.90
CT_GradientStopListClass · 0.90
CT_ParentClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…