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

Method get_or_add_ext_rel

src/docx/opc/rel.py:40–47  ·  view source on GitHub ↗

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

(self, reltype: str, target_ref: str)

Source from the content-addressed store, hash-verified

38 return rel
39
40 def get_or_add_ext_rel(self, reltype: str, target_ref: str) -> str:
41 """Return rId of external relationship of `reltype` to `target_ref`, newly added
42 if not already present in collection."""
43 rel = self._get_matching(reltype, target_ref, is_external=True)
44 if rel is None:
45 rId = self._next_rId
46 rel = self.add_relationship(reltype, target_ref, rId, is_external=True)
47 return rel.rId
48
49 def part_with_reltype(self, reltype: str) -> Part:
50 """Return target part of rel with matching `reltype`, raising |KeyError| if not

Calls 2

_get_matchingMethod · 0.95
add_relationshipMethod · 0.95