Relationships
paper-docx 0.2.0 API reference
Collection object for _Relationship instances, having list semantics.
Relationships(baseURI: str)Attributes
related_parts
attributerelated_partsDict mapping rIds to target parts for all the internal relationships in the collection.
xml
attributexmlstrSerialize this relationship collection into XML suitable for storage as a .rels file in an OPC package.
Functions
__delitem__
func__delitem__(rId: str) -> NoneRemove rId from both relationship indexes.
paramrIdstrReturns
Noneadd_relationship
funcadd_relationship(reltype: str, target: Part | str, rId: str, is_external: bool = False) -> '_Relationship'Return a newly added _Relationship instance.
paramreltypestrparamtargetPart | strparamrIdstrparamis_externalbool= FalseReturns
'_Relationship'get_or_add
funcget_or_add(reltype: str, target_part: Part) -> _RelationshipReturn relationship of reltype to target_part, newly added if not already
present in collection.
paramreltypestrparamtarget_partPartReturns
docx.opc.rel._Relationshipget_or_add_ext_rel
funcget_or_add_ext_rel(reltype: str, target_ref: str) -> strReturn rId of external relationship of reltype to target_ref, newly added
if not already present in collection.
paramreltypestrparamtarget_refstrReturns
strpart_with_reltype
funcpart_with_reltype(reltype: str) -> PartReturn target part of rel with matching reltype, raising KeyError if not
found and ValueError if more than one matching relationship is found.
paramreltypestrReturns
docx.opc.part.Part