MCPcopy Index your code
hub / github.com/python-openxml/python-docx / add_relationship

Method add_relationship

src/docx/opc/rel.py:21–29  ·  view source on GitHub ↗

Return a newly added |_Relationship| instance.

(
        self, reltype: str, target: Part | str, rId: str, is_external: bool = False
    )

Source from the content-addressed store, hash-verified

19 self._target_parts_by_rId: dict[str, Any] = {}
20
21 def add_relationship(
22 self, reltype: str, target: Part | str, rId: str, is_external: bool = False
23 ) -> "_Relationship":
24 """Return a newly added |_Relationship| instance."""
25 rel = _Relationship(rId, reltype, target, self._baseURI, is_external)
26 self[rId] = rel
27 if not is_external:
28 self._target_parts_by_rId[rId] = target
29 return rel
30
31 def get_or_add(self, reltype: str, target_part: Part) -> _Relationship:
32 """Return relationship of `reltype` to `target_part`, newly added if not already

Callers 8

get_or_addMethod · 0.95
get_or_add_ext_relMethod · 0.95
relsMethod · 0.95
load_relMethod · 0.80
load_relMethod · 0.80

Calls 1

_RelationshipClass · 0.85

Tested by 4

relsMethod · 0.76