_Relationships
paper-pptx 0.2.0 API reference
Collection of _Relationship instances having dict semantics.
Relationships are keyed by their rId, but may also be found in other ways, such as by their
relationship type. Relationship objects are keyed by their rId.
Iterating this collection has normal mapping semantics, generating the keys (rIds) of the
mapping. rels.keys(), rels.values(), and rels.items() can be used as they would be for a dict`.
_Relationships(base_uri: str)Attributes
xml
attributexmlbytes XML serialization of this relationship collection.
This value is suitable for storage as a .rels file in an OPC package. Includes a <?xml..
declaration header with encoding as UTF-8.
Functions
__contains__
func__contains__(rId: object) -> boolImplement 'in' operation, like "rId7" in relationships.
paramrIdobjectReturns
bool__getitem__
func__getitem__(rId: str) -> _RelationshipImplement relationship lookup by rId using indexed access, like rels[rId].
paramrIdstrReturns
pptx.opc.package._Relationship__iter__
func__iter__() -> Iterator[str]Implement iteration of rIds (iterating a mapping produces its keys).
Returns
typing.Iterator[str]__len__
func__len__() -> intReturn count of relationships in collection.
Returns
intget_or_add
funcget_or_add(reltype: str, target_part: Part) -> strReturn str rId of reltype to target_part.
The rId of an existing matching relationship is used if present. Otherwise, a new relationship is added and that rId is returned.
paramreltypestrparamtarget_partPartReturns
strget_or_add_ext_rel
funcget_or_add_ext_rel(reltype: str, target_ref: str) -> strReturn str rId of external relationship of reltype to target_ref.
The rId of an existing matching relationship is used if present. Otherwise, a new relationship is added and that rId is returned.
paramreltypestrparamtarget_refstrReturns
strload_from_xml
funcload_from_xml(base_uri: str, xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> NoneReplace any relationships in this collection with those from xml_rels.
parambase_uristrparamxml_relsCT_Relationshipsparampartsdict[PackURI, Part]Returns
Nonepart_with_reltype
funcpart_with_reltype(reltype: str) -> PartReturn target part of relationship with matching reltype.
Raises KeyError if not found and ValueError if more than one matching relationship is
found.
paramreltypestrReturns
pptx.opc.package.Partpop
funcpop(rId: str) -> _RelationshipReturn _Relationship identified by rId after removing it from collection.
The caller is responsible for ensuring it is no longer required.
paramrIdstrReturns
pptx.opc.package._Relationship