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
Binary file
lxml/builder.py CHANGED
@@ -1,232 +1,232 @@
1
- # cython: language_level=2
2
-
3
- #
4
- # Element generator factory by Fredrik Lundh.
5
- #
6
- # Source:
7
- # http://online.effbot.org/2006_11_01_archive.htm#et-builder
8
- # http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py
9
- #
10
- # --------------------------------------------------------------------
11
- # The ElementTree toolkit is
12
- #
13
- # Copyright (c) 1999-2004 by Fredrik Lundh
14
- #
15
- # By obtaining, using, and/or copying this software and/or its
16
- # associated documentation, you agree that you have read, understood,
17
- # and will comply with the following terms and conditions:
18
- #
19
- # Permission to use, copy, modify, and distribute this software and
20
- # its associated documentation for any purpose and without fee is
21
- # hereby granted, provided that the above copyright notice appears in
22
- # all copies, and that both that copyright notice and this permission
23
- # notice appear in supporting documentation, and that the name of
24
- # Secret Labs AB or the author not be used in advertising or publicity
25
- # pertaining to distribution of the software without specific, written
26
- # prior permission.
27
- #
28
- # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
29
- # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
30
- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
31
- # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
32
- # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
33
- # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
34
- # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
35
- # OF THIS SOFTWARE.
36
- # --------------------------------------------------------------------
37
-
38
- """
39
- The ``E`` Element factory for generating XML documents.
40
- """
41
-
42
-
43
- import lxml.etree as ET
44
- _QName = ET.QName
45
-
46
- from functools import partial
47
-
48
- try:
49
- basestring
50
- except NameError:
51
- basestring = str
52
-
53
- try:
54
- unicode
55
- except NameError:
56
- unicode = str
57
-
58
-
59
- class ElementMaker:
60
- """Element generator factory.
61
-
62
- Unlike the ordinary Element factory, the E factory allows you to pass in
63
- more than just a tag and some optional attributes; you can also pass in
64
- text and other elements. The text is added as either text or tail
65
- attributes, and elements are inserted at the right spot. Some small
66
- examples::
67
-
68
- >>> from lxml import etree as ET
69
- >>> from lxml.builder import E
70
-
71
- >>> ET.tostring(E("tag"))
72
- '<tag/>'
73
- >>> ET.tostring(E("tag", "text"))
74
- '<tag>text</tag>'
75
- >>> ET.tostring(E("tag", "text", key="value"))
76
- '<tag key="value">text</tag>'
77
- >>> ET.tostring(E("tag", E("subtag", "text"), "tail"))
78
- '<tag><subtag>text</subtag>tail</tag>'
79
-
80
- For simple tags, the factory also allows you to write ``E.tag(...)`` instead
81
- of ``E('tag', ...)``::
82
-
83
- >>> ET.tostring(E.tag())
84
- '<tag/>'
85
- >>> ET.tostring(E.tag("text"))
86
- '<tag>text</tag>'
87
- >>> ET.tostring(E.tag(E.subtag("text"), "tail"))
88
- '<tag><subtag>text</subtag>tail</tag>'
89
-
90
- Here's a somewhat larger example; this shows how to generate HTML
91
- documents, using a mix of prepared factory functions for inline elements,
92
- nested ``E.tag`` calls, and embedded XHTML fragments::
93
-
94
- # some common inline elements
95
- A = E.a
96
- I = E.i
97
- B = E.b
98
-
99
- def CLASS(v):
100
- # helper function, 'class' is a reserved word
101
- return {'class': v}
102
-
103
- page = (
104
- E.html(
105
- E.head(
106
- E.title("This is a sample document")
107
- ),
108
- E.body(
109
- E.h1("Hello!", CLASS("title")),
110
- E.p("This is a paragraph with ", B("bold"), " text in it!"),
111
- E.p("This is another paragraph, with a ",
112
- A("link", href="http://www.python.org"), "."),
113
- E.p("Here are some reserved characters: <spam&egg>."),
114
- ET.XML("<p>And finally, here is an embedded XHTML fragment.</p>"),
115
- )
116
- )
117
- )
118
-
119
- print ET.tostring(page)
120
-
121
- Here's a prettyprinted version of the output from the above script::
122
-
123
- <html>
124
- <head>
125
- <title>This is a sample document</title>
126
- </head>
127
- <body>
128
- <h1 class="title">Hello!</h1>
129
- <p>This is a paragraph with <b>bold</b> text in it!</p>
130
- <p>This is another paragraph, with <a href="http://www.python.org">link</a>.</p>
131
- <p>Here are some reserved characters: &lt;spam&amp;egg&gt;.</p>
132
- <p>And finally, here is an embedded XHTML fragment.</p>
133
- </body>
134
- </html>
135
-
136
- For namespace support, you can pass a namespace map (``nsmap``)
137
- and/or a specific target ``namespace`` to the ElementMaker class::
138
-
139
- >>> E = ElementMaker(namespace="http://my.ns/")
140
- >>> print(ET.tostring( E.test ))
141
- <test xmlns="http://my.ns/"/>
142
-
143
- >>> E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})
144
- >>> print(ET.tostring( E.test ))
145
- <p:test xmlns:p="http://my.ns/"/>
146
- """
147
-
148
- def __init__(self, typemap=None,
149
- namespace=None, nsmap=None, makeelement=None):
150
- self._namespace = '{' + namespace + '}' if namespace is not None else None
151
- self._nsmap = dict(nsmap) if nsmap else None
152
-
153
- assert makeelement is None or callable(makeelement)
154
- self._makeelement = makeelement if makeelement is not None else ET.Element
155
-
156
- # initialize the default type map functions for this element factory
157
- typemap = dict(typemap) if typemap else {}
158
-
159
- def add_text(elem, item):
160
- try:
161
- last_child = elem[-1]
162
- except IndexError:
163
- elem.text = (elem.text or "") + item
164
- else:
165
- last_child.tail = (last_child.tail or "") + item
166
-
167
- def add_cdata(elem, cdata):
168
- if elem.text:
169
- raise ValueError("Can't add a CDATA section. Element already has some text: %r" % elem.text)
170
- elem.text = cdata
171
-
172
- if str not in typemap:
173
- typemap[str] = add_text
174
- if unicode not in typemap:
175
- typemap[unicode] = add_text
176
- if ET.CDATA not in typemap:
177
- typemap[ET.CDATA] = add_cdata
178
-
179
- def add_dict(elem, item):
180
- attrib = elem.attrib
181
- for k, v in item.items():
182
- if isinstance(v, basestring):
183
- attrib[k] = v
184
- else:
185
- attrib[k] = typemap[type(v)](None, v)
186
-
187
- if dict not in typemap:
188
- typemap[dict] = add_dict
189
-
190
- self._typemap = typemap
191
-
192
- def __call__(self, tag, *children, **attrib):
193
- typemap = self._typemap
194
-
195
- # We'll usually get a 'str', and the compiled type check is very fast.
196
- if not isinstance(tag, str) and isinstance(tag, _QName):
197
- # A QName is explicitly qualified, do not look at self._namespace.
198
- tag = tag.text
199
- elif self._namespace is not None and tag[0] != '{':
200
- tag = self._namespace + tag
201
- elem = self._makeelement(tag, nsmap=self._nsmap)
202
- if attrib:
203
- typemap[dict](elem, attrib)
204
-
205
- for item in children:
206
- if callable(item):
207
- item = item()
208
- t = typemap.get(type(item))
209
- if t is None:
210
- if ET.iselement(item):
211
- elem.append(item)
212
- continue
213
- for basetype in type(item).__mro__:
214
- # See if the typemap knows of any of this type's bases.
215
- t = typemap.get(basetype)
216
- if t is not None:
217
- break
218
- else:
219
- raise TypeError("bad argument type: %s(%r)" %
220
- (type(item).__name__, item))
221
- v = t(elem, item)
222
- if v:
223
- typemap.get(type(v))(elem, v)
224
-
225
- return elem
226
-
227
- def __getattr__(self, tag):
228
- return partial(self, tag)
229
-
230
-
231
- # create factory object
232
- E = ElementMaker()
1
+ # cython: language_level=2
2
+
3
+ #
4
+ # Element generator factory by Fredrik Lundh.
5
+ #
6
+ # Source:
7
+ # http://online.effbot.org/2006_11_01_archive.htm#et-builder
8
+ # http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py
9
+ #
10
+ # --------------------------------------------------------------------
11
+ # The ElementTree toolkit is
12
+ #
13
+ # Copyright (c) 1999-2004 by Fredrik Lundh
14
+ #
15
+ # By obtaining, using, and/or copying this software and/or its
16
+ # associated documentation, you agree that you have read, understood,
17
+ # and will comply with the following terms and conditions:
18
+ #
19
+ # Permission to use, copy, modify, and distribute this software and
20
+ # its associated documentation for any purpose and without fee is
21
+ # hereby granted, provided that the above copyright notice appears in
22
+ # all copies, and that both that copyright notice and this permission
23
+ # notice appear in supporting documentation, and that the name of
24
+ # Secret Labs AB or the author not be used in advertising or publicity
25
+ # pertaining to distribution of the software without specific, written
26
+ # prior permission.
27
+ #
28
+ # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
29
+ # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
30
+ # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
31
+ # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
32
+ # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
33
+ # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
34
+ # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
35
+ # OF THIS SOFTWARE.
36
+ # --------------------------------------------------------------------
37
+
38
+ """
39
+ The ``E`` Element factory for generating XML documents.
40
+ """
41
+
42
+
43
+ import lxml.etree as ET
44
+ _QName = ET.QName
45
+
46
+ from functools import partial
47
+
48
+ try:
49
+ basestring
50
+ except NameError:
51
+ basestring = str
52
+
53
+ try:
54
+ unicode
55
+ except NameError:
56
+ unicode = str
57
+
58
+
59
+ class ElementMaker:
60
+ """Element generator factory.
61
+
62
+ Unlike the ordinary Element factory, the E factory allows you to pass in
63
+ more than just a tag and some optional attributes; you can also pass in
64
+ text and other elements. The text is added as either text or tail
65
+ attributes, and elements are inserted at the right spot. Some small
66
+ examples::
67
+
68
+ >>> from lxml import etree as ET
69
+ >>> from lxml.builder import E
70
+
71
+ >>> ET.tostring(E("tag"))
72
+ '<tag/>'
73
+ >>> ET.tostring(E("tag", "text"))
74
+ '<tag>text</tag>'
75
+ >>> ET.tostring(E("tag", "text", key="value"))
76
+ '<tag key="value">text</tag>'
77
+ >>> ET.tostring(E("tag", E("subtag", "text"), "tail"))
78
+ '<tag><subtag>text</subtag>tail</tag>'
79
+
80
+ For simple tags, the factory also allows you to write ``E.tag(...)`` instead
81
+ of ``E('tag', ...)``::
82
+
83
+ >>> ET.tostring(E.tag())
84
+ '<tag/>'
85
+ >>> ET.tostring(E.tag("text"))
86
+ '<tag>text</tag>'
87
+ >>> ET.tostring(E.tag(E.subtag("text"), "tail"))
88
+ '<tag><subtag>text</subtag>tail</tag>'
89
+
90
+ Here's a somewhat larger example; this shows how to generate HTML
91
+ documents, using a mix of prepared factory functions for inline elements,
92
+ nested ``E.tag`` calls, and embedded XHTML fragments::
93
+
94
+ # some common inline elements
95
+ A = E.a
96
+ I = E.i
97
+ B = E.b
98
+
99
+ def CLASS(v):
100
+ # helper function, 'class' is a reserved word
101
+ return {'class': v}
102
+
103
+ page = (
104
+ E.html(
105
+ E.head(
106
+ E.title("This is a sample document")
107
+ ),
108
+ E.body(
109
+ E.h1("Hello!", CLASS("title")),
110
+ E.p("This is a paragraph with ", B("bold"), " text in it!"),
111
+ E.p("This is another paragraph, with a ",
112
+ A("link", href="http://www.python.org"), "."),
113
+ E.p("Here are some reserved characters: <spam&egg>."),
114
+ ET.XML("<p>And finally, here is an embedded XHTML fragment.</p>"),
115
+ )
116
+ )
117
+ )
118
+
119
+ print ET.tostring(page)
120
+
121
+ Here's a prettyprinted version of the output from the above script::
122
+
123
+ <html>
124
+ <head>
125
+ <title>This is a sample document</title>
126
+ </head>
127
+ <body>
128
+ <h1 class="title">Hello!</h1>
129
+ <p>This is a paragraph with <b>bold</b> text in it!</p>
130
+ <p>This is another paragraph, with <a href="http://www.python.org">link</a>.</p>
131
+ <p>Here are some reserved characters: &lt;spam&amp;egg&gt;.</p>
132
+ <p>And finally, here is an embedded XHTML fragment.</p>
133
+ </body>
134
+ </html>
135
+
136
+ For namespace support, you can pass a namespace map (``nsmap``)
137
+ and/or a specific target ``namespace`` to the ElementMaker class::
138
+
139
+ >>> E = ElementMaker(namespace="http://my.ns/")
140
+ >>> print(ET.tostring( E.test ))
141
+ <test xmlns="http://my.ns/"/>
142
+
143
+ >>> E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})
144
+ >>> print(ET.tostring( E.test ))
145
+ <p:test xmlns:p="http://my.ns/"/>
146
+ """
147
+
148
+ def __init__(self, typemap=None,
149
+ namespace=None, nsmap=None, makeelement=None):
150
+ self._namespace = '{' + namespace + '}' if namespace is not None else None
151
+ self._nsmap = dict(nsmap) if nsmap else None
152
+
153
+ assert makeelement is None or callable(makeelement)
154
+ self._makeelement = makeelement if makeelement is not None else ET.Element
155
+
156
+ # initialize the default type map functions for this element factory
157
+ typemap = dict(typemap) if typemap else {}
158
+
159
+ def add_text(elem, item):
160
+ try:
161
+ last_child = elem[-1]
162
+ except IndexError:
163
+ elem.text = (elem.text or "") + item
164
+ else:
165
+ last_child.tail = (last_child.tail or "") + item
166
+
167
+ def add_cdata(elem, cdata):
168
+ if elem.text:
169
+ raise ValueError("Can't add a CDATA section. Element already has some text: %r" % elem.text)
170
+ elem.text = cdata
171
+
172
+ if str not in typemap:
173
+ typemap[str] = add_text
174
+ if unicode not in typemap:
175
+ typemap[unicode] = add_text
176
+ if ET.CDATA not in typemap:
177
+ typemap[ET.CDATA] = add_cdata
178
+
179
+ def add_dict(elem, item):
180
+ attrib = elem.attrib
181
+ for k, v in item.items():
182
+ if isinstance(v, basestring):
183
+ attrib[k] = v
184
+ else:
185
+ attrib[k] = typemap[type(v)](None, v)
186
+
187
+ if dict not in typemap:
188
+ typemap[dict] = add_dict
189
+
190
+ self._typemap = typemap
191
+
192
+ def __call__(self, tag, *children, **attrib):
193
+ typemap = self._typemap
194
+
195
+ # We'll usually get a 'str', and the compiled type check is very fast.
196
+ if not isinstance(tag, str) and isinstance(tag, _QName):
197
+ # A QName is explicitly qualified, do not look at self._namespace.
198
+ tag = tag.text
199
+ elif self._namespace is not None and tag[0] != '{':
200
+ tag = self._namespace + tag
201
+ elem = self._makeelement(tag, nsmap=self._nsmap)
202
+ if attrib:
203
+ typemap[dict](elem, attrib)
204
+
205
+ for item in children:
206
+ if callable(item):
207
+ item = item()
208
+ t = typemap.get(type(item))
209
+ if t is None:
210
+ if ET.iselement(item):
211
+ elem.append(item)
212
+ continue
213
+ for basetype in type(item).__mro__:
214
+ # See if the typemap knows of any of this type's bases.
215
+ t = typemap.get(basetype)
216
+ if t is not None:
217
+ break
218
+ else:
219
+ raise TypeError("bad argument type: %s(%r)" %
220
+ (type(item).__name__, item))
221
+ v = t(elem, item)
222
+ if v:
223
+ typemap.get(type(v))(elem, v)
224
+
225
+ return elem
226
+
227
+ def __getattr__(self, tag):
228
+ return partial(self, tag)
229
+
230
+
231
+ # create factory object
232
+ E = ElementMaker()