lxml 5.2.0__cp310-cp310-win32.whl → 5.2.2__cp310-cp310-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. lxml/ElementInclude.py +244 -244
  2. lxml/__init__.py +22 -22
  3. lxml/_elementpath.cp310-win32.pyd +0 -0
  4. lxml/_elementpath.py +341 -341
  5. lxml/apihelpers.pxi +1793 -1793
  6. lxml/builder.cp310-win32.pyd +0 -0
  7. lxml/builder.py +232 -232
  8. lxml/classlookup.pxi +580 -580
  9. lxml/cleanup.pxi +215 -215
  10. lxml/cssselect.py +101 -101
  11. lxml/debug.pxi +90 -90
  12. lxml/docloader.pxi +178 -178
  13. lxml/doctestcompare.py +488 -488
  14. lxml/dtd.pxi +478 -478
  15. lxml/etree.cp310-win32.pyd +0 -0
  16. lxml/etree.h +6 -6
  17. lxml/etree.pyx +3732 -3711
  18. lxml/extensions.pxi +833 -833
  19. lxml/html/ElementSoup.py +10 -10
  20. lxml/html/__init__.py +1923 -1923
  21. lxml/html/_diffcommand.py +86 -86
  22. lxml/html/_html5builder.py +100 -100
  23. lxml/html/_setmixin.py +56 -56
  24. lxml/html/builder.py +133 -133
  25. lxml/html/clean.py +21 -21
  26. lxml/html/defs.py +135 -135
  27. lxml/html/diff.cp310-win32.pyd +0 -0
  28. lxml/html/diff.py +878 -878
  29. lxml/html/formfill.py +299 -299
  30. lxml/html/html5parser.py +260 -260
  31. lxml/html/soupparser.py +314 -314
  32. lxml/html/usedoctest.py +13 -13
  33. lxml/includes/c14n.pxd +25 -25
  34. lxml/includes/config.pxd +3 -3
  35. lxml/includes/dtdvalid.pxd +18 -18
  36. lxml/includes/etree_defs.h +379 -379
  37. lxml/includes/etreepublic.pxd +237 -237
  38. lxml/includes/htmlparser.pxd +56 -56
  39. lxml/includes/lxml-version.h +1 -1
  40. lxml/includes/relaxng.pxd +64 -64
  41. lxml/includes/schematron.pxd +34 -34
  42. lxml/includes/tree.pxd +494 -494
  43. lxml/includes/uri.pxd +5 -5
  44. lxml/includes/xinclude.pxd +22 -22
  45. lxml/includes/xmlerror.pxd +852 -852
  46. lxml/includes/xmlparser.pxd +265 -265
  47. lxml/includes/xmlschema.pxd +35 -35
  48. lxml/includes/xpath.pxd +136 -136
  49. lxml/includes/xslt.pxd +190 -190
  50. lxml/isoschematron/__init__.py +348 -348
  51. lxml/isoschematron/resources/rng/iso-schematron.rng +709 -709
  52. lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl +75 -75
  53. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl +312 -312
  54. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl +1159 -1159
  55. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl +54 -54
  56. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1796 -1796
  57. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +588 -588
  58. lxml/iterparse.pxi +438 -438
  59. lxml/lxml.etree.h +6 -6
  60. lxml/nsclasses.pxi +281 -281
  61. lxml/objectify.cp310-win32.pyd +0 -0
  62. lxml/objectify.pyx +2145 -2145
  63. lxml/objectpath.pxi +332 -332
  64. lxml/parser.pxi +1994 -1994
  65. lxml/parsertarget.pxi +180 -180
  66. lxml/proxy.pxi +619 -619
  67. lxml/public-api.pxi +178 -178
  68. lxml/pyclasslookup.py +3 -3
  69. lxml/readonlytree.pxi +565 -565
  70. lxml/relaxng.pxi +165 -165
  71. lxml/sax.cp310-win32.pyd +0 -0
  72. lxml/sax.py +275 -275
  73. lxml/saxparser.pxi +875 -875
  74. lxml/schematron.pxi +168 -168
  75. lxml/serializer.pxi +1871 -1871
  76. lxml/usedoctest.py +13 -13
  77. lxml/xinclude.pxi +67 -67
  78. lxml/xmlerror.pxi +1654 -1654
  79. lxml/xmlid.pxi +179 -179
  80. lxml/xmlschema.pxi +215 -215
  81. lxml/xpath.pxi +487 -487
  82. lxml/xslt.pxi +950 -950
  83. lxml/xsltext.pxi +242 -242
  84. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSE.txt +29 -29
  85. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSES.txt +29 -29
  86. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/METADATA +9 -17
  87. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/RECORD +89 -89
  88. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/WHEEL +0 -0
  89. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/top_level.txt +0 -0
