MCPcopy
hub / github.com/python-openxml/python-docx / register_element_cls

Function register_element_cls

src/docx/oxml/parser.py:32–41  ·  view source on GitHub ↗

Register an lxml custom element-class to use for `tag`. A instance of `cls` to be constructed when the oxml parser encounters an element with matching `tag`. `tag` is a string of the form `nspfx:tagroot`, e.g. `'w:document'`.

(tag: str, cls: Type["BaseOxmlElement"])

Source from the content-addressed store, hash-verified

30
31
32def register_element_cls(tag: str, cls: Type["BaseOxmlElement"]):
33 """Register an lxml custom element-class to use for `tag`.
34
35 A instance of `cls` to be constructed when the oxml parser encounters an element
36 with matching `tag`. `tag` is a string of the form `nspfx:tagroot`, e.g.
37 `'w:document'`.
38 """
39 nspfx, tagroot = tag.split(":")
40 namespace = element_class_lookup.get_namespace(nsmap[nspfx])
41 namespace[tagroot] = cls
42
43
44def OxmlElement(

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…