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

Method get_or_add

src/docx/opc/rel.py:31–38  ·  view source on GitHub ↗

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

(self, reltype: str, target_part: Part)

Source from the content-addressed store, hash-verified

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
33 present in collection."""
34 rel = self._get_matching(reltype, target_part)
35 if rel is None:
36 rId = self._next_rId
37 rel = self.add_relationship(reltype, target_part, rId)
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

Callers 3

relate_toMethod · 0.80
relate_toMethod · 0.80

Calls 2

_get_matchingMethod · 0.95
add_relationshipMethod · 0.95

Tested by 1