lxml 6.0.0__cp39-cp39-musllinux_1_2_armv7l.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 (174) hide show
  1. lxml/ElementInclude.py +244 -0
  2. lxml/__init__.py +22 -0
  3. lxml/_elementpath.cpython-39-arm-linux-gnueabihf.so +0 -0
  4. lxml/_elementpath.py +343 -0
  5. lxml/apihelpers.pxi +1801 -0
  6. lxml/builder.cpython-39-arm-linux-gnueabihf.so +0 -0
  7. lxml/builder.py +243 -0
  8. lxml/classlookup.pxi +580 -0
  9. lxml/cleanup.pxi +215 -0
  10. lxml/cssselect.py +101 -0
  11. lxml/debug.pxi +36 -0
  12. lxml/docloader.pxi +178 -0
  13. lxml/doctestcompare.py +488 -0
  14. lxml/dtd.pxi +479 -0
  15. lxml/etree.cpython-39-arm-linux-gnueabihf.so +0 -0
  16. lxml/etree.h +244 -0
  17. lxml/etree.pyx +3853 -0
  18. lxml/etree_api.h +204 -0
  19. lxml/extensions.pxi +830 -0
  20. lxml/html/ElementSoup.py +10 -0
  21. lxml/html/__init__.py +1927 -0
  22. lxml/html/_diffcommand.py +86 -0
  23. lxml/html/_difflib.cpython-39-arm-linux-gnueabihf.so +0 -0
  24. lxml/html/_difflib.py +2106 -0
  25. lxml/html/_html5builder.py +100 -0
  26. lxml/html/_setmixin.py +56 -0
  27. lxml/html/builder.py +173 -0
  28. lxml/html/clean.py +21 -0
  29. lxml/html/defs.py +135 -0
  30. lxml/html/diff.cpython-39-arm-linux-gnueabihf.so +0 -0
  31. lxml/html/diff.py +972 -0
  32. lxml/html/formfill.py +299 -0
  33. lxml/html/html5parser.py +260 -0
  34. lxml/html/soupparser.py +314 -0
  35. lxml/html/usedoctest.py +13 -0
  36. lxml/includes/__init__.pxd +0 -0
  37. lxml/includes/__init__.py +0 -0
  38. lxml/includes/c14n.pxd +25 -0
  39. lxml/includes/config.pxd +3 -0
  40. lxml/includes/dtdvalid.pxd +18 -0
  41. lxml/includes/etree_defs.h +379 -0
  42. lxml/includes/etreepublic.pxd +237 -0
  43. lxml/includes/extlibs/__init__.py +0 -0
  44. lxml/includes/extlibs/libcharset.h +45 -0
  45. lxml/includes/extlibs/localcharset.h +137 -0
  46. lxml/includes/extlibs/zconf.h +543 -0
  47. lxml/includes/extlibs/zlib.h +1938 -0
  48. lxml/includes/htmlparser.pxd +56 -0
  49. lxml/includes/libexslt/__init__.py +0 -0
  50. lxml/includes/libexslt/exslt.h +108 -0
  51. lxml/includes/libexslt/exsltconfig.h +70 -0
  52. lxml/includes/libexslt/exsltexports.h +63 -0
  53. lxml/includes/libxml/HTMLparser.h +339 -0
  54. lxml/includes/libxml/HTMLtree.h +148 -0
  55. lxml/includes/libxml/SAX.h +18 -0
  56. lxml/includes/libxml/SAX2.h +170 -0
  57. lxml/includes/libxml/__init__.py +0 -0
  58. lxml/includes/libxml/c14n.h +115 -0
  59. lxml/includes/libxml/catalog.h +183 -0
  60. lxml/includes/libxml/chvalid.h +230 -0
  61. lxml/includes/libxml/debugXML.h +79 -0
  62. lxml/includes/libxml/dict.h +82 -0
  63. lxml/includes/libxml/encoding.h +307 -0
  64. lxml/includes/libxml/entities.h +147 -0
  65. lxml/includes/libxml/globals.h +25 -0
  66. lxml/includes/libxml/hash.h +251 -0
  67. lxml/includes/libxml/list.h +137 -0
  68. lxml/includes/libxml/nanoftp.h +16 -0
  69. lxml/includes/libxml/nanohttp.h +98 -0
  70. lxml/includes/libxml/parser.h +1633 -0
  71. lxml/includes/libxml/parserInternals.h +591 -0
  72. lxml/includes/libxml/relaxng.h +224 -0
  73. lxml/includes/libxml/schemasInternals.h +959 -0
  74. lxml/includes/libxml/schematron.h +143 -0
  75. lxml/includes/libxml/threads.h +81 -0
  76. lxml/includes/libxml/tree.h +1326 -0
  77. lxml/includes/libxml/uri.h +106 -0
  78. lxml/includes/libxml/valid.h +485 -0
  79. lxml/includes/libxml/xinclude.h +141 -0
  80. lxml/includes/libxml/xlink.h +193 -0
  81. lxml/includes/libxml/xmlIO.h +419 -0
  82. lxml/includes/libxml/xmlautomata.h +163 -0
  83. lxml/includes/libxml/xmlerror.h +962 -0
  84. lxml/includes/libxml/xmlexports.h +96 -0
  85. lxml/includes/libxml/xmlmemory.h +188 -0
  86. lxml/includes/libxml/xmlmodule.h +61 -0
  87. lxml/includes/libxml/xmlreader.h +444 -0
  88. lxml/includes/libxml/xmlregexp.h +116 -0
  89. lxml/includes/libxml/xmlsave.h +111 -0
  90. lxml/includes/libxml/xmlschemas.h +254 -0
  91. lxml/includes/libxml/xmlschemastypes.h +152 -0
  92. lxml/includes/libxml/xmlstring.h +140 -0
  93. lxml/includes/libxml/xmlunicode.h +15 -0
  94. lxml/includes/libxml/xmlversion.h +332 -0
  95. lxml/includes/libxml/xmlwriter.h +489 -0
  96. lxml/includes/libxml/xpath.h +569 -0
  97. lxml/includes/libxml/xpathInternals.h +639 -0
  98. lxml/includes/libxml/xpointer.h +48 -0
  99. lxml/includes/libxslt/__init__.py +0 -0
  100. lxml/includes/libxslt/attributes.h +39 -0
  101. lxml/includes/libxslt/documents.h +93 -0
  102. lxml/includes/libxslt/extensions.h +262 -0
  103. lxml/includes/libxslt/extra.h +72 -0
  104. lxml/includes/libxslt/functions.h +78 -0
  105. lxml/includes/libxslt/imports.h +75 -0
  106. lxml/includes/libxslt/keys.h +53 -0
  107. lxml/includes/libxslt/namespaces.h +68 -0
  108. lxml/includes/libxslt/numbersInternals.h +73 -0
  109. lxml/includes/libxslt/pattern.h +84 -0
  110. lxml/includes/libxslt/preproc.h +43 -0
  111. lxml/includes/libxslt/security.h +104 -0
  112. lxml/includes/libxslt/templates.h +77 -0
  113. lxml/includes/libxslt/transform.h +207 -0
  114. lxml/includes/libxslt/variables.h +118 -0
  115. lxml/includes/libxslt/xslt.h +110 -0
  116. lxml/includes/libxslt/xsltInternals.h +1995 -0
  117. lxml/includes/libxslt/xsltconfig.h +146 -0
  118. lxml/includes/libxslt/xsltexports.h +64 -0
  119. lxml/includes/libxslt/xsltlocale.h +44 -0
  120. lxml/includes/libxslt/xsltutils.h +343 -0
  121. lxml/includes/lxml-version.h +3 -0
  122. lxml/includes/relaxng.pxd +64 -0
  123. lxml/includes/schematron.pxd +34 -0
  124. lxml/includes/tree.pxd +492 -0
  125. lxml/includes/uri.pxd +5 -0
  126. lxml/includes/xinclude.pxd +22 -0
  127. lxml/includes/xmlerror.pxd +852 -0
  128. lxml/includes/xmlparser.pxd +303 -0
  129. lxml/includes/xmlschema.pxd +35 -0
  130. lxml/includes/xpath.pxd +136 -0
  131. lxml/includes/xslt.pxd +190 -0
  132. lxml/isoschematron/__init__.py +348 -0
  133. lxml/isoschematron/resources/rng/iso-schematron.rng +709 -0
  134. lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl +75 -0
  135. lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl +77 -0
  136. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl +313 -0
  137. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl +1160 -0
  138. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl +55 -0
  139. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1796 -0
  140. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +588 -0
  141. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt +84 -0
  142. lxml/iterparse.pxi +438 -0
  143. lxml/lxml.etree.h +244 -0
  144. lxml/lxml.etree_api.h +204 -0
  145. lxml/nsclasses.pxi +281 -0
  146. lxml/objectify.cpython-39-arm-linux-gnueabihf.so +0 -0
  147. lxml/objectify.pyx +2149 -0
  148. lxml/objectpath.pxi +332 -0
  149. lxml/parser.pxi +2059 -0
  150. lxml/parsertarget.pxi +180 -0
  151. lxml/proxy.pxi +619 -0
  152. lxml/public-api.pxi +178 -0
  153. lxml/pyclasslookup.py +3 -0
  154. lxml/readonlytree.pxi +565 -0
  155. lxml/relaxng.pxi +165 -0
  156. lxml/sax.cpython-39-arm-linux-gnueabihf.so +0 -0
  157. lxml/sax.py +286 -0
  158. lxml/saxparser.pxi +875 -0
  159. lxml/schematron.pxi +173 -0
  160. lxml/serializer.pxi +1849 -0
  161. lxml/usedoctest.py +13 -0
  162. lxml/xinclude.pxi +67 -0
  163. lxml/xmlerror.pxi +1654 -0
  164. lxml/xmlid.pxi +179 -0
  165. lxml/xmlschema.pxi +215 -0
  166. lxml/xpath.pxi +487 -0
  167. lxml/xslt.pxi +957 -0
  168. lxml/xsltext.pxi +242 -0
  169. lxml-6.0.0.dist-info/METADATA +163 -0
  170. lxml-6.0.0.dist-info/RECORD +174 -0
  171. lxml-6.0.0.dist-info/WHEEL +5 -0
  172. lxml-6.0.0.dist-info/licenses/LICENSE.txt +31 -0
  173. lxml-6.0.0.dist-info/licenses/LICENSES.txt +29 -0
  174. lxml-6.0.0.dist-info/top_level.txt +1 -0
