Paper Office
paper-docxAPI referenceopc.rel

Relationships

paper-docx 0.2.0 API reference

Collection object for _Relationship instances, having list semantics.

Relationships(baseURI: str)

Attributes

attributerelated_parts

Dict mapping rIds to target parts for all the internal relationships in the collection.

xml

attributexmlstr

Serialize this relationship collection into XML suitable for storage as a .rels file in an OPC package.

Functions

__delitem__

func__delitem__(rId: str) -> None

Remove rId from both relationship indexes.

paramrIdstr

Returns

None

add_relationship

funcadd_relationship(reltype: str, target: Part | str, rId: str, is_external: bool = False) -> '_Relationship'

Return a newly added _Relationship instance.

paramreltypestr
paramtargetPart | str
paramrIdstr
paramis_externalbool
= False

Returns

'_Relationship'

get_or_add

funcget_or_add(reltype: str, target_part: Part) -> _Relationship

Return relationship of reltype to target_part, newly added if not already present in collection.

paramreltypestr
paramtarget_partPart

Returns

docx.opc.rel._Relationship

get_or_add_ext_rel

funcget_or_add_ext_rel(reltype: str, target_ref: str) -> str

Return rId of external relationship of reltype to target_ref, newly added if not already present in collection.

paramreltypestr
paramtarget_refstr

Returns

str

part_with_reltype

funcpart_with_reltype(reltype: str) -> Part

Return target part of rel with matching reltype, raising KeyError if not found and ValueError if more than one matching relationship is found.

paramreltypestr

Returns

docx.opc.part.Part

On this page