MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / _add_relationship_for_people

Method _add_relationship_for_people

docx/scripts/document.py:972–986  ·  view source on GitHub ↗

Add people.xml relationship to document.xml.rels if not already present.

(self, path)

Source from the content-addressed store, hash-verified

970 editor.append_to(root, override_xml)
971
972 def _add_relationship_for_people(self, path):
973 """Add people.xml relationship to document.xml.rels if not already present."""
974 editor = self["word/_rels/document.xml.rels"]
975
976 if self._has_relationship(editor, "people.xml"):
977 return
978
979 root = editor.dom.documentElement
980 root_tag = root.tagName # type: ignore
981 prefix = root_tag.split(":")[0] + ":" if ":" in root_tag else ""
982 next_rid = editor.get_next_rid()
983
984 # Create the relationship entry
985 rel_xml = f'<{prefix}Relationship Id="{next_rid}" Type="http://schemas.microsoft.com/office/2011/relationships/people" Target="people.xml"/>'
986 editor.append_to(root, rel_xml)
987
988 def _update_settings(self, path, track_revisions=False):
989 """Add RSID and optionally enable track revisions in settings.xml.

Callers 1

_setup_trackingMethod · 0.95

Calls 3

_has_relationshipMethod · 0.95
get_next_ridMethod · 0.80
append_toMethod · 0.45

Tested by

no test coverage detected