lxml/objectpath.pxi ADDED
@@ -0,0 +1,332 @@
1
+ ################################################################################
2
+ # ObjectPath
3
+
4
+ ctypedef struct _ObjectPath:
5
+ const_xmlChar* href
6
+ const_xmlChar* name
7
+ Py_ssize_t index
8
+
9
+
10
+ cdef object _NO_DEFAULT = object()
11
+
12
+
13
+ cdef class ObjectPath:
14
+ """ObjectPath(path)
15
+ Immutable object that represents a compiled object path.
16
+
17
+ Example for a path: 'root.child[1].{other}child[25]'
18
+ """
19
+ cdef readonly object find
20
+ cdef list _path
21
+ cdef object _path_str
22
+ cdef _ObjectPath* _c_path
23
+ cdef Py_ssize_t _path_len
24
+ def __init__(self, path):
25
+ if python._isString(path):
26
+ self._path = _parse_object_path_string(path)
27
+ self._path_str = path
28
+ else:
29
+ self._path = _parse_object_path_list(path)
30
+ self._path_str = '.'.join(path)
31
+ self._path_len = len(self._path)
32
+ self._c_path = _build_object_path_segments(self._path)
33
+ self.find = self.__call__
34
+
35
+ def __dealloc__(self):
36
+ if self._c_path is not NULL:
37
+ python.lxml_free(self._c_path)
38
+
39
+ def __str__(self):
40
+ return self._path_str
41
+
42
+ def __call__(self, _Element root not None, *_default):
43
+ """Follow the attribute path in the object structure and return the
44
+ target attribute value.
45
+
46
+ If it it not found, either returns a default value (if one was passed
47
+ as second argument) or raises AttributeError.
48
+ """
49
+ if _default:
50
+ if len(_default) > 1:
51
+ raise TypeError, "invalid number of arguments: needs one or two"
52
+ default = _default[0]
53
+ else:
54
+ default = _NO_DEFAULT
55
+ return _find_object_path(root, self._c_path, self._path_len, default)
56
+
57
+ def hasattr(self, _Element root not None):
58
+ "hasattr(self, root)"
59
+ try:
60
+ _find_object_path(root, self._c_path, self._path_len, _NO_DEFAULT)
61
+ except AttributeError:
62
+ return False
63
+ return True
64
+
65
+ def setattr(self, _Element root not None, value):
66
+ """setattr(self, root, value)
67
+
68
+ Set the value of the target element in a subtree.
69
+
70
+ If any of the children on the path does not exist, it is created.
71
+ """
72
+ _create_object_path(root, self._c_path, self._path_len, 1, value)
73
+
74
+ def addattr(self, _Element root not None, value):
75
+ """addattr(self, root, value)
76
+
77
+ Append a value to the target element in a subtree.
78
+
79
+ If any of the children on the path does not exist, it is created.
80
+ """
81
+ _create_object_path(root, self._c_path, self._path_len, 0, value)
82
+
83
+
84
+ cdef object __MATCH_PATH_SEGMENT = re.compile(
85
+ r"(\.?)\s*(?:\{([^}]*)\})?\s*([^.{}\[\]\s]+)\s*(?:\[\s*([-0-9]+)\s*\])?",
86
+ re.U).match
87
+
88
+ cdef tuple _RELATIVE_PATH_SEGMENT = (None, None, 0)
89
+
90
+
91
+ cdef list _parse_object_path_string(_path):
92
+ """Parse object path string into a (ns, name, index) list.
93
+ """
94
+ cdef bint has_dot
95
+ cdef unicode path
96
+ new_path = []
97
+ if isinstance(_path, bytes):
98
+ path = (<bytes>_path).decode('ascii')
99
+ elif type(_path) is not unicode:
100
+ path = unicode(_path)
101
+ else:
102
+ path = _path
103
+ path = path.strip()
104
+ if path == '.':
105
+ return [_RELATIVE_PATH_SEGMENT]
106
+ path_pos = 0
107
+ while path:
108
+ match = __MATCH_PATH_SEGMENT(path, path_pos)
109
+ if match is None:
110
+ break
111
+
112
+ dot, ns, name, index = match.groups()
113
+ index = int(index) if index else 0
114
+ has_dot = dot == '.'
115
+ if not new_path:
116
+ if has_dot:
117
+ # path '.child' => ignore root
118
+ new_path.append(_RELATIVE_PATH_SEGMENT)
119
+ elif index:
120
+ raise ValueError, "index not allowed on root node"
121
+ elif not has_dot:
122
+ raise ValueError, "invalid path"
123
+ if ns is not None:
124
+ ns = python.PyUnicode_AsUTF8String(ns)
125
+ name = python.PyUnicode_AsUTF8String(name)
126
+ new_path.append( (ns, name, index) )
127
+
128
+ path_pos = match.end()
129
+ if not new_path or len(path) > path_pos:
130
+ raise ValueError, "invalid path"
131
+ return new_path
132
+
133
+
134
+ cdef list _parse_object_path_list(path):
135
+ """Parse object path sequence into a (ns, name, index) list.
136
+ """
137
+ new_path = []
138
+ for item in path:
139
+ item = item.strip()
140
+ if not new_path and item == '':
141
+ # path '.child' => ignore root
142
+ ns = name = None
143
+ index = 0
144
+ else:
145
+ ns, name = cetree.getNsTag(item)
146
+ c_name = _xcstr(name)
147
+ index_pos = tree.xmlStrchr(c_name, c'[')
148
+ if index_pos is NULL:
149
+ index = 0
150
+ else:
151
+ index_end = tree.xmlStrchr(index_pos + 1, c']')
152
+ if index_end is NULL:
153
+ raise ValueError, "index must be enclosed in []"
154
+ index = int(index_pos[1:index_end - index_pos])
155
+ if not new_path and index != 0:
156
+ raise ValueError, "index not allowed on root node"
157
+ name = <bytes>c_name[:index_pos - c_name]
158
+ new_path.append( (ns, name, index) )
159
+ if not new_path:
160
+ raise ValueError, "invalid path"
161
+ return new_path
162
+
163
+
164
+ cdef _ObjectPath* _build_object_path_segments(list path_list) except NULL:
165
+ cdef _ObjectPath* c_path
166
+ cdef _ObjectPath* c_path_segments
167
+ c_path_segments = <_ObjectPath*>python.lxml_malloc(len(path_list), sizeof(_ObjectPath))
168
+ if c_path_segments is NULL:
169
+ raise MemoryError()
170
+ c_path = c_path_segments
171
+ for href, name, index in path_list:
172
+ c_path[0].href = _xcstr(href) if href is not None else NULL
173
+ c_path[0].name = _xcstr(name) if name is not None else NULL
174
+ c_path[0].index = index
175
+ c_path += 1
176
+ return c_path_segments
177
+
178
+
179
+ cdef _find_object_path(_Element root, _ObjectPath* c_path, Py_ssize_t c_path_len, default_value):
180
+ """Follow the path to find the target element.
181
+ """
182
+ cdef tree.xmlNode* c_node
183
+ cdef Py_ssize_t c_index
184
+ c_node = root._c_node
185
+ c_name = c_path[0].name
186
+ c_href = c_path[0].href
187
+ if c_href is NULL or c_href[0] == c'\0':
188
+ c_href = tree._getNs(c_node)
189
+ if not cetree.tagMatches(c_node, c_href, c_name):
190
+ if default_value is not _NO_DEFAULT:
191
+ return default_value
192
+ else:
193
+ raise ValueError(
194
+ f"root element does not match: need {cetree.namespacedNameFromNsName(c_href, c_name)}, got {root.tag}")
195
+
196
+ while c_node is not NULL:
197
+ c_path_len -= 1
198
+ if c_path_len <= 0:
199
+ break
200
+
201
+ c_path += 1
202
+ if c_path[0].href is not NULL:
203
+ c_href = c_path[0].href # otherwise: keep parent namespace
204
+ c_name = tree.xmlDictExists(c_node.doc.dict, c_path[0].name, -1)
205
+ if c_name is NULL:
206
+ c_name = c_path[0].name
207
+ c_node = NULL
208
+ break
209
+ c_index = c_path[0].index
210
+ c_node = c_node.last if c_index < 0 else c_node.children
211
+ c_node = _findFollowingSibling(c_node, c_href, c_name, c_index)
212
+
213
+ if c_node is not NULL:
214
+ return cetree.elementFactory(root._doc, c_node)
215
+ elif default_value is not _NO_DEFAULT:
216
+ return default_value
217
+ else:
218
+ tag = cetree.namespacedNameFromNsName(c_href, c_name)
219
+ raise AttributeError, f"no such child: {tag}"
220
+
221
+
222
+ cdef _create_object_path(_Element root, _ObjectPath* c_path,
223
+ Py_ssize_t c_path_len, int replace, value):
224
+ """Follow the path to find the target element, build the missing children
225
+ as needed and set the target element to 'value'. If replace is true, an
226
+ existing value is replaced, otherwise the new value is added.
227
+ """
228
+ cdef _Element child
229
+ cdef tree.xmlNode* c_node
230
+ cdef tree.xmlNode* c_child
231
+ cdef Py_ssize_t c_index
232
+ if c_path_len == 1:
233
+ raise TypeError, "cannot update root node"
234
+
235
+ c_node = root._c_node
236
+ c_name = c_path[0].name
237
+ c_href = c_path[0].href
238
+ if c_href is NULL or c_href[0] == c'\0':
239
+ c_href = tree._getNs(c_node)
240
+ if not cetree.tagMatches(c_node, c_href, c_name):
241
+ raise ValueError(
242
+ f"root element does not match: need {cetree.namespacedNameFromNsName(c_href, c_name)}, got {root.tag}")
243
+
244
+ while c_path_len > 1:
245
+ c_path_len -= 1
246
+ c_path += 1
247
+ if c_path[0].href is not NULL:
248
+ c_href = c_path[0].href # otherwise: keep parent namespace
249
+ c_index = c_path[0].index
250
+ c_name = tree.xmlDictExists(c_node.doc.dict, c_path[0].name, -1)
251
+ if c_name is NULL:
252
+ c_name = c_path[0].name
253
+ c_child = NULL
254
+ else:
255
+ c_child = c_node.last if c_index < 0 else c_node.children
256
+ c_child = _findFollowingSibling(c_child, c_href, c_name, c_index)
257
+
258
+ if c_child is not NULL:
259
+ c_node = c_child
260
+ elif c_index != 0:
261
+ raise TypeError, "creating indexed path attributes is not supported"
262
+ elif c_path_len == 1:
263
+ _appendValue(cetree.elementFactory(root._doc, c_node),
264
+ cetree.namespacedNameFromNsName(c_href, c_name),
265
+ value)
266
+ return
267
+ else:
268
+ child = cetree.makeSubElement(
269
+ cetree.elementFactory(root._doc, c_node),
270
+ cetree.namespacedNameFromNsName(c_href, c_name),
271
+ None, None, None, None)
272
+ c_node = child._c_node
273
+
274
+ # if we get here, the entire path was already there
275
+ if replace:
276
+ element = cetree.elementFactory(root._doc, c_node)
277
+ _replaceElement(element, value)
278
+ else:
279
+ _appendValue(cetree.elementFactory(root._doc, c_node.parent),
280
+ cetree.namespacedName(c_node), value)
281
+
282
+
283
+ cdef list _build_descendant_paths(tree.xmlNode* c_node, prefix_string):
284
+ """Returns a list of all descendant paths.
285
+ """
286
+ cdef list path, path_list
287
+ tag = cetree.namespacedName(c_node)
288
+ if prefix_string:
289
+ if prefix_string[-1] != '.':
290
+ prefix_string += '.'
291
+ prefix_string = prefix_string + tag
292
+ else:
293
+ prefix_string = tag
294
+ path = [prefix_string]
295
+ path_list = []
296
+ _recursive_build_descendant_paths(c_node, path, path_list)
297
+ return path_list
298
+
299
+
300
+ cdef int _recursive_build_descendant_paths(tree.xmlNode* c_node,
301
+ list path, list path_list) except -1:
302
+ """Fills the list 'path_list' with all descendant paths, initial prefix
303
+ being in the list 'path'.
304
+ """
305
+ cdef tree.xmlNode* c_child
306
+ tags = {}
307
+ path_list.append('.'.join(path))
308
+ c_href = tree._getNs(c_node)
309
+ c_child = c_node.children
310
+ while c_child is not NULL:
311
+ while c_child.type != tree.XML_ELEMENT_NODE:
312
+ c_child = c_child.next
313
+ if c_child is NULL:
314
+ return 0
315
+ if c_href is tree._getNs(c_child):
316
+ tag = pyunicode(c_child.name)
317
+ elif c_href is not NULL and tree._getNs(c_child) is NULL:
318
+ # special case: parent has namespace, child does not
319
+ tag = '{}' + pyunicode(c_child.name)
320
+ else:
321
+ tag = cetree.namespacedName(c_child)
322
+ count = tags.get(tag)
323
+ if count is None:
324
+ tags[tag] = 1
325
+ else:
326
+ tags[tag] = count + 1
327
+ tag += f'[{count}]'
328
+ path.append(tag)
329
+ _recursive_build_descendant_paths(c_child, path, path_list)
330
+ del path[-1]
331
+ c_child = c_child.next
332
+ return 0