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

Method _add_author_to_people

docx/scripts/document.py:1181–1201  ·  view source on GitHub ↗

Add author to people.xml (called during initialization).

(self, author)

Source from the content-addressed store, hash-verified

1179 return False
1180
1181 def _add_author_to_people(self, author):
1182 """Add author to people.xml (called during initialization)."""
1183 people_path = self.word_path / "people.xml"
1184
1185 # people.xml should already exist from _setup_tracking
1186 if not people_path.exists():
1187 raise ValueError("people.xml should exist after _setup_tracking")
1188
1189 editor = self["word/people.xml"]
1190 root = editor.get_node(tag="w15:people")
1191
1192 # Check if author already exists
1193 if self._has_author(editor, author):
1194 return
1195
1196 # Add author with proper XML escaping to prevent injection
1197 escaped_author = html.escape(author, quote=True)
1198 person_xml = f''&#x27;<w15:person w15:author="{escaped_author}">
1199 <w15:presenceInfo w15:providerId="None" w15:userId="{escaped_author}"/>
1200</w15:person>''&#x27;
1201 editor.append_to(root, person_xml)
1202
1203 def _ensure_comment_relationships(self):
1204 """Ensure word/_rels/document.xml.rels has comment relationships."""

Callers 1

__init__Method · 0.95

Calls 3

_has_authorMethod · 0.95
get_nodeMethod · 0.80
append_toMethod · 0.45

Tested by

no test coverage detected