/
public-api.pxi
157 lines (114 loc) · 5.64 KB
/
public-api.pxi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Public C API for lxml.etree
cdef public api _Element deepcopyNodeToDocument(_Document doc, xmlNode* c_root):
u"Recursively copy the element into the document. doc is not modified."
cdef xmlNode* c_node
c_node = _copyNodeToDoc(c_root, doc._c_doc)
return _elementFactory(doc, c_node)
cdef public api _ElementTree elementTreeFactory(_Element context_node):
return newElementTree(context_node, _ElementTree)
cdef public api _ElementTree newElementTree(_Element context_node,
object subclass):
if <void*>context_node is NULL or context_node is None:
raise TypeError
return _newElementTree(context_node._doc, context_node, subclass)
cdef public api _Element elementFactory(_Document doc, xmlNode* c_node):
if c_node is NULL or doc is None:
raise TypeError
return _elementFactory(doc, c_node)
cdef public api _Element makeElement(tag, _Document doc, parser,
text, tail, attrib, nsmap):
return _makeElement(tag, NULL, doc, parser, text, tail, attrib, nsmap, None)
cdef public api _Element makeSubElement(_Element parent, tag, text, tail,
attrib, nsmap):
return _makeSubElement(parent, tag, text, tail, attrib, nsmap, None)
cdef public api void setElementClassLookupFunction(
_element_class_lookup_function function, state):
_setElementClassLookupFunction(function, state)
cdef public api object lookupDefaultElementClass(state, doc, xmlNode* c_node):
return _lookupDefaultElementClass(state, doc, c_node)
cdef public api object lookupNamespaceElementClass(state, doc, xmlNode* c_node):
return _find_nselement_class(state, doc, c_node)
cdef public api object callLookupFallback(FallbackElementClassLookup lookup,
_Document doc, xmlNode* c_node):
return _callLookupFallback(lookup, doc, c_node)
cdef public api int tagMatches(xmlNode* c_node, char* c_href, char* c_name):
if c_node is NULL:
return -1
return _tagMatches(c_node, c_href, c_name)
cdef public api _Document documentOrRaise(object input):
return _documentOrRaise(input)
cdef public api _Element rootNodeOrRaise(object input):
return _rootNodeOrRaise(input)
cdef public api bint hasText(xmlNode* c_node):
return _hasText(c_node)
cdef public api bint hasTail(xmlNode* c_node):
return _hasTail(c_node)
cdef public api object textOf(xmlNode* c_node):
if c_node is NULL:
return None
return _collectText(c_node.children)
cdef public api object tailOf(xmlNode* c_node):
if c_node is NULL:
return None
return _collectText(c_node.next)
cdef public api int setNodeText(xmlNode* c_node, text) except -1:
if c_node is NULL:
raise ValueError
return _setNodeText(c_node, text)
cdef public api int setTailText(xmlNode* c_node, text) except -1:
if c_node is NULL:
raise ValueError
return _setTailText(c_node, text)
cdef public api object attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):
return _attributeValue(c_element, c_attrib_node)
cdef public api object attributeValueFromNsName(xmlNode* c_element,
char* ns, char* name):
return _attributeValueFromNsName(c_element, ns, name)
cdef public api object getAttributeValue(_Element element, key, default):
return _getAttributeValue(element, key, default)
cdef public api object iterattributes(_Element element, int keysvalues):
return _attributeIteratorFactory(element, keysvalues)
cdef public api object collectAttributes(xmlNode* c_element, int keysvalues):
return _collectAttributes(c_element, keysvalues)
cdef public api int setAttributeValue(_Element element, key, value) except -1:
return _setAttributeValue(element, key, value)
cdef public api int delAttribute(_Element element, key) except -1:
return _delAttribute(element, key)
cdef public api int delAttributeFromNsName(tree.xmlNode* c_element,
char* c_href, char* c_name):
return _delAttributeFromNsName(c_element, c_href, c_name)
cdef public api bint hasChild(xmlNode* c_node):
return _hasChild(c_node)
cdef public api xmlNode* findChild(xmlNode* c_node, Py_ssize_t index):
return _findChild(c_node, index)
cdef public api xmlNode* findChildForwards(xmlNode* c_node, Py_ssize_t index):
return _findChildForwards(c_node, index)
cdef public api xmlNode* findChildBackwards(xmlNode* c_node, Py_ssize_t index):
return _findChildBackwards(c_node, index)
cdef public api xmlNode* nextElement(xmlNode* c_node):
return _nextElement(c_node)
cdef public api xmlNode* previousElement(xmlNode* c_node):
return _previousElement(c_node)
cdef public api void appendChild(_Element parent, _Element child):
_appendChild(parent, child)
cdef public api object pyunicode(char* s):
if s is NULL:
raise TypeError
return funicode(s)
cdef public api object utf8(object s):
return _utf8(s)
cdef public api object getNsTag(object tag):
return _getNsTag(tag)
cdef public api object namespacedName(xmlNode* c_node):
return _namespacedName(c_node)
cdef public api object namespacedNameFromNsName(char* href, char* name):
return _namespacedNameFromNsName(href, name)
cdef public api void iteratorStoreNext(_ElementIterator iterator, _Element node):
iterator._storeNext(node)
cdef public api void initTagMatch(_ElementTagMatcher matcher, tag):
matcher._initTagMatch(tag)
cdef public api tree.xmlNs* findOrBuildNodeNsPrefix(
_Document doc, xmlNode* c_node, char* href, char* prefix) except NULL:
if doc is None:
raise TypeError
return doc._findOrBuildNodeNs(c_node, href, prefix)