MCPcopy
hub / github.com/anthropics/skills / _append_xml

Function _append_xml

skills/docx/scripts/comment.py:86–95  ·  view source on GitHub ↗
(xml_path: Path, root_tag: str, content: str)

Source from the content-addressed store, hash-verified

84
85
86def _append_xml(xml_path: Path, root_tag: str, content: str) -> None:
87 dom = defusedxml.minidom.parseString(xml_path.read_text(encoding="utf-8"))
88 root = dom.getElementsByTagName(root_tag)[0]
89 ns_attrs = " ".join(f'xmlns:{k}="{v}"' for k, v in NS.items())
90 wrapper_dom = defusedxml.minidom.parseString(f"<root {ns_attrs}>{content}</root>")
91 for child in wrapper_dom.documentElement.childNodes:
92 if child.nodeType == child.ELEMENT_NODE:
93 root.appendChild(dom.importNode(child, True))
94 output = _encode_smart_quotes(dom.toxml(encoding="UTF-8").decode("utf-8"))
95 xml_path.write_text(output, encoding="utf-8")
96
97
98def _find_para_id(comments_path: Path, comment_id: int) -> str | None:

Callers 1

add_commentFunction · 0.85

Calls 1

_encode_smart_quotesFunction · 0.85

Tested by

no test coverage detected