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

Method relate_to

src/docx/opc/part.py:126–136  ·  view source on GitHub ↗

Return rId key of relationship of `reltype` to `target`. The returned `rId` is from an existing relationship if there is one, otherwise a new relationship is created.

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

Source from the content-addressed store, hash-verified

124 return self.rels.part_with_reltype(reltype)
125
126 def relate_to(self, target: Part | str, reltype: str, is_external: bool = False) -> str:
127 """Return rId key of relationship of `reltype` to `target`.
128
129 The returned `rId` is from an existing relationship if there is one, otherwise a
130 new relationship is created.
131 """
132 if is_external:
133 return self.rels.get_or_add_ext_rel(reltype, cast(str, target))
134 else:
135 rel = self.rels.get_or_add(reltype, cast(Part, target))
136 return rel.rId
137
138 @property
139 def related_parts(self):

Callers 9

get_or_add_imageMethod · 0.45
add_footer_partMethod · 0.45
add_header_partMethod · 0.45
numbering_partMethod · 0.45
_comments_partMethod · 0.45
_settings_partMethod · 0.45
_styles_partMethod · 0.45

Calls 2

get_or_add_ext_relMethod · 0.80
get_or_addMethod · 0.80