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

Class OneAndOnlyOne

src/pptx/oxml/xmlchemy.py:474–500  ·  view source on GitHub ↗

Defines a required child element for MetaOxmlElement.

Source from the content-addressed store, hash-verified

472
473
474class OneAndOnlyOne(_BaseChildElement):
475 """Defines a required child element for MetaOxmlElement."""
476
477 def __init__(self, nsptagname: str):
478 super(OneAndOnlyOne, self).__init__(nsptagname, ())
479
480 def populate_class_members(self, element_cls: Type[BaseOxmlElement], prop_name: str):
481 """
482 Add the appropriate methods to *element_cls*.
483 """
484 super(OneAndOnlyOne, self).populate_class_members(element_cls, prop_name)
485 self._add_getter()
486
487 @property
488 def _getter(self) -> Callable[[BaseOxmlElement], BaseOxmlElement]:
489 """Callable suitable for the "get" side of the property descriptor."""
490
491 def get_child_element(obj: BaseOxmlElement) -> BaseOxmlElement:
492 child = obj.find(qn(self._nsptagname))
493 if child is None:
494 raise InvalidXmlError(
495 "required ``<%s>`` child element not present" % self._nsptagname
496 )
497 return child
498
499 get_child_element.__doc__ = "Required ``<%s>`` child element." % self._nsptagname
500 return get_child_element
501
502
503class OneOrMore(_BaseChildElement):

Callers 15

CT_RegularTextRunClass · 0.90
CT_TextBodyClass · 0.90
CT_CommonSlideDataClass · 0.90
CT_NotesMasterClass · 0.90
CT_NotesSlideClass · 0.90
CT_SlideClass · 0.90
CT_SlideLayoutClass · 0.90
CT_SlideMasterClass · 0.90
CT_TLMediaNodeVideoClass · 0.90
CT_TableClass · 0.90
CT_DPtClass · 0.90
CT_NumDataSourceClass · 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…