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.
- lxml/ElementInclude.py +244 -244
- lxml/__init__.py +22 -22
- lxml/_elementpath.cp310-win32.pyd +0 -0
- lxml/_elementpath.py +341 -341
- lxml/apihelpers.pxi +1793 -1793
- lxml/builder.cp310-win32.pyd +0 -0
- lxml/builder.py +232 -232
- lxml/classlookup.pxi +580 -580
- lxml/cleanup.pxi +215 -215
- lxml/cssselect.py +101 -101
- lxml/debug.pxi +90 -90
- lxml/docloader.pxi +178 -178
- lxml/doctestcompare.py +488 -488
- lxml/dtd.pxi +478 -478
- lxml/etree.cp310-win32.pyd +0 -0
- lxml/etree.h +6 -6
- lxml/etree.pyx +3732 -3711
- lxml/extensions.pxi +833 -833
- lxml/html/ElementSoup.py +10 -10
- lxml/html/__init__.py +1923 -1923
- lxml/html/_diffcommand.py +86 -86
- lxml/html/_html5builder.py +100 -100
- lxml/html/_setmixin.py +56 -56
- lxml/html/builder.py +133 -133
- lxml/html/clean.py +21 -21
- lxml/html/defs.py +135 -135
- lxml/html/diff.cp310-win32.pyd +0 -0
- lxml/html/diff.py +878 -878
- lxml/html/formfill.py +299 -299
- lxml/html/html5parser.py +260 -260
- lxml/html/soupparser.py +314 -314
- lxml/html/usedoctest.py +13 -13
- lxml/includes/c14n.pxd +25 -25
- lxml/includes/config.pxd +3 -3
- lxml/includes/dtdvalid.pxd +18 -18
- lxml/includes/etree_defs.h +379 -379
- lxml/includes/etreepublic.pxd +237 -237
- lxml/includes/htmlparser.pxd +56 -56
- lxml/includes/lxml-version.h +1 -1
- lxml/includes/relaxng.pxd +64 -64
- lxml/includes/schematron.pxd +34 -34
- lxml/includes/tree.pxd +494 -494
- lxml/includes/uri.pxd +5 -5
- lxml/includes/xinclude.pxd +22 -22
- lxml/includes/xmlerror.pxd +852 -852
- lxml/includes/xmlparser.pxd +265 -265
- lxml/includes/xmlschema.pxd +35 -35
- lxml/includes/xpath.pxd +136 -136
- lxml/includes/xslt.pxd +190 -190
- lxml/isoschematron/__init__.py +348 -348
- lxml/isoschematron/resources/rng/iso-schematron.rng +709 -709
- lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl +75 -75
- lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl +312 -312
- lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl +1159 -1159
- lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl +54 -54
- lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1796 -1796
- lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +588 -588
- lxml/iterparse.pxi +438 -438
- lxml/lxml.etree.h +6 -6
- lxml/nsclasses.pxi +281 -281
- lxml/objectify.cp310-win32.pyd +0 -0
- lxml/objectify.pyx +2145 -2145
- lxml/objectpath.pxi +332 -332
- lxml/parser.pxi +1994 -1994
- lxml/parsertarget.pxi +180 -180
- lxml/proxy.pxi +619 -619
- lxml/public-api.pxi +178 -178
- lxml/pyclasslookup.py +3 -3
- lxml/readonlytree.pxi +565 -565
- lxml/relaxng.pxi +165 -165
- lxml/sax.cp310-win32.pyd +0 -0
- lxml/sax.py +275 -275
- lxml/saxparser.pxi +875 -875
- lxml/schematron.pxi +168 -168
- lxml/serializer.pxi +1871 -1871
- lxml/usedoctest.py +13 -13
- lxml/xinclude.pxi +67 -67
- lxml/xmlerror.pxi +1654 -1654
- lxml/xmlid.pxi +179 -179
- lxml/xmlschema.pxi +215 -215
- lxml/xpath.pxi +487 -487
- lxml/xslt.pxi +950 -950
- lxml/xsltext.pxi +242 -242
- {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSE.txt +29 -29
- {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSES.txt +29 -29
- {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/METADATA +9 -17
- {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/RECORD +89 -89
- {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/WHEEL +0 -0
- {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/top_level.txt +0 -0
lxml/xmlid.pxi
CHANGED
@@ -1,179 +1,179 @@
|
|
1
|
-
cdef object _find_id_attributes
|
2
|
-
|
3
|
-
def XMLID(text, parser=None, *, base_url=None):
|
4
|
-
"""XMLID(text, parser=None, base_url=None)
|
5
|
-
|
6
|
-
Parse the text and return a tuple (root node, ID dictionary). The root
|
7
|
-
node is the same as returned by the XML() function. The dictionary
|
8
|
-
contains string-element pairs. The dictionary keys are the values of 'id'
|
9
|
-
attributes. The elements referenced by the ID are stored as dictionary
|
10
|
-
values.
|
11
|
-
"""
|
12
|
-
cdef dict dic
|
13
|
-
global _find_id_attributes
|
14
|
-
if _find_id_attributes is None:
|
15
|
-
_find_id_attributes = XPath('//*[string(@id)]')
|
16
|
-
|
17
|
-
# ElementTree compatible implementation: parse and look for 'id' attributes
|
18
|
-
root = XML(text, parser, base_url=base_url)
|
19
|
-
dic = {}
|
20
|
-
for elem in _find_id_attributes(root):
|
21
|
-
dic[elem.get('id')] = elem
|
22
|
-
return root, dic
|
23
|
-
|
24
|
-
def XMLDTDID(text, parser=None, *, base_url=None):
|
25
|
-
"""XMLDTDID(text, parser=None, base_url=None)
|
26
|
-
|
27
|
-
Parse the text and return a tuple (root node, ID dictionary). The root
|
28
|
-
node is the same as returned by the XML() function. The dictionary
|
29
|
-
contains string-element pairs. The dictionary keys are the values of ID
|
30
|
-
attributes as defined by the DTD. The elements referenced by the ID are
|
31
|
-
stored as dictionary values.
|
32
|
-
|
33
|
-
Note that you must not modify the XML tree if you use the ID dictionary.
|
34
|
-
The results are undefined.
|
35
|
-
"""
|
36
|
-
cdef _Element root
|
37
|
-
root = XML(text, parser, base_url=base_url)
|
38
|
-
# xml:id spec compatible implementation: use DTD ID attributes from libxml2
|
39
|
-
if root._doc._c_doc.ids is NULL:
|
40
|
-
return root, {}
|
41
|
-
else:
|
42
|
-
return root, _IDDict(root)
|
43
|
-
|
44
|
-
def parseid(source, parser=None, *, base_url=None):
|
45
|
-
"""parseid(source, parser=None)
|
46
|
-
|
47
|
-
Parses the source into a tuple containing an ElementTree object and an
|
48
|
-
ID dictionary. If no parser is provided as second argument, the default
|
49
|
-
parser is used.
|
50
|
-
|
51
|
-
Note that you must not modify the XML tree if you use the ID dictionary.
|
52
|
-
The results are undefined.
|
53
|
-
"""
|
54
|
-
cdef _Document doc
|
55
|
-
doc = _parseDocument(source, parser, base_url)
|
56
|
-
return _elementTreeFactory(doc, None), _IDDict(doc)
|
57
|
-
|
58
|
-
cdef class _IDDict:
|
59
|
-
"""IDDict(self, etree)
|
60
|
-
A dictionary-like proxy class that mapps ID attributes to elements.
|
61
|
-
|
62
|
-
The dictionary must be instantiated with the root element of a parsed XML
|
63
|
-
document, otherwise the behaviour is undefined. Elements and XML trees
|
64
|
-
that were created or modified 'by hand' are not supported.
|
65
|
-
"""
|
66
|
-
cdef _Document _doc
|
67
|
-
cdef object _keys
|
68
|
-
cdef object _items
|
69
|
-
def __cinit__(self, etree):
|
70
|
-
cdef _Document doc
|
71
|
-
doc = _documentOrRaise(etree)
|
72
|
-
if doc._c_doc.ids is NULL:
|
73
|
-
raise ValueError, "No ID dictionary available."
|
74
|
-
self._doc = doc
|
75
|
-
self._keys = None
|
76
|
-
self._items = None
|
77
|
-
|
78
|
-
def copy(self):
|
79
|
-
return _IDDict(self._doc)
|
80
|
-
|
81
|
-
def __getitem__(self, id_name):
|
82
|
-
cdef tree.xmlHashTable* c_ids
|
83
|
-
cdef tree.xmlID* c_id
|
84
|
-
cdef xmlAttr* c_attr
|
85
|
-
c_ids = self._doc._c_doc.ids
|
86
|
-
id_utf = _utf8(id_name)
|
87
|
-
c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _xcstr(id_utf))
|
88
|
-
if c_id is NULL:
|
89
|
-
raise KeyError, "key not found."
|
90
|
-
c_attr = c_id.attr
|
91
|
-
if c_attr is NULL or c_attr.parent is NULL:
|
92
|
-
raise KeyError, "ID attribute not found."
|
93
|
-
return _elementFactory(self._doc, c_attr.parent)
|
94
|
-
|
95
|
-
def get(self, id_name):
|
96
|
-
return self[id_name]
|
97
|
-
|
98
|
-
def __contains__(self, id_name):
|
99
|
-
cdef tree.xmlID* c_id
|
100
|
-
id_utf = _utf8(id_name)
|
101
|
-
c_id = <tree.xmlID*>tree.xmlHashLookup(
|
102
|
-
self._doc._c_doc.ids, _xcstr(id_utf))
|
103
|
-
return c_id is not NULL
|
104
|
-
|
105
|
-
def has_key(self, id_name):
|
106
|
-
return id_name in self
|
107
|
-
|
108
|
-
def __repr__(self):
|
109
|
-
return repr(dict(self))
|
110
|
-
|
111
|
-
def keys(self):
|
112
|
-
if self._keys is None:
|
113
|
-
self._keys = self._build_keys()
|
114
|
-
return self._keys[:]
|
115
|
-
|
116
|
-
def __iter__(self):
|
117
|
-
if self._keys is None:
|
118
|
-
self._keys = self._build_keys()
|
119
|
-
return iter(self._keys)
|
120
|
-
|
121
|
-
def iterkeys(self):
|
122
|
-
return self
|
123
|
-
|
124
|
-
def __len__(self):
|
125
|
-
if self._keys is None:
|
126
|
-
self._keys = self._build_keys()
|
127
|
-
return len(self._keys)
|
128
|
-
|
129
|
-
def items(self):
|
130
|
-
if self._items is None:
|
131
|
-
self._items = self._build_items()
|
132
|
-
return self._items[:]
|
133
|
-
|
134
|
-
def iteritems(self):
|
135
|
-
if self._items is None:
|
136
|
-
self._items = self._build_items()
|
137
|
-
return iter(self._items)
|
138
|
-
|
139
|
-
def values(self):
|
140
|
-
cdef list values = []
|
141
|
-
if self._items is None:
|
142
|
-
self._items = self._build_items()
|
143
|
-
for item in self._items:
|
144
|
-
value = python.PyTuple_GET_ITEM(item, 1)
|
145
|
-
python.Py_INCREF(value)
|
146
|
-
values.append(value)
|
147
|
-
return values
|
148
|
-
|
149
|
-
def itervalues(self):
|
150
|
-
return iter(self.values())
|
151
|
-
|
152
|
-
cdef object _build_keys(self):
|
153
|
-
keys = []
|
154
|
-
tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
|
155
|
-
<tree.xmlHashScanner>_collectIdHashKeys, <python.PyObject*>keys)
|
156
|
-
return keys
|
157
|
-
|
158
|
-
cdef object _build_items(self):
|
159
|
-
items = []
|
160
|
-
context = (items, self._doc)
|
161
|
-
tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
|
162
|
-
<tree.xmlHashScanner>_collectIdHashItemList, <python.PyObject*>context)
|
163
|
-
return items
|
164
|
-
|
165
|
-
cdef void _collectIdHashItemList(void* payload, void* context, xmlChar* name) noexcept:
|
166
|
-
# collect elements from ID attribute hash table
|
167
|
-
cdef list lst
|
168
|
-
c_id = <tree.xmlID*>payload
|
169
|
-
if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
|
170
|
-
return
|
171
|
-
lst, doc = <tuple>context
|
172
|
-
element = _elementFactory(doc, c_id.attr.parent)
|
173
|
-
lst.append( (funicode(name), element) )
|
174
|
-
|
175
|
-
cdef void _collectIdHashKeys(void* payload, void* collect_list, xmlChar* name) noexcept:
|
176
|
-
c_id = <tree.xmlID*>payload
|
177
|
-
if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
|
178
|
-
return
|
179
|
-
(<list>collect_list).append(funicode(name))
|
1
|
+
cdef object _find_id_attributes
|
2
|
+
|
3
|
+
def XMLID(text, parser=None, *, base_url=None):
|
4
|
+
"""XMLID(text, parser=None, base_url=None)
|
5
|
+
|
6
|
+
Parse the text and return a tuple (root node, ID dictionary). The root
|
7
|
+
node is the same as returned by the XML() function. The dictionary
|
8
|
+
contains string-element pairs. The dictionary keys are the values of 'id'
|
9
|
+
attributes. The elements referenced by the ID are stored as dictionary
|
10
|
+
values.
|
11
|
+
"""
|
12
|
+
cdef dict dic
|
13
|
+
global _find_id_attributes
|
14
|
+
if _find_id_attributes is None:
|
15
|
+
_find_id_attributes = XPath('//*[string(@id)]')
|
16
|
+
|
17
|
+
# ElementTree compatible implementation: parse and look for 'id' attributes
|
18
|
+
root = XML(text, parser, base_url=base_url)
|
19
|
+
dic = {}
|
20
|
+
for elem in _find_id_attributes(root):
|
21
|
+
dic[elem.get('id')] = elem
|
22
|
+
return root, dic
|
23
|
+
|
24
|
+
def XMLDTDID(text, parser=None, *, base_url=None):
|
25
|
+
"""XMLDTDID(text, parser=None, base_url=None)
|
26
|
+
|
27
|
+
Parse the text and return a tuple (root node, ID dictionary). The root
|
28
|
+
node is the same as returned by the XML() function. The dictionary
|
29
|
+
contains string-element pairs. The dictionary keys are the values of ID
|
30
|
+
attributes as defined by the DTD. The elements referenced by the ID are
|
31
|
+
stored as dictionary values.
|
32
|
+
|
33
|
+
Note that you must not modify the XML tree if you use the ID dictionary.
|
34
|
+
The results are undefined.
|
35
|
+
"""
|
36
|
+
cdef _Element root
|
37
|
+
root = XML(text, parser, base_url=base_url)
|
38
|
+
# xml:id spec compatible implementation: use DTD ID attributes from libxml2
|
39
|
+
if root._doc._c_doc.ids is NULL:
|
40
|
+
return root, {}
|
41
|
+
else:
|
42
|
+
return root, _IDDict(root)
|
43
|
+
|
44
|
+
def parseid(source, parser=None, *, base_url=None):
|
45
|
+
"""parseid(source, parser=None)
|
46
|
+
|
47
|
+
Parses the source into a tuple containing an ElementTree object and an
|
48
|
+
ID dictionary. If no parser is provided as second argument, the default
|
49
|
+
parser is used.
|
50
|
+
|
51
|
+
Note that you must not modify the XML tree if you use the ID dictionary.
|
52
|
+
The results are undefined.
|
53
|
+
"""
|
54
|
+
cdef _Document doc
|
55
|
+
doc = _parseDocument(source, parser, base_url)
|
56
|
+
return _elementTreeFactory(doc, None), _IDDict(doc)
|
57
|
+
|
58
|
+
cdef class _IDDict:
|
59
|
+
"""IDDict(self, etree)
|
60
|
+
A dictionary-like proxy class that mapps ID attributes to elements.
|
61
|
+
|
62
|
+
The dictionary must be instantiated with the root element of a parsed XML
|
63
|
+
document, otherwise the behaviour is undefined. Elements and XML trees
|
64
|
+
that were created or modified 'by hand' are not supported.
|
65
|
+
"""
|
66
|
+
cdef _Document _doc
|
67
|
+
cdef object _keys
|
68
|
+
cdef object _items
|
69
|
+
def __cinit__(self, etree):
|
70
|
+
cdef _Document doc
|
71
|
+
doc = _documentOrRaise(etree)
|
72
|
+
if doc._c_doc.ids is NULL:
|
73
|
+
raise ValueError, "No ID dictionary available."
|
74
|
+
self._doc = doc
|
75
|
+
self._keys = None
|
76
|
+
self._items = None
|
77
|
+
|
78
|
+
def copy(self):
|
79
|
+
return _IDDict(self._doc)
|
80
|
+
|
81
|
+
def __getitem__(self, id_name):
|
82
|
+
cdef tree.xmlHashTable* c_ids
|
83
|
+
cdef tree.xmlID* c_id
|
84
|
+
cdef xmlAttr* c_attr
|
85
|
+
c_ids = self._doc._c_doc.ids
|
86
|
+
id_utf = _utf8(id_name)
|
87
|
+
c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _xcstr(id_utf))
|
88
|
+
if c_id is NULL:
|
89
|
+
raise KeyError, "key not found."
|
90
|
+
c_attr = c_id.attr
|
91
|
+
if c_attr is NULL or c_attr.parent is NULL:
|
92
|
+
raise KeyError, "ID attribute not found."
|
93
|
+
return _elementFactory(self._doc, c_attr.parent)
|
94
|
+
|
95
|
+
def get(self, id_name):
|
96
|
+
return self[id_name]
|
97
|
+
|
98
|
+
def __contains__(self, id_name):
|
99
|
+
cdef tree.xmlID* c_id
|
100
|
+
id_utf = _utf8(id_name)
|
101
|
+
c_id = <tree.xmlID*>tree.xmlHashLookup(
|
102
|
+
self._doc._c_doc.ids, _xcstr(id_utf))
|
103
|
+
return c_id is not NULL
|
104
|
+
|
105
|
+
def has_key(self, id_name):
|
106
|
+
return id_name in self
|
107
|
+
|
108
|
+
def __repr__(self):
|
109
|
+
return repr(dict(self))
|
110
|
+
|
111
|
+
def keys(self):
|
112
|
+
if self._keys is None:
|
113
|
+
self._keys = self._build_keys()
|
114
|
+
return self._keys[:]
|
115
|
+
|
116
|
+
def __iter__(self):
|
117
|
+
if self._keys is None:
|
118
|
+
self._keys = self._build_keys()
|
119
|
+
return iter(self._keys)
|
120
|
+
|
121
|
+
def iterkeys(self):
|
122
|
+
return self
|
123
|
+
|
124
|
+
def __len__(self):
|
125
|
+
if self._keys is None:
|
126
|
+
self._keys = self._build_keys()
|
127
|
+
return len(self._keys)
|
128
|
+
|
129
|
+
def items(self):
|
130
|
+
if self._items is None:
|
131
|
+
self._items = self._build_items()
|
132
|
+
return self._items[:]
|
133
|
+
|
134
|
+
def iteritems(self):
|
135
|
+
if self._items is None:
|
136
|
+
self._items = self._build_items()
|
137
|
+
return iter(self._items)
|
138
|
+
|
139
|
+
def values(self):
|
140
|
+
cdef list values = []
|
141
|
+
if self._items is None:
|
142
|
+
self._items = self._build_items()
|
143
|
+
for item in self._items:
|
144
|
+
value = python.PyTuple_GET_ITEM(item, 1)
|
145
|
+
python.Py_INCREF(value)
|
146
|
+
values.append(value)
|
147
|
+
return values
|
148
|
+
|
149
|
+
def itervalues(self):
|
150
|
+
return iter(self.values())
|
151
|
+
|
152
|
+
cdef object _build_keys(self):
|
153
|
+
keys = []
|
154
|
+
tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
|
155
|
+
<tree.xmlHashScanner>_collectIdHashKeys, <python.PyObject*>keys)
|
156
|
+
return keys
|
157
|
+
|
158
|
+
cdef object _build_items(self):
|
159
|
+
items = []
|
160
|
+
context = (items, self._doc)
|
161
|
+
tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
|
162
|
+
<tree.xmlHashScanner>_collectIdHashItemList, <python.PyObject*>context)
|
163
|
+
return items
|
164
|
+
|
165
|
+
cdef void _collectIdHashItemList(void* payload, void* context, xmlChar* name) noexcept:
|
166
|
+
# collect elements from ID attribute hash table
|
167
|
+
cdef list lst
|
168
|
+
c_id = <tree.xmlID*>payload
|
169
|
+
if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
|
170
|
+
return
|
171
|
+
lst, doc = <tuple>context
|
172
|
+
element = _elementFactory(doc, c_id.attr.parent)
|
173
|
+
lst.append( (funicode(name), element) )
|
174
|
+
|
175
|
+
cdef void _collectIdHashKeys(void* payload, void* collect_list, xmlChar* name) noexcept:
|
176
|
+
c_id = <tree.xmlID*>payload
|
177
|
+
if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
|
178
|
+
return
|
179
|
+
(<list>collect_list).append(funicode(name))
|