@@ -1,237 +1,237 @@
1
- # public Cython/C interface to lxml.etree
2
-
3
- from lxml.includes cimport tree
4
- from lxml.includes.tree cimport const_xmlChar
5
-
6
- cdef extern from "lxml-version.h":
7
- cdef char* LXML_VERSION_STRING
8
-
9
- cdef extern from "etree_defs.h":
10
- # test if c_node is considered an Element (i.e. Element, Comment, etc.)
11
- cdef bint _isElement(tree.xmlNode* c_node) noexcept nogil
12
-
13
- # return the namespace URI of the node or NULL
14
- cdef const_xmlChar* _getNs(tree.xmlNode* node) noexcept nogil
15
-
16
- # pair of macros for tree traversal
17
- cdef void BEGIN_FOR_EACH_ELEMENT_FROM(tree.xmlNode* tree_top,
18
- tree.xmlNode* start_node,
19
- int start_node_inclusive) noexcept nogil
20
- cdef void END_FOR_EACH_ELEMENT_FROM(tree.xmlNode* start_node) noexcept nogil
21
-
22
- cdef extern from "etree_api.h":
23
-
24
- # first function to call!
25
- cdef int import_lxml__etree() except -1
26
-
27
- ##########################################################################
28
- # public ElementTree API classes
29
-
30
- cdef class lxml.etree._Document [ object LxmlDocument ]:
31
- cdef tree.xmlDoc* _c_doc
32
-
33
- cdef class lxml.etree._Element [ object LxmlElement ]:
34
- cdef _Document _doc
35
- cdef tree.xmlNode* _c_node
36
-
37
- cdef class lxml.etree.ElementBase(_Element) [ object LxmlElementBase ]:
38
- pass
39
-
40
- cdef class lxml.etree._ElementTree [ object LxmlElementTree ]:
41
- cdef _Document _doc
42
- cdef _Element _context_node
43
-
44
- cdef class lxml.etree.ElementClassLookup [ object LxmlElementClassLookup ]:
45
- cdef object (*_lookup_function)(object, _Document, tree.xmlNode*)
46
-
47
- cdef class lxml.etree.FallbackElementClassLookup(ElementClassLookup) \
48
- [ object LxmlFallbackElementClassLookup ]:
49
- cdef ElementClassLookup fallback
50
- cdef object (*_fallback_function)(object, _Document, tree.xmlNode*)
51
-
52
- ##########################################################################
53
- # creating Element objects
54
-
55
- # create an Element for a C-node in the Document
56
- cdef _Element elementFactory(_Document doc, tree.xmlNode* c_node)
57
-
58
- # create an ElementTree for an Element
59
- cdef _ElementTree elementTreeFactory(_Element context_node)
60
-
61
- # create an ElementTree subclass for an Element
62
- cdef _ElementTree newElementTree(_Element context_node, object subclass)
63
-
64
- # create an ElementTree from an external document
65
- cdef _ElementTree adoptExternalDocument(tree.xmlDoc* c_doc, parser, bint is_owned)
66
-
67
- # create a new Element for an existing or new document (doc = None)
68
- # builds Python object after setting text, tail, namespaces and attributes
69
- cdef _Element makeElement(tag, _Document doc, parser,
70
- text, tail, attrib, nsmap)
71
-
72
- # create a new SubElement for an existing parent
73
- # builds Python object after setting text, tail, namespaces and attributes
74
- cdef _Element makeSubElement(_Element parent, tag, text, tail,
75
- attrib, nsmap)
76
-
77
- # deep copy a node to include it in the Document
78
- cdef _Element deepcopyNodeToDocument(_Document doc, tree.xmlNode* c_root)
79
-
80
- # set the internal lookup function for Element/Comment/PI classes
81
- # use setElementClassLookupFunction(NULL, None) to reset it
82
- # note that the lookup function *must always* return an _Element subclass!
83
- cdef void setElementClassLookupFunction(
84
- object (*function)(object, _Document, tree.xmlNode*), object state)
85
-
86
- # lookup function that always returns the default Element class
87
- # note that the first argument is expected to be None!
88
- cdef object lookupDefaultElementClass(_1, _Document _2,
89
- tree.xmlNode* c_node)
90
-
91
- # lookup function for namespace/tag specific Element classes
92
- # note that the first argument is expected to be None!
93
- cdef object lookupNamespaceElementClass(_1, _Document _2,
94
- tree.xmlNode* c_node)
95
-
96
- # call the fallback lookup function of a FallbackElementClassLookup
97
- cdef object callLookupFallback(FallbackElementClassLookup lookup,
98
- _Document doc, tree.xmlNode* c_node)
99
-
100
- ##########################################################################
101
- # XML attribute access
102
-
103
- # return an attribute value for a C attribute on a C element node
104
- cdef unicode attributeValue(tree.xmlNode* c_element,
105
- tree.xmlAttr* c_attrib_node)
106
-
107
- # return the value of the attribute with 'ns' and 'name' (or None)
108
- cdef unicode attributeValueFromNsName(tree.xmlNode* c_element,
109
- const_xmlChar* c_ns, const_xmlChar* c_name)
110
-
111
- # return the value of attribute "{ns}name", or the default value
112
- cdef object getAttributeValue(_Element element, key, default)
113
-
114
- # return an iterator over attribute names (1), values (2) or items (3)
115
- # attributes must not be removed during iteration!
116
- cdef object iterattributes(_Element element, int keysvalues)
117
-
118
- # return the list of all attribute names (1), values (2) or items (3)
119
- cdef list collectAttributes(tree.xmlNode* c_element, int keysvalues)
120
-
121
- # set an attribute value on an element
122
- # on failure, sets an exception and returns -1
123
- cdef int setAttributeValue(_Element element, key, value) except -1
124
-
125
- # delete an attribute
126
- # on failure, sets an exception and returns -1
127
- cdef int delAttribute(_Element element, key) except -1
128
-
129
- # delete an attribute based on name and namespace URI
130
- # returns -1 if the attribute was not found (no exception)
131
- cdef int delAttributeFromNsName(tree.xmlNode* c_element,
132
- const_xmlChar* c_href, const_xmlChar* c_name) noexcept
133
-
134
- ##########################################################################
135
- # XML node helper functions
136
-
137
- # check if the element has at least one child
138
- cdef bint hasChild(tree.xmlNode* c_node) noexcept nogil
139
-
140
- # find child element number 'index' (supports negative indexes)
141
- cdef tree.xmlNode* findChild(tree.xmlNode* c_node,
142
- Py_ssize_t index) noexcept nogil
143
-
144
- # find child element number 'index' starting at first one
145
- cdef tree.xmlNode* findChildForwards(tree.xmlNode* c_node,
146
- Py_ssize_t index) nogil
147
-
148
- # find child element number 'index' starting at last one
149
- cdef tree.xmlNode* findChildBackwards(tree.xmlNode* c_node,
150
- Py_ssize_t index) nogil
151
-
152
- # return next/previous sibling element of the node
153
- cdef tree.xmlNode* nextElement(tree.xmlNode* c_node) nogil
154
- cdef tree.xmlNode* previousElement(tree.xmlNode* c_node) nogil
155
-
156
- ##########################################################################
157
- # iterators (DEPRECATED API, don't use in new code!)
158
-
159
- cdef class lxml.etree._ElementTagMatcher [ object LxmlElementTagMatcher ]:
160
- cdef char* _href
161
- cdef char* _name
162
-
163
- # store "{ns}tag" (or None) filter for this matcher or element iterator
164
- # ** unless _href *and* _name are set up 'by hand', this function *must*
165
- # ** be called when subclassing the iterator below!
166
- cdef void initTagMatch(_ElementTagMatcher matcher, tag)
167
-
168
- cdef class lxml.etree._ElementIterator(_ElementTagMatcher) [
169
- object LxmlElementIterator ]:
170
- cdef _Element _node
171
- cdef tree.xmlNode* (*_next_element)(tree.xmlNode*)
172
-
173
- # store the initial node of the iterator if it matches the required tag
174
- # or its next matching sibling if not
175
- cdef void iteratorStoreNext(_ElementIterator iterator, _Element node)
176
-
177
- ##########################################################################
178
- # other helper functions
179
-
180
- # check if a C node matches a tag name and namespace
181
- # (NULL allowed for each => always matches)
182
- cdef int tagMatches(tree.xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name)
183
-
184
- # convert a UTF-8 char* to a Python unicode string
185
- cdef unicode pyunicode(const_xmlChar* s)
186
-
187
- # convert the string to UTF-8 using the normal lxml.etree semantics
188
- cdef bytes utf8(object s)
189
-
190
- # split a tag into a (URI, name) tuple, return None as URI for '{}tag'
191
- cdef tuple getNsTag(object tag)
192
-
193
- # split a tag into a (URI, name) tuple, return b'' as URI for '{}tag'
194
- cdef tuple getNsTagWithEmptyNs(object tag)
195
-
196
- # get the "{ns}tag" string for a C node
197
- cdef unicode namespacedName(tree.xmlNode* c_node)
198
-
199
- # get the "{ns}tag" string for a href/tagname pair (c_ns may be NULL)
200
- cdef unicode namespacedNameFromNsName(const_xmlChar* c_ns, const_xmlChar* c_tag)
201
-
202
- # check if the node has a text value (which may be '')
203
- cdef bint hasText(tree.xmlNode* c_node) nogil
204
-
205
- # check if the node has a tail value (which may be '')
206
- cdef bint hasTail(tree.xmlNode* c_node) nogil
207
-
208
- # get the text content of an element (or None)
209
- cdef unicode textOf(tree.xmlNode* c_node)
210
-
211
- # get the tail content of an element (or None)
212
- cdef unicode tailOf(tree.xmlNode* c_node)
213
-
214
- # set the text value of an element
215
- cdef int setNodeText(tree.xmlNode* c_node, text) except -1
216
-
217
- # set the tail text value of an element
218
- cdef int setTailText(tree.xmlNode* c_node, text) except -1
219
-
220
- # append an element to the children of a parent element
221
- # deprecated: don't use, does not propagate exceptions!
222
- # use appendChildToElement() instead
223
- cdef void appendChild(_Element parent, _Element child)
224
-
225
- # added in lxml 3.3 as a safe replacement for appendChild()
226
- # return -1 for exception, 0 for ok
227
- cdef int appendChildToElement(_Element parent, _Element child) except -1
228
-
229
- # recursively lookup a namespace in element or ancestors, or create it
230
- cdef tree.xmlNs* findOrBuildNodeNsPrefix(
231
- _Document doc, tree.xmlNode* c_node, const_xmlChar* href, const_xmlChar* prefix)
232
-
233
- # find the Document of an Element, ElementTree or Document (itself!)
234
- cdef _Document documentOrRaise(object input)
235
-
236
- # find the root Element of an Element (itself!), ElementTree or Document
237
- cdef _Element rootNodeOrRaise(object input)
1
+ # public Cython/C interface to lxml.etree
2
+
3
+ from lxml.includes cimport tree
4
+ from lxml.includes.tree cimport const_xmlChar
5
+
6
+ cdef extern from "lxml-version.h":
7
+ cdef char* LXML_VERSION_STRING
8
+
9
+ cdef extern from "etree_defs.h":
10
+ # test if c_node is considered an Element (i.e. Element, Comment, etc.)
11
+ cdef bint _isElement(tree.xmlNode* c_node) noexcept nogil
12
+
13
+ # return the namespace URI of the node or NULL
14
+ cdef const_xmlChar* _getNs(tree.xmlNode* node) noexcept nogil
15
+
16
+ # pair of macros for tree traversal
17
+ cdef void BEGIN_FOR_EACH_ELEMENT_FROM(tree.xmlNode* tree_top,
18
+ tree.xmlNode* start_node,
19
+ int start_node_inclusive) noexcept nogil
20
+ cdef void END_FOR_EACH_ELEMENT_FROM(tree.xmlNode* start_node) noexcept nogil
21
+
22
+ cdef extern from "etree_api.h":
23
+
24
+ # first function to call!
25
+ cdef int import_lxml__etree() except -1
26
+
27
+ ##########################################################################
28
+ # public ElementTree API classes
29
+
30
+ cdef class lxml.etree._Document [ object LxmlDocument ]:
31
+ cdef tree.xmlDoc* _c_doc
32
+
33
+ cdef class lxml.etree._Element [ object LxmlElement ]:
34
+ cdef _Document _doc
35
+ cdef tree.xmlNode* _c_node
36
+
37
+ cdef class lxml.etree.ElementBase(_Element) [ object LxmlElementBase ]:
38
+ pass
39
+
40
+ cdef class lxml.etree._ElementTree [ object LxmlElementTree ]:
41
+ cdef _Document _doc
42
+ cdef _Element _context_node
43
+
44
+ cdef class lxml.etree.ElementClassLookup [ object LxmlElementClassLookup ]:
45
+ cdef object (*_lookup_function)(object, _Document, tree.xmlNode*)
46
+
47
+ cdef class lxml.etree.FallbackElementClassLookup(ElementClassLookup) \
48
+ [ object LxmlFallbackElementClassLookup ]:
49
+ cdef ElementClassLookup fallback
50
+ cdef object (*_fallback_function)(object, _Document, tree.xmlNode*)
51
+
52
+ ##########################################################################
53
+ # creating Element objects
54
+
55
+ # create an Element for a C-node in the Document
56
+ cdef _Element elementFactory(_Document doc, tree.xmlNode* c_node)
57
+
58
+ # create an ElementTree for an Element
59
+ cdef _ElementTree elementTreeFactory(_Element context_node)
60
+
61
+ # create an ElementTree subclass for an Element
62
+ cdef _ElementTree newElementTree(_Element context_node, object subclass)
63
+
64
+ # create an ElementTree from an external document
65
+ cdef _ElementTree adoptExternalDocument(tree.xmlDoc* c_doc, parser, bint is_owned)
66
+
67
+ # create a new Element for an existing or new document (doc = None)
68
+ # builds Python object after setting text, tail, namespaces and attributes
69
+ cdef _Element makeElement(tag, _Document doc, parser,
70
+ text, tail, attrib, nsmap)
71
+
72
+ # create a new SubElement for an existing parent
73
+ # builds Python object after setting text, tail, namespaces and attributes
74
+ cdef _Element makeSubElement(_Element parent, tag, text, tail,
75
+ attrib, nsmap)
76
+
77
+ # deep copy a node to include it in the Document
78
+ cdef _Element deepcopyNodeToDocument(_Document doc, tree.xmlNode* c_root)
79
+
80
+ # set the internal lookup function for Element/Comment/PI classes
81
+ # use setElementClassLookupFunction(NULL, None) to reset it
82
+ # note that the lookup function *must always* return an _Element subclass!
83
+ cdef void setElementClassLookupFunction(
84
+ object (*function)(object, _Document, tree.xmlNode*), object state)
85
+
86
+ # lookup function that always returns the default Element class
87
+ # note that the first argument is expected to be None!
88
+ cdef object lookupDefaultElementClass(_1, _Document _2,
89
+ tree.xmlNode* c_node)
90
+
91
+ # lookup function for namespace/tag specific Element classes
92
+ # note that the first argument is expected to be None!
93
+ cdef object lookupNamespaceElementClass(_1, _Document _2,
94
+ tree.xmlNode* c_node)
95
+
96
+ # call the fallback lookup function of a FallbackElementClassLookup
97
+ cdef object callLookupFallback(FallbackElementClassLookup lookup,
98
+ _Document doc, tree.xmlNode* c_node)
99
+
100
+ ##########################################################################
101
+ # XML attribute access
102
+
103
+ # return an attribute value for a C attribute on a C element node
104
+ cdef unicode attributeValue(tree.xmlNode* c_element,
105
+ tree.xmlAttr* c_attrib_node)
106
+
107
+ # return the value of the attribute with 'ns' and 'name' (or None)
108
+ cdef unicode attributeValueFromNsName(tree.xmlNode* c_element,
109
+ const_xmlChar* c_ns, const_xmlChar* c_name)
110
+
111
+ # return the value of attribute "{ns}name", or the default value
112
+ cdef object getAttributeValue(_Element element, key, default)
113
+
114
+ # return an iterator over attribute names (1), values (2) or items (3)
115
+ # attributes must not be removed during iteration!
116
+ cdef object iterattributes(_Element element, int keysvalues)
117
+
118
+ # return the list of all attribute names (1), values (2) or items (3)
119
+ cdef list collectAttributes(tree.xmlNode* c_element, int keysvalues)
120
+
121
+ # set an attribute value on an element
122
+ # on failure, sets an exception and returns -1
123
+ cdef int setAttributeValue(_Element element, key, value) except -1
124
+
125
+ # delete an attribute
126
+ # on failure, sets an exception and returns -1
127
+ cdef int delAttribute(_Element element, key) except -1
128
+
129
+ # delete an attribute based on name and namespace URI
130
+ # returns -1 if the attribute was not found (no exception)
131
+ cdef int delAttributeFromNsName(tree.xmlNode* c_element,
132
+ const_xmlChar* c_href, const_xmlChar* c_name) noexcept
133
+
134
+ ##########################################################################
135
+ # XML node helper functions
136
+
137
+ # check if the element has at least one child
138
+ cdef bint hasChild(tree.xmlNode* c_node) noexcept nogil
139
+
140
+ # find child element number 'index' (supports negative indexes)
141
+ cdef tree.xmlNode* findChild(tree.xmlNode* c_node,
142
+ Py_ssize_t index) noexcept nogil
143
+
144
+ # find child element number 'index' starting at first one
145
+ cdef tree.xmlNode* findChildForwards(tree.xmlNode* c_node,
146
+ Py_ssize_t index) nogil
147
+
148
+ # find child element number 'index' starting at last one
149
+ cdef tree.xmlNode* findChildBackwards(tree.xmlNode* c_node,
150
+ Py_ssize_t index) nogil
151
+
152
+ # return next/previous sibling element of the node
153
+ cdef tree.xmlNode* nextElement(tree.xmlNode* c_node) nogil
154
+ cdef tree.xmlNode* previousElement(tree.xmlNode* c_node) nogil
155
+
156
+ ##########################################################################
157
+ # iterators (DEPRECATED API, don't use in new code!)
158
+
159
+ cdef class lxml.etree._ElementTagMatcher [ object LxmlElementTagMatcher ]:
160
+ cdef char* _href
161
+ cdef char* _name
162
+
163
+ # store "{ns}tag" (or None) filter for this matcher or element iterator
164
+ # ** unless _href *and* _name are set up 'by hand', this function *must*
165
+ # ** be called when subclassing the iterator below!
166
+ cdef void initTagMatch(_ElementTagMatcher matcher, tag)
167
+
168
+ cdef class lxml.etree._ElementIterator(_ElementTagMatcher) [
169
+ object LxmlElementIterator ]:
170
+ cdef _Element _node
171
+ cdef tree.xmlNode* (*_next_element)(tree.xmlNode*)
172
+
173
+ # store the initial node of the iterator if it matches the required tag
174
+ # or its next matching sibling if not
175
+ cdef void iteratorStoreNext(_ElementIterator iterator, _Element node)
176
+
177
+ ##########################################################################
178
+ # other helper functions
179
+
180
+ # check if a C node matches a tag name and namespace
181
+ # (NULL allowed for each => always matches)
182
+ cdef int tagMatches(tree.xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name)
183
+
184
+ # convert a UTF-8 char* to a Python unicode string
185
+ cdef unicode pyunicode(const_xmlChar* s)
186
+
187
+ # convert the string to UTF-8 using the normal lxml.etree semantics
188
+ cdef bytes utf8(object s)
189
+
190
+ # split a tag into a (URI, name) tuple, return None as URI for '{}tag'
191
+ cdef tuple getNsTag(object tag)
192
+
193
+ # split a tag into a (URI, name) tuple, return b'' as URI for '{}tag'
194
+ cdef tuple getNsTagWithEmptyNs(object tag)
195
+
196
+ # get the "{ns}tag" string for a C node
197
+ cdef unicode namespacedName(tree.xmlNode* c_node)
198
+
199
+ # get the "{ns}tag" string for a href/tagname pair (c_ns may be NULL)
200
+ cdef unicode namespacedNameFromNsName(const_xmlChar* c_ns, const_xmlChar* c_tag)
201
+
202
+ # check if the node has a text value (which may be '')
203
+ cdef bint hasText(tree.xmlNode* c_node) nogil
204
+
205
+ # check if the node has a tail value (which may be '')
206
+ cdef bint hasTail(tree.xmlNode* c_node) nogil
207
+
208
+ # get the text content of an element (or None)
209
+ cdef unicode textOf(tree.xmlNode* c_node)
210
+
211
+ # get the tail content of an element (or None)
212
+ cdef unicode tailOf(tree.xmlNode* c_node)
213
+
214
+ # set the text value of an element
215
+ cdef int setNodeText(tree.xmlNode* c_node, text) except -1
216
+
217
+ # set the tail text value of an element
218
+ cdef int setTailText(tree.xmlNode* c_node, text) except -1
219
+
220
+ # append an element to the children of a parent element
221
+ # deprecated: don't use, does not propagate exceptions!
222
+ # use appendChildToElement() instead
223
+ cdef void appendChild(_Element parent, _Element child)
224
+
225
+ # added in lxml 3.3 as a safe replacement for appendChild()
226
+ # return -1 for exception, 0 for ok
227
+ cdef int appendChildToElement(_Element parent, _Element child) except -1
228
+
229
+ # recursively lookup a namespace in element or ancestors, or create it
230
+ cdef tree.xmlNs* findOrBuildNodeNsPrefix(
231
+ _Document doc, tree.xmlNode* c_node, const_xmlChar* href, const_xmlChar* prefix)
232
+
233
+ # find the Document of an Element, ElementTree or Document (itself!)
234
+ cdef _Document documentOrRaise(object input)
235
+
236
+ # find the root Element of an Element (itself!), ElementTree or Document
237
+ cdef _Element rootNodeOrRaise(object input)
@@ -1,56 +1,56 @@
1
- from libc.string cimport const_char
2
-
3
- from lxml.includes.tree cimport xmlDoc
4
- from lxml.includes.tree cimport xmlInputReadCallback, xmlInputCloseCallback
5
- from lxml.includes.xmlparser cimport xmlParserCtxt, xmlSAXHandler, xmlSAXHandlerV1
6
-
7
- cdef extern from "libxml/HTMLparser.h" nogil:
8
- ctypedef enum htmlParserOption:
9
- HTML_PARSE_NOERROR # suppress error reports
10
- HTML_PARSE_NOWARNING # suppress warning reports
11
- HTML_PARSE_PEDANTIC # pedantic error reporting
12
- HTML_PARSE_NOBLANKS # remove blank nodes
13
- HTML_PARSE_NONET # Forbid network access
14
- # libxml2 2.6.21+ only:
15
- HTML_PARSE_RECOVER # Relaxed parsing
16
- HTML_PARSE_COMPACT # compact small text nodes
17
- # libxml2 2.7.7+ only:
18
- HTML_PARSE_NOIMPLIED # Do not add implied html/body... elements
19
- # libxml2 2.7.8+ only:
20
- HTML_PARSE_NODEFDTD # do not default a doctype if not found
21
- # libxml2 2.8.0+ only:
22
- XML_PARSE_IGNORE_ENC # ignore internal document encoding hint
23
-
24
- xmlSAXHandlerV1 htmlDefaultSAXHandler
25
-
26
- cdef xmlParserCtxt* htmlCreateMemoryParserCtxt(
27
- char* buffer, int size)
28
- cdef xmlParserCtxt* htmlCreateFileParserCtxt(
29
- char* filename, char* encoding)
30
- cdef xmlParserCtxt* htmlCreatePushParserCtxt(xmlSAXHandler* sax,
31
- void* user_data,
32
- char* chunk, int size,
33
- char* filename, int enc)
34
- cdef void htmlFreeParserCtxt(xmlParserCtxt* ctxt)
35
- cdef void htmlCtxtReset(xmlParserCtxt* ctxt)
36
- cdef int htmlCtxtUseOptions(xmlParserCtxt* ctxt, int options)
37
- cdef int htmlParseDocument(xmlParserCtxt* ctxt)
38
- cdef int htmlParseChunk(xmlParserCtxt* ctxt,
39
- char* chunk, int size, int terminate)
40
-
41
- cdef xmlDoc* htmlCtxtReadFile(xmlParserCtxt* ctxt,
42
- char* filename, const_char* encoding,
43
- int options)
44
- cdef xmlDoc* htmlCtxtReadDoc(xmlParserCtxt* ctxt,
45
- char* buffer, char* URL, const_char* encoding,
46
- int options)
47
- cdef xmlDoc* htmlCtxtReadIO(xmlParserCtxt* ctxt,
48
- xmlInputReadCallback ioread,
49
- xmlInputCloseCallback ioclose,
50
- void* ioctx,
51
- char* URL, const_char* encoding,
52
- int options)
53
- cdef xmlDoc* htmlCtxtReadMemory(xmlParserCtxt* ctxt,
54
- char* buffer, int size,
55
- char* filename, const_char* encoding,
56
- int options)
1
+ from libc.string cimport const_char
2
+
3
+ from lxml.includes.tree cimport xmlDoc
4
+ from lxml.includes.tree cimport xmlInputReadCallback, xmlInputCloseCallback
5
+ from lxml.includes.xmlparser cimport xmlParserCtxt, xmlSAXHandler, xmlSAXHandlerV1
6
+
7
+ cdef extern from "libxml/HTMLparser.h" nogil:
8
+ ctypedef enum htmlParserOption:
9
+ HTML_PARSE_NOERROR # suppress error reports
10
+ HTML_PARSE_NOWARNING # suppress warning reports
11
+ HTML_PARSE_PEDANTIC # pedantic error reporting
12
+ HTML_PARSE_NOBLANKS # remove blank nodes
13
+ HTML_PARSE_NONET # Forbid network access
14
+ # libxml2 2.6.21+ only:
15
+ HTML_PARSE_RECOVER # Relaxed parsing
16
+ HTML_PARSE_COMPACT # compact small text nodes
17
+ # libxml2 2.7.7+ only:
18
+ HTML_PARSE_NOIMPLIED # Do not add implied html/body... elements
19
+ # libxml2 2.7.8+ only:
20
+ HTML_PARSE_NODEFDTD # do not default a doctype if not found
21
+ # libxml2 2.8.0+ only:
22
+ XML_PARSE_IGNORE_ENC # ignore internal document encoding hint
23
+
24
+ xmlSAXHandlerV1 htmlDefaultSAXHandler
25
+
26
+ cdef xmlParserCtxt* htmlCreateMemoryParserCtxt(
27
+ char* buffer, int size)
28
+ cdef xmlParserCtxt* htmlCreateFileParserCtxt(
29
+ char* filename, char* encoding)
30
+ cdef xmlParserCtxt* htmlCreatePushParserCtxt(xmlSAXHandler* sax,
31
+ void* user_data,
32
+ char* chunk, int size,
33
+ char* filename, int enc)
34
+ cdef void htmlFreeParserCtxt(xmlParserCtxt* ctxt)
35
+ cdef void htmlCtxtReset(xmlParserCtxt* ctxt)
36
+ cdef int htmlCtxtUseOptions(xmlParserCtxt* ctxt, int options)
37
+ cdef int htmlParseDocument(xmlParserCtxt* ctxt)
38
+ cdef int htmlParseChunk(xmlParserCtxt* ctxt,
39
+ char* chunk, int size, int terminate)
40
+
41
+ cdef xmlDoc* htmlCtxtReadFile(xmlParserCtxt* ctxt,
42
+ char* filename, const_char* encoding,
43
+ int options)
44
+ cdef xmlDoc* htmlCtxtReadDoc(xmlParserCtxt* ctxt,
45
+ char* buffer, char* URL, const_char* encoding,
46
+ int options)
47
+ cdef xmlDoc* htmlCtxtReadIO(xmlParserCtxt* ctxt,
48
+ xmlInputReadCallback ioread,
49
+ xmlInputCloseCallback ioclose,
50
+ void* ioctx,
51
+ char* URL, const_char* encoding,
52
+ int options)
53
+ cdef xmlDoc* htmlCtxtReadMemory(xmlParserCtxt* ctxt,
54
+ char* buffer, int size,
55
+ char* filename, const_char* encoding,
56
+ int options)
@@ -1,3 +1,3 @@
1
1
  #ifndef LXML_VERSION_STRING
2
- #define LXML_VERSION_STRING "5.2.0"
2
+ #define LXML_VERSION_STRING "5.2.2"
3
3
  #endif