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

Method relate_to

src/docx/opc/package.py:144–151  ·  view source on GitHub ↗

Return rId key of new or existing relationship to `part`. If a relationship of `reltype` to `part` already exists, its rId is returned. Otherwise a new relationship is created and that rId is returned.

(self, part: Part, reltype: str)

Source from the content-addressed store, hash-verified

142 return list(self.iter_parts())
143
144 def relate_to(self, part: Part, reltype: str):
145 """Return rId key of new or existing relationship to `part`.
146
147 If a relationship of `reltype` to `part` already exists, its rId is returned. Otherwise a
148 new relationship is created and that rId is returned.
149 """
150 rel = self.rels.get_or_add(reltype, part)
151 return rel.rId
152
153 @lazyproperty
154 def rels(self):

Calls 1

get_or_addMethod · 0.80