assassinlike commited on
Commit
dcd2b44
·
verified ·
1 Parent(s): a687fd8

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/licenses/AUTHORS +7 -0
  2. data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/licenses/LICENSE +202 -0
  3. data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/licenses/LICENSE.txt +13 -0
  4. data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/licenses/vendor/llhttp/LICENSE +22 -0
  5. data/conda_envs/evalclaw/lib/python3.11/site-packages/annotated_doc-0.0.4.dist-info/licenses/LICENSE +21 -0
  6. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/__init__.cpython-311.pyc +0 -0
  7. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/_deprecation.cpython-311.pyc +0 -0
  8. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/_typing.cpython-311.pyc +0 -0
  9. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/_warnings.cpython-311.pyc +0 -0
  10. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/css.cpython-311.pyc +0 -0
  11. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/dammit.cpython-311.pyc +0 -0
  12. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/diagnose.cpython-311.pyc +0 -0
  13. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/exceptions.cpython-311.pyc +0 -0
  14. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/filter.cpython-311.pyc +0 -0
  15. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/formatter.cpython-311.pyc +0 -0
  16. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__init__.py +848 -0
  17. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/__init__.cpython-311.pyc +0 -0
  18. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/_html5lib.cpython-311.pyc +0 -0
  19. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/_htmlparser.cpython-311.pyc +0 -0
  20. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/_lxml.cpython-311.pyc +0 -0
  21. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/_html5lib.py +611 -0
  22. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/_htmlparser.py +462 -0
  23. data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/_lxml.py +501 -0
  24. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/__init__.cpython-311.pyc +0 -0
  25. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_api.cpython-311.pyc +0 -0
  26. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_async_read_write.cpython-311.pyc +0 -0
  27. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_error.cpython-311.pyc +0 -0
  28. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_read_write.cpython-311.pyc +0 -0
  29. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_soft.cpython-311.pyc +0 -0
  30. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_unix.cpython-311.pyc +0 -0
  31. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_util.cpython-311.pyc +0 -0
  32. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_windows.cpython-311.pyc +0 -0
  33. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/asyncio.cpython-311.pyc +0 -0
  34. data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/version.cpython-311.pyc +0 -0
  35. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/__pycache__/__init__.cpython-311.pyc +0 -0
  36. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/__init__.py +0 -0
  37. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/__pycache__/__init__.cpython-311.pyc +0 -0
  38. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/aot_autograd/__init__.py +8 -0
  39. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/aot_autograd/__pycache__/__init__.cpython-311.pyc +0 -0
  40. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/eager_transforms/__init__.py +7 -0
  41. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/eager_transforms/__pycache__/__init__.cpython-311.pyc +0 -0
  42. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/make_functional/__init__.py +4 -0
  43. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/make_functional/__pycache__/__init__.cpython-311.pyc +0 -0
  44. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/vmap/__init__.py +16 -0
  45. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/vmap/__pycache__/__init__.cpython-311.pyc +0 -0
  46. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/compile/__init__.py +30 -0
  47. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/compile/__pycache__/__init__.cpython-311.pyc +0 -0
  48. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/dim/__init__.py +181 -0
  49. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/dim/__pycache__/__init__.cpython-311.pyc +0 -0
  50. data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/dim/__pycache__/batch_tensor.cpython-311.pyc +0 -0
data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/licenses/AUTHORS ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # This is the list of Abseil authors for copyright purposes.
2
+ #
3
+ # This does not necessarily list everyone who has contributed code, since in
4
+ # some cases, their employer may be the copyright holder. To see the full list
5
+ # of contributors, see the revision history in source control.
6
+
7
+ Google Inc.
data/conda_envs/evalclaw/lib/python3.11/site-packages/absl_py-2.4.0.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/licenses/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright aio-libs contributors.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/conda_envs/evalclaw/lib/python3.11/site-packages/aiohttp-3.13.3.dist-info/licenses/vendor/llhttp/LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This software is licensed under the MIT License.
2
+
3
+ Copyright Fedor Indutny, 2018.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a
6
+ copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to permit
10
+ persons to whom the Software is furnished to do so, subject to the
11
+ following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included
14
+ in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
data/conda_envs/evalclaw/lib/python3.11/site-packages/annotated_doc-0.0.4.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Sebastián Ramírez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (42.9 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/_deprecation.cpython-311.pyc ADDED
Binary file (4.17 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/_typing.cpython-311.pyc ADDED
Binary file (4.63 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/_warnings.cpython-311.pyc ADDED
Binary file (5.99 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/css.cpython-311.pyc ADDED
Binary file (14.6 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/dammit.cpython-311.pyc ADDED
Binary file (51.5 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/diagnose.cpython-311.pyc ADDED
Binary file (14.4 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/exceptions.cpython-311.pyc ADDED
Binary file (2.1 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/filter.cpython-311.pyc ADDED
Binary file (31.1 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/__pycache__/formatter.cpython-311.pyc ADDED
Binary file (11.1 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__init__.py ADDED
@@ -0,0 +1,848 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ # Use of this source code is governed by the MIT license.
4
+ __license__ = "MIT"
5
+
6
+ from collections import defaultdict
7
+ import re
8
+ from types import ModuleType
9
+ from typing import (
10
+ Any,
11
+ cast,
12
+ Dict,
13
+ Iterable,
14
+ List,
15
+ Optional,
16
+ Pattern,
17
+ Set,
18
+ Tuple,
19
+ Type,
20
+ TYPE_CHECKING,
21
+ )
22
+ import warnings
23
+ import sys
24
+ from bs4.element import (
25
+ AttributeDict,
26
+ AttributeValueList,
27
+ CharsetMetaAttributeValue,
28
+ ContentMetaAttributeValue,
29
+ RubyParenthesisString,
30
+ RubyTextString,
31
+ Stylesheet,
32
+ Script,
33
+ TemplateString,
34
+ nonwhitespace_re,
35
+ )
36
+
37
+ # Exceptions were moved to their own module in 4.13. Import here for
38
+ # backwards compatibility.
39
+ from bs4.exceptions import ParserRejectedMarkup
40
+
41
+ from bs4._typing import (
42
+ _AttributeValues,
43
+ _RawAttributeValue,
44
+ )
45
+
46
+ from bs4._warnings import XMLParsedAsHTMLWarning
47
+
48
+ if TYPE_CHECKING:
49
+ from bs4 import BeautifulSoup
50
+ from bs4.element import (
51
+ NavigableString,
52
+ Tag,
53
+ )
54
+ from bs4._typing import (
55
+ _AttributeValue,
56
+ _Encoding,
57
+ _Encodings,
58
+ _RawOrProcessedAttributeValues,
59
+ _RawMarkup,
60
+ )
61
+
62
+ __all__ = [
63
+ "HTMLTreeBuilder",
64
+ "SAXTreeBuilder",
65
+ "TreeBuilder",
66
+ "TreeBuilderRegistry",
67
+ ]
68
+
69
+ # Some useful features for a TreeBuilder to have.
70
+ FAST = "fast"
71
+ PERMISSIVE = "permissive"
72
+ STRICT = "strict"
73
+ XML = "xml"
74
+ HTML = "html"
75
+ HTML_5 = "html5"
76
+
77
+ __all__ = [
78
+ "TreeBuilderRegistry",
79
+ "TreeBuilder",
80
+ "HTMLTreeBuilder",
81
+ "DetectsXMLParsedAsHTML",
82
+
83
+ "ParserRejectedMarkup", # backwards compatibility only as of 4.13.0
84
+ ]
85
+
86
+ class TreeBuilderRegistry(object):
87
+ """A way of looking up TreeBuilder subclasses by their name or by desired
88
+ features.
89
+ """
90
+
91
+ builders_for_feature: Dict[str, List[Type[TreeBuilder]]]
92
+ builders: List[Type[TreeBuilder]]
93
+
94
+ def __init__(self) -> None:
95
+ self.builders_for_feature = defaultdict(list)
96
+ self.builders = []
97
+
98
+ def register(self, treebuilder_class: type[TreeBuilder]) -> None:
99
+ """Register a treebuilder based on its advertised features.
100
+
101
+ :param treebuilder_class: A subclass of `TreeBuilder`. its
102
+ `TreeBuilder.features` attribute should list its features.
103
+ """
104
+ for feature in treebuilder_class.features:
105
+ self.builders_for_feature[feature].insert(0, treebuilder_class)
106
+ self.builders.insert(0, treebuilder_class)
107
+
108
+ def lookup(self, *features: str) -> Optional[Type[TreeBuilder]]:
109
+ """Look up a TreeBuilder subclass with the desired features.
110
+
111
+ :param features: A list of features to look for. If none are
112
+ provided, the most recently registered TreeBuilder subclass
113
+ will be used.
114
+ :return: A TreeBuilder subclass, or None if there's no
115
+ registered subclass with all the requested features.
116
+ """
117
+ if len(self.builders) == 0:
118
+ # There are no builders at all.
119
+ return None
120
+
121
+ if len(features) == 0:
122
+ # They didn't ask for any features. Give them the most
123
+ # recently registered builder.
124
+ return self.builders[0]
125
+
126
+ # Go down the list of features in order, and eliminate any builders
127
+ # that don't match every feature.
128
+ feature_list = list(features)
129
+ feature_list.reverse()
130
+ candidates = None
131
+ candidate_set = None
132
+ while len(feature_list) > 0:
133
+ feature = feature_list.pop()
134
+ we_have_the_feature = self.builders_for_feature.get(feature, [])
135
+ if len(we_have_the_feature) > 0:
136
+ if candidates is None:
137
+ candidates = we_have_the_feature
138
+ candidate_set = set(candidates)
139
+ elif candidate_set is not None:
140
+ # Eliminate any candidates that don't have this feature.
141
+ candidate_set = candidate_set.intersection(set(we_have_the_feature))
142
+
143
+ # The only valid candidates are the ones in candidate_set.
144
+ # Go through the original list of candidates and pick the first one
145
+ # that's in candidate_set.
146
+ if candidate_set is None or candidates is None:
147
+ return None
148
+ for candidate in candidates:
149
+ if candidate in candidate_set:
150
+ return candidate
151
+ return None
152
+
153
+
154
+ #: The `BeautifulSoup` constructor will take a list of features
155
+ #: and use it to look up `TreeBuilder` classes in this registry.
156
+ builder_registry: TreeBuilderRegistry = TreeBuilderRegistry()
157
+
158
+
159
+ class TreeBuilder(object):
160
+ """Turn a textual document into a Beautiful Soup object tree.
161
+
162
+ This is an abstract superclass which smooths out the behavior of
163
+ different parser libraries into a single, unified interface.
164
+
165
+ :param multi_valued_attributes: If this is set to None, the
166
+ TreeBuilder will not turn any values for attributes like
167
+ 'class' into lists. Setting this to a dictionary will
168
+ customize this behavior; look at :py:attr:`bs4.builder.HTMLTreeBuilder.DEFAULT_CDATA_LIST_ATTRIBUTES`
169
+ for an example.
170
+
171
+ Internally, these are called "CDATA list attributes", but that
172
+ probably doesn't make sense to an end-user, so the argument name
173
+ is ``multi_valued_attributes``.
174
+
175
+ :param preserve_whitespace_tags: A set of tags to treat
176
+ the way <pre> tags are treated in HTML. Tags in this set
177
+ are immune from pretty-printing; their contents will always be
178
+ output as-is.
179
+
180
+ :param string_containers: A dictionary mapping tag names to
181
+ the classes that should be instantiated to contain the textual
182
+ contents of those tags. The default is to use NavigableString
183
+ for every tag, no matter what the name. You can override the
184
+ default by changing :py:attr:`DEFAULT_STRING_CONTAINERS`.
185
+
186
+ :param store_line_numbers: If the parser keeps track of the line
187
+ numbers and positions of the original markup, that information
188
+ will, by default, be stored in each corresponding
189
+ :py:class:`bs4.element.Tag` object. You can turn this off by
190
+ passing store_line_numbers=False; then Tag.sourcepos and
191
+ Tag.sourceline will always be None. If the parser you're using
192
+ doesn't keep track of this information, then store_line_numbers
193
+ is irrelevant.
194
+
195
+ :param attribute_dict_class: The value of a multi-valued attribute
196
+ (such as HTML's 'class') willl be stored in an instance of this
197
+ class. The default is Beautiful Soup's built-in
198
+ `AttributeValueList`, which is a normal Python list, and you
199
+ will probably never need to change it.
200
+ """
201
+
202
+ USE_DEFAULT: Any = object() #: :meta private:
203
+
204
+ def __init__(
205
+ self,
206
+ multi_valued_attributes: Dict[str, Set[str]] = USE_DEFAULT,
207
+ preserve_whitespace_tags: Set[str] = USE_DEFAULT,
208
+ store_line_numbers: bool = USE_DEFAULT,
209
+ string_containers: Dict[str, Type[NavigableString]] = USE_DEFAULT,
210
+ empty_element_tags: Set[str] = USE_DEFAULT,
211
+ attribute_dict_class: Type[AttributeDict] = AttributeDict,
212
+ attribute_value_list_class: Type[AttributeValueList] = AttributeValueList,
213
+ ):
214
+ self.soup = None
215
+ if multi_valued_attributes is self.USE_DEFAULT:
216
+ multi_valued_attributes = self.DEFAULT_CDATA_LIST_ATTRIBUTES
217
+ self.cdata_list_attributes = multi_valued_attributes
218
+ if preserve_whitespace_tags is self.USE_DEFAULT:
219
+ preserve_whitespace_tags = self.DEFAULT_PRESERVE_WHITESPACE_TAGS
220
+ self.preserve_whitespace_tags = preserve_whitespace_tags
221
+ if empty_element_tags is self.USE_DEFAULT:
222
+ self.empty_element_tags = self.DEFAULT_EMPTY_ELEMENT_TAGS
223
+ else:
224
+ self.empty_element_tags = empty_element_tags
225
+ # TODO: store_line_numbers is probably irrelevant now that
226
+ # the behavior of sourceline and sourcepos has been made consistent
227
+ # everywhere.
228
+ if store_line_numbers == self.USE_DEFAULT:
229
+ store_line_numbers = self.TRACKS_LINE_NUMBERS
230
+ self.store_line_numbers = store_line_numbers
231
+ if string_containers == self.USE_DEFAULT:
232
+ string_containers = self.DEFAULT_STRING_CONTAINERS
233
+ self.string_containers = string_containers
234
+ self.attribute_dict_class = attribute_dict_class
235
+ self.attribute_value_list_class = attribute_value_list_class
236
+
237
+ NAME: str = "[Unknown tree builder]"
238
+ ALTERNATE_NAMES: Iterable[str] = []
239
+ features: Iterable[str] = []
240
+
241
+ is_xml: bool = False
242
+ picklable: bool = False
243
+
244
+ soup: Optional[BeautifulSoup] #: :meta private:
245
+
246
+ #: A tag will be considered an empty-element
247
+ #: tag when and only when it has no contents.
248
+ empty_element_tags: Optional[Set[str]] = None #: :meta private:
249
+ cdata_list_attributes: Dict[str, Set[str]] #: :meta private:
250
+ preserve_whitespace_tags: Set[str] #: :meta private:
251
+ string_containers: Dict[str, Type[NavigableString]] #: :meta private:
252
+ tracks_line_numbers: bool #: :meta private:
253
+
254
+ #: A value for these tag/attribute combinations is a space- or
255
+ #: comma-separated list of CDATA, rather than a single CDATA.
256
+ DEFAULT_CDATA_LIST_ATTRIBUTES: Dict[str, Set[str]] = defaultdict(set)
257
+
258
+ #: Whitespace should be preserved inside these tags.
259
+ DEFAULT_PRESERVE_WHITESPACE_TAGS: Set[str] = set()
260
+
261
+ #: The textual contents of tags with these names should be
262
+ #: instantiated with some class other than `bs4.element.NavigableString`.
263
+ DEFAULT_STRING_CONTAINERS: Dict[str, Type[bs4.element.NavigableString]] = {} # type:ignore
264
+
265
+ #: By default, tags are treated as empty-element tags if they have
266
+ #: no contents--that is, using XML rules. HTMLTreeBuilder
267
+ #: defines a different set of DEFAULT_EMPTY_ELEMENT_TAGS based on the
268
+ #: HTML 4 and HTML5 standards.
269
+ DEFAULT_EMPTY_ELEMENT_TAGS: Optional[Set[str]] = None
270
+
271
+ #: Most parsers don't keep track of line numbers.
272
+ TRACKS_LINE_NUMBERS: bool = False
273
+
274
+ def initialize_soup(self, soup: BeautifulSoup) -> None:
275
+ """The BeautifulSoup object has been initialized and is now
276
+ being associated with the TreeBuilder.
277
+
278
+ :param soup: A BeautifulSoup object.
279
+ """
280
+ self.soup = soup
281
+
282
+ def reset(self) -> None:
283
+ """Do any work necessary to reset the underlying parser
284
+ for a new document.
285
+
286
+ By default, this does nothing.
287
+ """
288
+ pass
289
+
290
+ def can_be_empty_element(self, tag_name: str) -> bool:
291
+ """Might a tag with this name be an empty-element tag?
292
+
293
+ The final markup may or may not actually present this tag as
294
+ self-closing.
295
+
296
+ For instance: an HTMLBuilder does not consider a <p> tag to be
297
+ an empty-element tag (it's not in
298
+ HTMLBuilder.empty_element_tags). This means an empty <p> tag
299
+ will be presented as "<p></p>", not "<p/>" or "<p>".
300
+
301
+ The default implementation has no opinion about which tags are
302
+ empty-element tags, so a tag will be presented as an
303
+ empty-element tag if and only if it has no children.
304
+ "<foo></foo>" will become "<foo/>", and "<foo>bar</foo>" will
305
+ be left alone.
306
+
307
+ :param tag_name: The name of a markup tag.
308
+ """
309
+ if self.empty_element_tags is None:
310
+ return True
311
+ return tag_name in self.empty_element_tags
312
+
313
+ def feed(self, markup: _RawMarkup) -> None:
314
+ """Run incoming markup through some parsing process."""
315
+ raise NotImplementedError()
316
+
317
+ def prepare_markup(
318
+ self,
319
+ markup: _RawMarkup,
320
+ user_specified_encoding: Optional[_Encoding] = None,
321
+ document_declared_encoding: Optional[_Encoding] = None,
322
+ exclude_encodings: Optional[_Encodings] = None,
323
+ ) -> Iterable[Tuple[_RawMarkup, Optional[_Encoding], Optional[_Encoding], bool]]:
324
+ """Run any preliminary steps necessary to make incoming markup
325
+ acceptable to the parser.
326
+
327
+ :param markup: The markup that's about to be parsed.
328
+ :param user_specified_encoding: The user asked to try this encoding
329
+ to convert the markup into a Unicode string.
330
+ :param document_declared_encoding: The markup itself claims to be
331
+ in this encoding. NOTE: This argument is not used by the
332
+ calling code and can probably be removed.
333
+ :param exclude_encodings: The user asked *not* to try any of
334
+ these encodings.
335
+
336
+ :yield: A series of 4-tuples: (markup, encoding, declared encoding,
337
+ has undergone character replacement)
338
+
339
+ Each 4-tuple represents a strategy that the parser can try
340
+ to convert the document to Unicode and parse it. Each
341
+ strategy will be tried in turn.
342
+
343
+ By default, the only strategy is to parse the markup
344
+ as-is. See `LXMLTreeBuilderForXML` and
345
+ `HTMLParserTreeBuilder` for implementations that take into
346
+ account the quirks of particular parsers.
347
+
348
+ :meta private:
349
+
350
+ """
351
+ yield markup, None, None, False
352
+
353
+ def test_fragment_to_document(self, fragment: str) -> str:
354
+ """Wrap an HTML fragment to make it look like a document.
355
+
356
+ Different parsers do this differently. For instance, lxml
357
+ introduces an empty <head> tag, and html5lib
358
+ doesn't. Abstracting this away lets us write simple tests
359
+ which run HTML fragments through the parser and compare the
360
+ results against other HTML fragments.
361
+
362
+ This method should not be used outside of unit tests.
363
+
364
+ :param fragment: A fragment of HTML.
365
+ :return: A full HTML document.
366
+ :meta private:
367
+ """
368
+ return fragment
369
+
370
+ def set_up_substitutions(self, tag: Tag) -> bool:
371
+ """Set up any substitutions that will need to be performed on
372
+ a `Tag` when it's output as a string.
373
+
374
+ By default, this does nothing. See `HTMLTreeBuilder` for a
375
+ case where this is used.
376
+
377
+ :return: Whether or not a substitution was performed.
378
+ :meta private:
379
+ """
380
+ return False
381
+
382
+ def _replace_cdata_list_attribute_values(
383
+ self, tag_name: str, attrs: _RawOrProcessedAttributeValues
384
+ ) -> _AttributeValues:
385
+ """When an attribute value is associated with a tag that can
386
+ have multiple values for that attribute, convert the string
387
+ value to a list of strings.
388
+
389
+ Basically, replaces class="foo bar" with class=["foo", "bar"]
390
+
391
+ NOTE: This method modifies its input in place.
392
+
393
+ :param tag_name: The name of a tag.
394
+ :param attrs: A dictionary containing the tag's attributes.
395
+ Any appropriate attribute values will be modified in place.
396
+ :return: The modified dictionary that was originally passed in.
397
+ """
398
+
399
+ # First, cast the attrs dict to _AttributeValues. This might
400
+ # not be accurate yet, but it will be by the time this method
401
+ # returns.
402
+ modified_attrs = cast(_AttributeValues, attrs)
403
+ if not modified_attrs or not self.cdata_list_attributes:
404
+ # Nothing to do.
405
+ return modified_attrs
406
+
407
+ # There is at least a possibility that we need to modify one of
408
+ # the attribute values.
409
+ universal: Set[str] = self.cdata_list_attributes.get("*", set())
410
+ tag_specific = self.cdata_list_attributes.get(tag_name.lower(), None)
411
+ for attr in list(modified_attrs.keys()):
412
+ modified_value: _AttributeValue
413
+ if attr in universal or (tag_specific and attr in tag_specific):
414
+ # We have a "class"-type attribute whose string
415
+ # value is a whitespace-separated list of
416
+ # values. Split it into a list.
417
+ original_value: _AttributeValue = modified_attrs[attr]
418
+ if isinstance(original_value, _RawAttributeValue):
419
+ # This is a _RawAttributeValue (a string) that
420
+ # needs to be split and converted to a
421
+ # AttributeValueList so it can be an
422
+ # _AttributeValue.
423
+ modified_value = self.attribute_value_list_class(
424
+ nonwhitespace_re.findall(original_value)
425
+ )
426
+ else:
427
+ # html5lib calls setAttributes twice for the
428
+ # same tag when rearranging the parse tree. On
429
+ # the second call the attribute value here is
430
+ # already a list. This can also happen when a
431
+ # Tag object is cloned. If this happens, leave
432
+ # the value alone rather than trying to split
433
+ # it again.
434
+ modified_value = original_value
435
+ modified_attrs[attr] = modified_value
436
+ return modified_attrs
437
+
438
+
439
+ class SAXTreeBuilder(TreeBuilder):
440
+ """A Beautiful Soup treebuilder that listens for SAX events.
441
+
442
+ This is not currently used for anything, and it will be removed
443
+ soon. It was a good idea, but it wasn't properly integrated into the
444
+ rest of Beautiful Soup, so there have been long stretches where it
445
+ hasn't worked properly.
446
+ """
447
+
448
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
449
+ warnings.warn(
450
+ "The SAXTreeBuilder class was deprecated in 4.13.0 and will be removed soon thereafter. It is completely untested and probably doesn't work; do not use it.",
451
+ DeprecationWarning,
452
+ stacklevel=2,
453
+ )
454
+ super(SAXTreeBuilder, self).__init__(*args, **kwargs)
455
+
456
+ def feed(self, markup: _RawMarkup) -> None:
457
+ raise NotImplementedError()
458
+
459
+ def close(self) -> None:
460
+ pass
461
+
462
+ def startElement(self, name: str, attrs: Dict[str, str]) -> None:
463
+ attrs = AttributeDict((key[1], value) for key, value in list(attrs.items()))
464
+ # print("Start %s, %r" % (name, attrs))
465
+ assert self.soup is not None
466
+ self.soup.handle_starttag(name, None, None, attrs)
467
+
468
+ def endElement(self, name: str) -> None:
469
+ # print("End %s" % name)
470
+ assert self.soup is not None
471
+ self.soup.handle_endtag(name)
472
+
473
+ def startElementNS(
474
+ self, nsTuple: Tuple[str, str], nodeName: str, attrs: Dict[str, str]
475
+ ) -> None:
476
+ # Throw away (ns, nodeName) for now.
477
+ self.startElement(nodeName, attrs)
478
+
479
+ def endElementNS(self, nsTuple: Tuple[str, str], nodeName: str) -> None:
480
+ # Throw away (ns, nodeName) for now.
481
+ self.endElement(nodeName)
482
+ # handler.endElementNS((ns, node.nodeName), node.nodeName)
483
+
484
+ def startPrefixMapping(self, prefix: str, nodeValue: str) -> None:
485
+ # Ignore the prefix for now.
486
+ pass
487
+
488
+ def endPrefixMapping(self, prefix: str) -> None:
489
+ # Ignore the prefix for now.
490
+ # handler.endPrefixMapping(prefix)
491
+ pass
492
+
493
+ def characters(self, content: str) -> None:
494
+ assert self.soup is not None
495
+ self.soup.handle_data(content)
496
+
497
+ def startDocument(self) -> None:
498
+ pass
499
+
500
+ def endDocument(self) -> None:
501
+ pass
502
+
503
+
504
+ class HTMLTreeBuilder(TreeBuilder):
505
+ """This TreeBuilder knows facts about HTML, such as which tags are treated
506
+ specially by the HTML standard.
507
+ """
508
+
509
+ #: Some HTML tags are defined as having no contents. Beautiful Soup
510
+ #: treats these specially.
511
+ DEFAULT_EMPTY_ELEMENT_TAGS: Optional[Set[str]] = set(
512
+ [
513
+ # These are from HTML5.
514
+ "area",
515
+ "base",
516
+ "br",
517
+ "col",
518
+ "embed",
519
+ "hr",
520
+ "img",
521
+ "input",
522
+ "keygen",
523
+ "link",
524
+ "menuitem",
525
+ "meta",
526
+ "param",
527
+ "source",
528
+ "track",
529
+ "wbr",
530
+ # These are from earlier versions of HTML and are removed in HTML5.
531
+ "basefont",
532
+ "bgsound",
533
+ "command",
534
+ "frame",
535
+ "image",
536
+ "isindex",
537
+ "nextid",
538
+ "spacer",
539
+ ]
540
+ )
541
+
542
+ #: The HTML standard defines these tags as block-level elements. Beautiful
543
+ #: Soup does not treat these elements differently from other elements,
544
+ #: but it may do so eventually, and this information is available if
545
+ #: you need to use it.
546
+ DEFAULT_BLOCK_ELEMENTS: Set[str] = set(
547
+ [
548
+ "address",
549
+ "article",
550
+ "aside",
551
+ "blockquote",
552
+ "canvas",
553
+ "dd",
554
+ "div",
555
+ "dl",
556
+ "dt",
557
+ "fieldset",
558
+ "figcaption",
559
+ "figure",
560
+ "footer",
561
+ "form",
562
+ "h1",
563
+ "h2",
564
+ "h3",
565
+ "h4",
566
+ "h5",
567
+ "h6",
568
+ "header",
569
+ "hr",
570
+ "li",
571
+ "main",
572
+ "nav",
573
+ "noscript",
574
+ "ol",
575
+ "output",
576
+ "p",
577
+ "pre",
578
+ "section",
579
+ "table",
580
+ "tfoot",
581
+ "ul",
582
+ "video",
583
+ ]
584
+ )
585
+
586
+ #: These HTML tags need special treatment so they can be
587
+ #: represented by a string class other than `bs4.element.NavigableString`.
588
+ #:
589
+ #: For some of these tags, it's because the HTML standard defines
590
+ #: an unusual content model for them. I made this list by going
591
+ #: through the HTML spec
592
+ #: (https://html.spec.whatwg.org/#metadata-content) and looking for
593
+ #: "metadata content" elements that can contain strings.
594
+ #:
595
+ #: The Ruby tags (<rt> and <rp>) are here despite being normal
596
+ #: "phrasing content" tags, because the content they contain is
597
+ #: qualitatively different from other text in the document, and it
598
+ #: can be useful to be able to distinguish it.
599
+ #:
600
+ #: TODO: Arguably <noscript> could go here but it seems
601
+ #: qualitatively different from the other tags.
602
+ DEFAULT_STRING_CONTAINERS: Dict[str, Type[bs4.element.NavigableString]] = { # type:ignore
603
+ "rt": RubyTextString,
604
+ "rp": RubyParenthesisString,
605
+ "style": Stylesheet,
606
+ "script": Script,
607
+ "template": TemplateString,
608
+ }
609
+
610
+ #: The HTML standard defines these attributes as containing a
611
+ #: space-separated list of values, not a single value. That is,
612
+ #: class="foo bar" means that the 'class' attribute has two values,
613
+ #: 'foo' and 'bar', not the single value 'foo bar'. When we
614
+ #: encounter one of these attributes, we will parse its value into
615
+ #: a list of values if possible. Upon output, the list will be
616
+ #: converted back into a string.
617
+ DEFAULT_CDATA_LIST_ATTRIBUTES: Dict[str, Set[str]] = {
618
+ "*": {"class", "accesskey", "dropzone"},
619
+ "a": {"rel", "rev"},
620
+ "link": {"rel", "rev"},
621
+ "td": {"headers"},
622
+ "th": {"headers"},
623
+ "form": {"accept-charset"},
624
+ "object": {"archive"},
625
+ # These are HTML5 specific, as are *.accesskey and *.dropzone above.
626
+ "area": {"rel"},
627
+ "icon": {"sizes"},
628
+ "iframe": {"sandbox"},
629
+ "output": {"for"},
630
+ }
631
+
632
+ #: By default, whitespace inside these HTML tags will be
633
+ #: preserved rather than being collapsed.
634
+ DEFAULT_PRESERVE_WHITESPACE_TAGS: set[str] = set(["pre", "textarea"])
635
+
636
+ def set_up_substitutions(self, tag: Tag) -> bool:
637
+ """Replace the declared encoding in a <meta> tag with a placeholder,
638
+ to be substituted when the tag is output to a string.
639
+
640
+ An HTML document may come in to Beautiful Soup as one
641
+ encoding, but exit in a different encoding, and the <meta> tag
642
+ needs to be changed to reflect this.
643
+
644
+ :return: Whether or not a substitution was performed.
645
+
646
+ :meta private:
647
+ """
648
+ # We are only interested in <meta> tags
649
+ if tag.name != "meta":
650
+ return False
651
+
652
+ # TODO: This cast will fail in the (very unlikely) scenario
653
+ # that the programmer who instantiates the TreeBuilder
654
+ # specifies meta['content'] or meta['charset'] as
655
+ # cdata_list_attributes.
656
+ content: Optional[str] = cast(Optional[str], tag.get("content"))
657
+ charset: Optional[str] = cast(Optional[str], tag.get("charset"))
658
+
659
+ # But we can accommodate meta['http-equiv'] being made a
660
+ # cdata_list_attribute (again, very unlikely) without much
661
+ # trouble.
662
+ http_equiv: List[str] = tag.get_attribute_list("http-equiv")
663
+
664
+ # We are interested in <meta> tags that say what encoding the
665
+ # document was originally in. This means HTML 5-style <meta>
666
+ # tags that provide the "charset" attribute. It also means
667
+ # HTML 4-style <meta> tags that provide the "content"
668
+ # attribute and have "http-equiv" set to "content-type".
669
+ #
670
+ # In both cases we will replace the value of the appropriate
671
+ # attribute with a standin object that can take on any
672
+ # encoding.
673
+ substituted = False
674
+ if charset is not None:
675
+ # HTML 5 style:
676
+ # <meta charset="utf8">
677
+ tag["charset"] = CharsetMetaAttributeValue(charset)
678
+ substituted = True
679
+
680
+ elif content is not None and any(
681
+ x.lower() == "content-type" for x in http_equiv
682
+ ):
683
+ # HTML 4 style:
684
+ # <meta http-equiv="content-type" content="text/html; charset=utf8">
685
+ tag["content"] = ContentMetaAttributeValue(content)
686
+ substituted = True
687
+
688
+ return substituted
689
+
690
+
691
+ class DetectsXMLParsedAsHTML(object):
692
+ """A mixin class for any class (a TreeBuilder, or some class used by a
693
+ TreeBuilder) that's in a position to detect whether an XML
694
+ document is being incorrectly parsed as HTML, and issue an
695
+ appropriate warning.
696
+
697
+ This requires being able to observe an incoming processing
698
+ instruction that might be an XML declaration, and also able to
699
+ observe tags as they're opened. If you can't do that for a given
700
+ `TreeBuilder`, there's a less reliable implementation based on
701
+ examining the raw markup.
702
+ """
703
+
704
+ #: Regular expression for seeing if string markup has an <html> tag.
705
+ LOOKS_LIKE_HTML: Pattern[str] = re.compile("<[^ +]html", re.I)
706
+
707
+ #: Regular expression for seeing if byte markup has an <html> tag.
708
+ LOOKS_LIKE_HTML_B: Pattern[bytes] = re.compile(b"<[^ +]html", re.I)
709
+
710
+ #: The start of an XML document string.
711
+ XML_PREFIX: str = "<?xml"
712
+
713
+ #: The start of an XML document bytestring.
714
+ XML_PREFIX_B: bytes = b"<?xml"
715
+
716
+ # This is typed as str, not `ProcessingInstruction`, because this
717
+ # check may be run before any Beautiful Soup objects are created.
718
+ _first_processing_instruction: Optional[str] #: :meta private:
719
+ _root_tag_name: Optional[str] #: :meta private:
720
+
721
+ @classmethod
722
+ def warn_if_markup_looks_like_xml(
723
+ cls, markup: Optional[_RawMarkup], stacklevel: int = 3
724
+ ) -> bool:
725
+ """Perform a check on some markup to see if it looks like XML
726
+ that's not XHTML. If so, issue a warning.
727
+
728
+ This is much less reliable than doing the check while parsing,
729
+ but some of the tree builders can't do that.
730
+
731
+ :param stacklevel: The stacklevel of the code calling this\
732
+ function.
733
+
734
+ :return: True if the markup looks like non-XHTML XML, False
735
+ otherwise.
736
+ """
737
+ if markup is None:
738
+ return False
739
+ markup = markup[:500]
740
+ if isinstance(markup, bytes):
741
+ markup_b: bytes = markup
742
+ looks_like_xml = markup_b.startswith(
743
+ cls.XML_PREFIX_B
744
+ ) and not cls.LOOKS_LIKE_HTML_B.search(markup)
745
+ else:
746
+ markup_s: str = markup
747
+ looks_like_xml = markup_s.startswith(
748
+ cls.XML_PREFIX
749
+ ) and not cls.LOOKS_LIKE_HTML.search(markup)
750
+
751
+ if looks_like_xml:
752
+ cls._warn(stacklevel=stacklevel + 2)
753
+ return True
754
+ return False
755
+
756
+ @classmethod
757
+ def _warn(cls, stacklevel: int = 5) -> None:
758
+ """Issue a warning about XML being parsed as HTML."""
759
+ warnings.warn(
760
+ XMLParsedAsHTMLWarning.MESSAGE,
761
+ XMLParsedAsHTMLWarning,
762
+ stacklevel=stacklevel,
763
+ )
764
+
765
+ def _initialize_xml_detector(self) -> None:
766
+ """Call this method before parsing a document."""
767
+ self._first_processing_instruction = None
768
+ self._root_tag_name = None
769
+
770
+ def _document_might_be_xml(self, processing_instruction: str) -> None:
771
+ """Call this method when encountering an XML declaration, or a
772
+ "processing instruction" that might be an XML declaration.
773
+
774
+ This helps Beautiful Soup detect potential issues later, if
775
+ the XML document turns out to be a non-XHTML document that's
776
+ being parsed as XML.
777
+ """
778
+ if (
779
+ self._first_processing_instruction is not None
780
+ or self._root_tag_name is not None
781
+ ):
782
+ # The document has already started. Don't bother checking
783
+ # anymore.
784
+ return
785
+
786
+ self._first_processing_instruction = processing_instruction
787
+
788
+ # We won't know until we encounter the first tag whether or
789
+ # not this is actually a problem.
790
+
791
+ def _root_tag_encountered(self, name: str) -> None:
792
+ """Call this when you encounter the document's root tag.
793
+
794
+ This is where we actually check whether an XML document is
795
+ being incorrectly parsed as HTML, and issue the warning.
796
+ """
797
+ if self._root_tag_name is not None:
798
+ # This method was incorrectly called multiple times. Do
799
+ # nothing.
800
+ return
801
+
802
+ self._root_tag_name = name
803
+
804
+ if (
805
+ name != "html"
806
+ and self._first_processing_instruction is not None
807
+ and self._first_processing_instruction.lower().startswith("xml ")
808
+ ):
809
+ # We encountered an XML declaration and then a tag other
810
+ # than 'html'. This is a reliable indicator that a
811
+ # non-XHTML document is being parsed as XML.
812
+ self._warn(stacklevel=10)
813
+
814
+
815
+ def register_treebuilders_from(module: ModuleType) -> None:
816
+ """Copy TreeBuilders from the given module into this module."""
817
+ this_module = sys.modules[__name__]
818
+ for name in module.__all__:
819
+ obj = getattr(module, name)
820
+
821
+ if issubclass(obj, TreeBuilder):
822
+ setattr(this_module, name, obj)
823
+ this_module.__all__.append(name)
824
+ # Register the builder while we're at it.
825
+ this_module.builder_registry.register(obj)
826
+
827
+
828
+ # Builders are registered in reverse order of priority, so that custom
829
+ # builder registrations will take precedence. In general, we want lxml
830
+ # to take precedence over html5lib, because it's faster. And we only
831
+ # want to use HTMLParser as a last resort.
832
+ from . import _htmlparser # noqa: E402
833
+
834
+ register_treebuilders_from(_htmlparser)
835
+ try:
836
+ from . import _html5lib
837
+
838
+ register_treebuilders_from(_html5lib)
839
+ except ImportError:
840
+ # They don't have html5lib installed.
841
+ pass
842
+ try:
843
+ from . import _lxml
844
+
845
+ register_treebuilders_from(_lxml)
846
+ except ImportError:
847
+ # They don't have lxml installed.
848
+ pass
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (29.9 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/_html5lib.cpython-311.pyc ADDED
Binary file (25.3 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/_htmlparser.cpython-311.pyc ADDED
Binary file (15.9 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/__pycache__/_lxml.cpython-311.pyc ADDED
Binary file (20.5 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/_html5lib.py ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use of this source code is governed by the MIT license.
2
+ __license__ = "MIT"
3
+
4
+ __all__ = [
5
+ "HTML5TreeBuilder",
6
+ ]
7
+
8
+ from typing import (
9
+ Any,
10
+ cast,
11
+ Dict,
12
+ Iterable,
13
+ Optional,
14
+ Sequence,
15
+ TYPE_CHECKING,
16
+ Tuple,
17
+ Union,
18
+ )
19
+ from typing_extensions import TypeAlias
20
+ from bs4._typing import (
21
+ _AttributeValue,
22
+ _AttributeValues,
23
+ _Encoding,
24
+ _Encodings,
25
+ _NamespaceURL,
26
+ _RawMarkup,
27
+ )
28
+
29
+ import warnings
30
+ from bs4.builder import (
31
+ DetectsXMLParsedAsHTML,
32
+ PERMISSIVE,
33
+ HTML,
34
+ HTML_5,
35
+ HTMLTreeBuilder,
36
+ )
37
+ from bs4.element import (
38
+ NamespacedAttribute,
39
+ PageElement,
40
+ nonwhitespace_re,
41
+ )
42
+ import html5lib
43
+ from html5lib.constants import (
44
+ namespaces,
45
+ )
46
+ from bs4.element import (
47
+ Comment,
48
+ Doctype,
49
+ NavigableString,
50
+ Tag,
51
+ )
52
+
53
+ if TYPE_CHECKING:
54
+ from bs4 import BeautifulSoup
55
+
56
+ from html5lib.treebuilders import base as treebuilder_base
57
+
58
+
59
+ class HTML5TreeBuilder(HTMLTreeBuilder):
60
+ """Use `html5lib <https://github.com/html5lib/html5lib-python>`_ to
61
+ build a tree.
62
+
63
+ Note that `HTML5TreeBuilder` does not support some common HTML
64
+ `TreeBuilder` features. Some of these features could theoretically
65
+ be implemented, but at the very least it's quite difficult,
66
+ because html5lib moves the parse tree around as it's being built.
67
+
68
+ Specifically:
69
+
70
+ * This `TreeBuilder` doesn't use different subclasses of
71
+ `NavigableString` (e.g. `Script`) based on the name of the tag
72
+ in which the string was found.
73
+ * You can't use a `SoupStrainer` to parse only part of a document.
74
+ """
75
+
76
+ NAME: str = "html5lib"
77
+
78
+ features: Iterable[str] = [NAME, PERMISSIVE, HTML_5, HTML]
79
+
80
+ #: html5lib can tell us which line number and position in the
81
+ #: original file is the source of an element.
82
+ TRACKS_LINE_NUMBERS: bool = True
83
+
84
+ underlying_builder: "TreeBuilderForHtml5lib" #: :meta private:
85
+ user_specified_encoding: Optional[_Encoding]
86
+
87
+ def prepare_markup(
88
+ self,
89
+ markup: _RawMarkup,
90
+ user_specified_encoding: Optional[_Encoding] = None,
91
+ document_declared_encoding: Optional[_Encoding] = None,
92
+ exclude_encodings: Optional[_Encodings] = None,
93
+ ) -> Iterable[Tuple[_RawMarkup, Optional[_Encoding], Optional[_Encoding], bool]]:
94
+ # Store the user-specified encoding for use later on.
95
+ self.user_specified_encoding = user_specified_encoding
96
+
97
+ # document_declared_encoding and exclude_encodings aren't used
98
+ # ATM because the html5lib TreeBuilder doesn't use
99
+ # UnicodeDammit.
100
+ for variable, name in (
101
+ (document_declared_encoding, "document_declared_encoding"),
102
+ (exclude_encodings, "exclude_encodings"),
103
+ ):
104
+ if variable:
105
+ warnings.warn(
106
+ f"You provided a value for {name}, but the html5lib tree builder doesn't support {name}.",
107
+ stacklevel=3,
108
+ )
109
+
110
+ # html5lib only parses HTML, so if it's given XML that's worth
111
+ # noting.
112
+ DetectsXMLParsedAsHTML.warn_if_markup_looks_like_xml(markup, stacklevel=3)
113
+
114
+ yield (markup, None, None, False)
115
+
116
+ # These methods are defined by Beautiful Soup.
117
+ def feed(self, markup: _RawMarkup) -> None:
118
+ """Run some incoming markup through some parsing process,
119
+ populating the `BeautifulSoup` object in `HTML5TreeBuilder.soup`.
120
+ """
121
+ if self.soup is not None and self.soup.parse_only is not None:
122
+ warnings.warn(
123
+ "You provided a value for parse_only, but the html5lib tree builder doesn't support parse_only. The entire document will be parsed.",
124
+ stacklevel=4,
125
+ )
126
+
127
+ # self.underlying_builder is probably None now, but it'll be set
128
+ # when html5lib calls self.create_treebuilder().
129
+ parser = html5lib.HTMLParser(tree=self.create_treebuilder)
130
+ assert self.underlying_builder is not None
131
+ self.underlying_builder.parser = parser
132
+ extra_kwargs = dict()
133
+ if not isinstance(markup, str):
134
+ # kwargs, specifically override_encoding, will eventually
135
+ # be passed in to html5lib's
136
+ # HTMLBinaryInputStream.__init__.
137
+ extra_kwargs["override_encoding"] = self.user_specified_encoding
138
+
139
+ doc = parser.parse(markup, **extra_kwargs) # type:ignore
140
+
141
+ # Set the character encoding detected by the tokenizer.
142
+ if isinstance(markup, str):
143
+ # We need to special-case this because html5lib sets
144
+ # charEncoding to UTF-8 if it gets Unicode input.
145
+ doc.original_encoding = None
146
+ else:
147
+ original_encoding = parser.tokenizer.stream.charEncoding[0] # type:ignore
148
+ # The encoding is an html5lib Encoding object. We want to
149
+ # use a string for compatibility with other tree builders.
150
+ original_encoding = original_encoding.name
151
+ doc.original_encoding = original_encoding
152
+ self.underlying_builder.parser = None
153
+
154
+ def create_treebuilder(
155
+ self, namespaceHTMLElements: bool
156
+ ) -> "TreeBuilderForHtml5lib":
157
+ """Called by html5lib to instantiate the kind of class it
158
+ calls a 'TreeBuilder'.
159
+
160
+ :param namespaceHTMLElements: Whether or not to namespace HTML elements.
161
+
162
+ :meta private:
163
+ """
164
+ self.underlying_builder = TreeBuilderForHtml5lib(
165
+ namespaceHTMLElements, self.soup, store_line_numbers=self.store_line_numbers
166
+ )
167
+ return self.underlying_builder
168
+
169
+ def test_fragment_to_document(self, fragment: str) -> str:
170
+ """See `TreeBuilder`."""
171
+ return "<html><head></head><body>%s</body></html>" % fragment
172
+
173
+
174
+ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder):
175
+ soup: "BeautifulSoup" #: :meta private:
176
+ parser: Optional[html5lib.HTMLParser] #: :meta private:
177
+
178
+ def __init__(
179
+ self,
180
+ namespaceHTMLElements: bool,
181
+ soup: Optional["BeautifulSoup"] = None,
182
+ store_line_numbers: bool = True,
183
+ **kwargs: Any,
184
+ ):
185
+ if soup:
186
+ self.soup = soup
187
+ else:
188
+ warnings.warn(
189
+ "The optionality of the 'soup' argument to the TreeBuilderForHtml5lib constructor is deprecated as of Beautiful Soup 4.13.0: 'soup' is now required. If you can't pass in a BeautifulSoup object here, or you get this warning and it seems mysterious to you, please contact the Beautiful Soup developer team for possible un-deprecation.",
190
+ DeprecationWarning,
191
+ stacklevel=2,
192
+ )
193
+ from bs4 import BeautifulSoup
194
+
195
+ # TODO: Why is the parser 'html.parser' here? Using
196
+ # html5lib doesn't cause an infinite loop and is more
197
+ # accurate. Best to get rid of this entire section, I think.
198
+ self.soup = BeautifulSoup(
199
+ "", "html.parser", store_line_numbers=store_line_numbers, **kwargs
200
+ )
201
+ # TODO: What are **kwargs exactly? Should they be passed in
202
+ # here in addition to/instead of being passed to the BeautifulSoup
203
+ # constructor?
204
+ super(TreeBuilderForHtml5lib, self).__init__(namespaceHTMLElements)
205
+
206
+ # This will be set later to a real html5lib HTMLParser object,
207
+ # which we can use to track the current line number.
208
+ self.parser = None
209
+ self.store_line_numbers = store_line_numbers
210
+
211
+ def documentClass(self) -> "Element":
212
+ self.soup.reset()
213
+ return Element(self.soup, self.soup, None)
214
+
215
+ def insertDoctype(self, token: Dict[str, Any]) -> None:
216
+ name: str = cast(str, token["name"])
217
+ publicId: Optional[str] = cast(Optional[str], token["publicId"])
218
+ systemId: Optional[str] = cast(Optional[str], token["systemId"])
219
+
220
+ doctype = Doctype.for_name_and_ids(name, publicId, systemId)
221
+ self.soup.object_was_parsed(doctype)
222
+
223
+ def elementClass(self, name: str, namespace: str) -> "Element":
224
+ sourceline: Optional[int] = None
225
+ sourcepos: Optional[int] = None
226
+ if self.parser is not None and self.store_line_numbers:
227
+ # This represents the point immediately after the end of the
228
+ # tag. We don't know when the tag started, but we do know
229
+ # where it ended -- the character just before this one.
230
+ sourceline, sourcepos = self.parser.tokenizer.stream.position() # type:ignore
231
+ assert sourcepos is not None
232
+ sourcepos = sourcepos - 1
233
+ tag = self.soup.new_tag(
234
+ name, namespace, sourceline=sourceline, sourcepos=sourcepos
235
+ )
236
+
237
+ return Element(tag, self.soup, namespace)
238
+
239
+ def commentClass(self, data: str) -> "TextNode":
240
+ return TextNode(Comment(data), self.soup)
241
+
242
+ def fragmentClass(self) -> "Element":
243
+ """This is only used by html5lib HTMLParser.parseFragment(),
244
+ which is never used by Beautiful Soup, only by the html5lib
245
+ unit tests. Since we don't currently hook into those tests,
246
+ the implementation is left blank.
247
+ """
248
+ raise NotImplementedError()
249
+
250
+ def getFragment(self) -> "Element":
251
+ """This is only used by the html5lib unit tests. Since we
252
+ don't currently hook into those tests, the implementation is
253
+ left blank.
254
+ """
255
+ raise NotImplementedError()
256
+
257
+ def appendChild(self, node: "Element") -> None:
258
+ # TODO: This code is not covered by the BS4 tests, and
259
+ # apparently not triggered by the html5lib test suite either.
260
+ # But it doesn't seem test-specific and there are calls to it
261
+ # (or a method with the same name) all over html5lib, so I'm
262
+ # leaving the implementation in place rather than replacing it
263
+ # with NotImplementedError()
264
+ self.soup.append(node.element)
265
+
266
+ def getDocument(self) -> "BeautifulSoup":
267
+ return self.soup
268
+
269
+ def testSerializer(self, node: "Element") -> None:
270
+ """This is only used by the html5lib unit tests. Since we
271
+ don't currently hook into those tests, the implementation is
272
+ left blank.
273
+ """
274
+ raise NotImplementedError()
275
+
276
+
277
+ class AttrList(object):
278
+ """Represents a Tag's attributes in a way compatible with html5lib."""
279
+
280
+ element: Tag
281
+ attrs: _AttributeValues
282
+
283
+ def __init__(self, element: Tag):
284
+ self.element = element
285
+ self.attrs = dict(self.element.attrs)
286
+
287
+ def __iter__(self) -> Iterable[Tuple[str, _AttributeValue]]:
288
+ return list(self.attrs.items()).__iter__()
289
+
290
+ def __setitem__(self, name: str, value: _AttributeValue) -> None:
291
+ # If this attribute is a multi-valued attribute for this element,
292
+ # turn its value into a list.
293
+ list_attr = self.element.cdata_list_attributes or {}
294
+ if name in list_attr.get("*", []) or (
295
+ self.element.name in list_attr
296
+ and name in list_attr.get(self.element.name, [])
297
+ ):
298
+ # A node that is being cloned may have already undergone
299
+ # this procedure. Check for this and skip it.
300
+ if not isinstance(value, list):
301
+ assert isinstance(value, str)
302
+ value = self.element.attribute_value_list_class(
303
+ nonwhitespace_re.findall(value)
304
+ )
305
+ self.element[name] = value
306
+
307
+ def items(self) -> Iterable[Tuple[str, _AttributeValue]]:
308
+ return list(self.attrs.items())
309
+
310
+ def keys(self) -> Iterable[str]:
311
+ return list(self.attrs.keys())
312
+
313
+ def __len__(self) -> int:
314
+ return len(self.attrs)
315
+
316
+ def __getitem__(self, name: str) -> _AttributeValue:
317
+ return self.attrs[name]
318
+
319
+ def __contains__(self, name: str) -> bool:
320
+ return name in list(self.attrs.keys())
321
+
322
+
323
+ class BeautifulSoupNode(treebuilder_base.Node):
324
+ # A node can correspond to _either_ a Tag _or_ a NavigableString.
325
+ tag: Optional[Tag]
326
+ string: Optional[NavigableString]
327
+ soup: "BeautifulSoup"
328
+ namespace: Optional[_NamespaceURL]
329
+
330
+ @property
331
+ def element(self) -> PageElement:
332
+ assert self.tag is not None or self.string is not None
333
+ if self.tag is not None:
334
+ return self.tag
335
+ else:
336
+ assert self.string is not None
337
+ return self.string
338
+
339
+ @property
340
+ def nodeType(self) -> int:
341
+ """Return the html5lib constant corresponding to the type of
342
+ the underlying DOM object.
343
+
344
+ NOTE: This property is only accessed by the html5lib test
345
+ suite, not by Beautiful Soup proper.
346
+ """
347
+ raise NotImplementedError()
348
+
349
+ # TODO-TYPING: typeshed stubs are incorrect about this;
350
+ # cloneNode returns a new Node, not None.
351
+ def cloneNode(self) -> treebuilder_base.Node: # type:ignore
352
+ raise NotImplementedError()
353
+
354
+
355
+ class Element(BeautifulSoupNode):
356
+ namespace: Optional[_NamespaceURL]
357
+
358
+ def __init__(
359
+ self, element: Tag, soup: "BeautifulSoup", namespace: Optional[_NamespaceURL]
360
+ ):
361
+ self.tag = element
362
+ self.string = None
363
+ self.soup = soup
364
+ self.namespace = namespace
365
+ treebuilder_base.Node.__init__(self, element.name)
366
+
367
+ def appendChild(self, node: "BeautifulSoupNode") -> None:
368
+ string_child: Optional[NavigableString] = None
369
+ child: PageElement
370
+ if type(node.string) is NavigableString:
371
+ # We check for NavigableString *only* because we want to avoid
372
+ # joining PreformattedStrings, such as Comments, with nearby strings.
373
+ string_child = child = node.string
374
+ else:
375
+ child = node.element
376
+ node.parent = self
377
+
378
+ if (
379
+ child is not None
380
+ and child.parent is not None
381
+ and not isinstance(child, str)
382
+ ):
383
+ node.element.extract()
384
+
385
+ if (
386
+ string_child is not None
387
+ and self.tag is not None and self.tag.contents
388
+ and type(self.tag.contents[-1]) is NavigableString
389
+ ):
390
+ # We are appending a string onto another string.
391
+ # TODO This has O(n^2) performance, for input like
392
+ # "a</a>a</a>a</a>..."
393
+ old_element = self.tag.contents[-1]
394
+ new_element = self.soup.new_string(old_element + string_child)
395
+ old_element.replace_with(new_element)
396
+ self.soup._most_recent_element = new_element
397
+ else:
398
+ if isinstance(node, str):
399
+ # Create a brand new NavigableString from this string.
400
+ child = self.soup.new_string(node)
401
+
402
+ # Tell Beautiful Soup to act as if it parsed this element
403
+ # immediately after the parent's last descendant. (Or
404
+ # immediately after the parent, if it has no children.)
405
+ if self.tag is not None and self.tag.contents:
406
+ most_recent_element = self.tag._last_descendant(False)
407
+ elif self.element.next_element is not None:
408
+ # Something from further ahead in the parse tree is
409
+ # being inserted into this earlier element. This is
410
+ # very annoying because it means an expensive search
411
+ # for the last element in the tree.
412
+ most_recent_element = self.soup._last_descendant()
413
+ else:
414
+ most_recent_element = self.element
415
+
416
+ self.soup.object_was_parsed(
417
+ child, parent=self.tag, most_recent_element=most_recent_element
418
+ )
419
+
420
+ def getAttributes(self) -> AttrList:
421
+ assert self.tag is not None
422
+ return AttrList(self.tag)
423
+
424
+ # An HTML5lib attribute name may either be a single string,
425
+ # or a tuple (namespace, name).
426
+ _Html5libAttributeName: TypeAlias = Union[str, Tuple[str, str]]
427
+ # Now we can define the type this method accepts as a dictionary
428
+ # mapping those attribute names to single string values.
429
+ _Html5libAttributes: TypeAlias = Dict[_Html5libAttributeName, str]
430
+
431
+ def setAttributes(self, attributes: Optional[_Html5libAttributes]) -> None:
432
+ assert self.tag is not None
433
+ if attributes is not None and len(attributes) > 0:
434
+ # Replace any namespaced attributes with
435
+ # NamespacedAttribute objects.
436
+ for name, value in list(attributes.items()):
437
+ if isinstance(name, tuple):
438
+ new_name = NamespacedAttribute(*name)
439
+ del attributes[name]
440
+ attributes[new_name] = value
441
+
442
+ # We can now cast attributes to the type of Dict
443
+ # used by Beautiful Soup.
444
+ normalized_attributes = cast(_AttributeValues, attributes)
445
+
446
+ # Values for tags like 'class' came in as single strings;
447
+ # replace them with lists of strings as appropriate.
448
+ self.soup.builder._replace_cdata_list_attribute_values(
449
+ self.name, normalized_attributes
450
+ )
451
+
452
+ # Then set the attributes on the Tag associated with this
453
+ # BeautifulSoupNode.
454
+ for name, value_or_values in list(normalized_attributes.items()):
455
+ self.tag[name] = value_or_values
456
+
457
+ # The attributes may contain variables that need substitution.
458
+ # Call set_up_substitutions manually.
459
+ #
460
+ # The Tag constructor called this method when the Tag was created,
461
+ # but we just set/changed the attributes, so call it again.
462
+ self.soup.builder.set_up_substitutions(self.tag)
463
+
464
+ attributes = property(getAttributes, setAttributes)
465
+
466
+ def insertText(
467
+ self, data: str, insertBefore: Optional["BeautifulSoupNode"] = None
468
+ ) -> None:
469
+ text = TextNode(self.soup.new_string(data), self.soup)
470
+ if insertBefore:
471
+ self.insertBefore(text, insertBefore)
472
+ else:
473
+ self.appendChild(text)
474
+
475
+ def insertBefore(
476
+ self, node: "BeautifulSoupNode", refNode: "BeautifulSoupNode"
477
+ ) -> None:
478
+ assert self.tag is not None
479
+ index = self.tag.index(refNode.element)
480
+ if (
481
+ type(node.element) is NavigableString
482
+ and self.tag.contents
483
+ and type(self.tag.contents[index - 1]) is NavigableString
484
+ ):
485
+ # (See comments in appendChild)
486
+ old_node = self.tag.contents[index - 1]
487
+ assert type(old_node) is NavigableString
488
+ new_str = self.soup.new_string(old_node + node.element)
489
+ old_node.replace_with(new_str)
490
+ else:
491
+ self.tag.insert(index, node.element)
492
+ node.parent = self
493
+
494
+ def removeChild(self, node: "Element") -> None:
495
+ node.element.extract()
496
+
497
+ def reparentChildren(self, newParent: "Element") -> None:
498
+ """Move all of this tag's children into another tag."""
499
+ # print("MOVE", self.element.contents)
500
+ # print("FROM", self.element)
501
+ # print("TO", new_parent.element)
502
+
503
+ element = self.tag
504
+ assert element is not None
505
+ new_parent_element = newParent.tag
506
+ assert new_parent_element is not None
507
+ # Determine what this tag's next_element will be once all the children
508
+ # are removed.
509
+ final_next_element = element.next_sibling
510
+
511
+ new_parents_last_descendant = new_parent_element._last_descendant(False, False)
512
+ if len(new_parent_element.contents) > 0:
513
+ # The new parent already contains children. We will be
514
+ # appending this tag's children to the end.
515
+
516
+ # We can make this assertion since we know new_parent has
517
+ # children.
518
+ assert new_parents_last_descendant is not None
519
+ new_parents_last_child = new_parent_element.contents[-1]
520
+ new_parents_last_descendant_next_element = (
521
+ new_parents_last_descendant.next_element
522
+ )
523
+ else:
524
+ # The new parent contains no children.
525
+ new_parents_last_child = None
526
+ new_parents_last_descendant_next_element = new_parent_element.next_element
527
+
528
+ to_append = element.contents
529
+ if len(to_append) > 0:
530
+ # Set the first child's previous_element and previous_sibling
531
+ # to elements within the new parent
532
+ first_child = to_append[0]
533
+ if new_parents_last_descendant is not None:
534
+ first_child.previous_element = new_parents_last_descendant
535
+ else:
536
+ first_child.previous_element = new_parent_element
537
+ first_child.previous_sibling = new_parents_last_child
538
+ if new_parents_last_descendant is not None:
539
+ new_parents_last_descendant.next_element = first_child
540
+ else:
541
+ new_parent_element.next_element = first_child
542
+ if new_parents_last_child is not None:
543
+ new_parents_last_child.next_sibling = first_child
544
+
545
+ # Find the very last element being moved. It is now the
546
+ # parent's last descendant. It has no .next_sibling and
547
+ # its .next_element is whatever the previous last
548
+ # descendant had.
549
+ last_childs_last_descendant = to_append[-1]._last_descendant(
550
+ is_initialized=False, accept_self=True
551
+ )
552
+
553
+ # Since we passed accept_self=True into _last_descendant,
554
+ # there's no possibility that the result is None.
555
+ assert last_childs_last_descendant is not None
556
+ last_childs_last_descendant.next_element = (
557
+ new_parents_last_descendant_next_element
558
+ )
559
+ if new_parents_last_descendant_next_element is not None:
560
+ # TODO-COVERAGE: This code has no test coverage and
561
+ # I'm not sure how to get html5lib to go through this
562
+ # path, but it's just the other side of the previous
563
+ # line.
564
+ new_parents_last_descendant_next_element.previous_element = (
565
+ last_childs_last_descendant
566
+ )
567
+ last_childs_last_descendant.next_sibling = None
568
+
569
+ for child in to_append:
570
+ child.parent = new_parent_element
571
+ new_parent_element.contents.append(child)
572
+
573
+ # Now that this element has no children, change its .next_element.
574
+ element.contents = []
575
+ element.next_element = final_next_element
576
+
577
+ # print("DONE WITH MOVE")
578
+ # print("FROM", self.element)
579
+ # print("TO", new_parent_element)
580
+
581
+ # TODO-TYPING: typeshed stubs are incorrect about this;
582
+ # hasContent returns a boolean, not None.
583
+ def hasContent(self) -> bool: # type:ignore
584
+ return self.tag is None or len(self.tag.contents) > 0
585
+
586
+ # TODO-TYPING: typeshed stubs are incorrect about this;
587
+ # cloneNode returns a new Node, not None.
588
+ def cloneNode(self) -> treebuilder_base.Node: # type:ignore
589
+ assert self.tag is not None
590
+ tag = self.soup.new_tag(self.tag.name, self.namespace)
591
+ node = Element(tag, self.soup, self.namespace)
592
+ for key, value in self.attributes:
593
+ node.attributes[key] = value
594
+ return node
595
+
596
+ def getNameTuple(self) -> Tuple[Optional[_NamespaceURL], str]:
597
+ if self.namespace is None:
598
+ return namespaces["html"], self.name
599
+ else:
600
+ return self.namespace, self.name
601
+
602
+ nameTuple = property(getNameTuple)
603
+
604
+
605
+ class TextNode(BeautifulSoupNode):
606
+
607
+ def __init__(self, element: NavigableString, soup: "BeautifulSoup"):
608
+ treebuilder_base.Node.__init__(self, None)
609
+ self.tag = None
610
+ self.string = element
611
+ self.soup = soup
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/_htmlparser.py ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # encoding: utf-8
2
+ """Use the HTMLParser library to parse HTML files that aren't too bad."""
3
+ from __future__ import annotations
4
+
5
+ # Use of this source code is governed by the MIT license.
6
+ __license__ = "MIT"
7
+
8
+ __all__ = [
9
+ "HTMLParserTreeBuilder",
10
+ ]
11
+
12
+ from html.parser import HTMLParser
13
+
14
+ from typing import (
15
+ Any,
16
+ Callable,
17
+ cast,
18
+ Dict,
19
+ Iterable,
20
+ List,
21
+ Optional,
22
+ TYPE_CHECKING,
23
+ Tuple,
24
+ Type,
25
+ Union,
26
+ )
27
+
28
+ from bs4.element import (
29
+ AttributeDict,
30
+ CData,
31
+ Comment,
32
+ Declaration,
33
+ Doctype,
34
+ ProcessingInstruction,
35
+ )
36
+ from bs4.dammit import EntitySubstitution, UnicodeDammit
37
+
38
+ from bs4.builder import (
39
+ DetectsXMLParsedAsHTML,
40
+ HTML,
41
+ HTMLTreeBuilder,
42
+ STRICT,
43
+ )
44
+
45
+ from bs4.exceptions import ParserRejectedMarkup
46
+
47
+ if TYPE_CHECKING:
48
+ from bs4 import BeautifulSoup
49
+ from bs4.element import NavigableString
50
+ from bs4._typing import (
51
+ _Encoding,
52
+ _Encodings,
53
+ _RawMarkup,
54
+ )
55
+
56
+ HTMLPARSER = "html.parser"
57
+
58
+ _DuplicateAttributeHandler = Callable[[Dict[str, str], str, str], None]
59
+
60
+
61
+ class BeautifulSoupHTMLParser(HTMLParser, DetectsXMLParsedAsHTML):
62
+ #: Constant to handle duplicate attributes by ignoring later values
63
+ #: and keeping the earlier ones.
64
+ REPLACE: str = "replace"
65
+
66
+ #: Constant to handle duplicate attributes by replacing earlier values
67
+ #: with later ones.
68
+ IGNORE: str = "ignore"
69
+
70
+ """A subclass of the Python standard library's HTMLParser class, which
71
+ listens for HTMLParser events and translates them into calls
72
+ to Beautiful Soup's tree construction API.
73
+
74
+ :param on_duplicate_attribute: A strategy for what to do if a
75
+ tag includes the same attribute more than once. Accepted
76
+ values are: REPLACE (replace earlier values with later
77
+ ones, the default), IGNORE (keep the earliest value
78
+ encountered), or a callable. A callable must take three
79
+ arguments: the dictionary of attributes already processed,
80
+ the name of the duplicate attribute, and the most recent value
81
+ encountered.
82
+ """
83
+
84
+ def __init__(
85
+ self,
86
+ soup: BeautifulSoup,
87
+ *args: Any,
88
+ on_duplicate_attribute: Union[str, _DuplicateAttributeHandler] = REPLACE,
89
+ **kwargs: Any,
90
+ ):
91
+ self.soup = soup
92
+ self.on_duplicate_attribute = on_duplicate_attribute
93
+ self.attribute_dict_class = soup.builder.attribute_dict_class
94
+ HTMLParser.__init__(self, *args, **kwargs)
95
+
96
+ # Keep a list of empty-element tags that were encountered
97
+ # without an explicit closing tag. If we encounter a closing tag
98
+ # of this type, we'll associate it with one of those entries.
99
+ #
100
+ # This isn't a stack because we don't care about the
101
+ # order. It's a list of closing tags we've already handled and
102
+ # will ignore, assuming they ever show up.
103
+ self.already_closed_empty_element = []
104
+
105
+ self._initialize_xml_detector()
106
+
107
+ on_duplicate_attribute: Union[str, _DuplicateAttributeHandler]
108
+ already_closed_empty_element: List[str]
109
+ soup: BeautifulSoup
110
+
111
+ def error(self, message: str) -> None:
112
+ # NOTE: This method is required so long as Python 3.9 is
113
+ # supported. The corresponding code is removed from HTMLParser
114
+ # in 3.5, but not removed from ParserBase until 3.10.
115
+ # https://github.com/python/cpython/issues/76025
116
+ #
117
+ # The original implementation turned the error into a warning,
118
+ # but in every case I discovered, this made HTMLParser
119
+ # immediately crash with an error message that was less
120
+ # helpful than the warning. The new implementation makes it
121
+ # more clear that html.parser just can't parse this
122
+ # markup. The 3.10 implementation does the same, though it
123
+ # raises AssertionError rather than calling a method. (We
124
+ # catch this error and wrap it in a ParserRejectedMarkup.)
125
+ raise ParserRejectedMarkup(message)
126
+
127
+ def handle_startendtag(
128
+ self, tag: str, attrs: List[Tuple[str, Optional[str]]]
129
+ ) -> None:
130
+ """Handle an incoming empty-element tag.
131
+
132
+ html.parser only calls this method when the markup looks like
133
+ <tag/>.
134
+ """
135
+ # `handle_empty_element` tells handle_starttag not to close the tag
136
+ # just because its name matches a known empty-element tag. We
137
+ # know that this is an empty-element tag, and we want to call
138
+ # handle_endtag ourselves.
139
+ self.handle_starttag(tag, attrs, handle_empty_element=False)
140
+ self.handle_endtag(tag)
141
+
142
+ def handle_starttag(
143
+ self,
144
+ tag: str,
145
+ attrs: List[Tuple[str, Optional[str]]],
146
+ handle_empty_element: bool = True,
147
+ ) -> None:
148
+ """Handle an opening tag, e.g. '<tag>'
149
+
150
+ :param handle_empty_element: True if this tag is known to be
151
+ an empty-element tag (i.e. there is not expected to be any
152
+ closing tag).
153
+ """
154
+ # TODO: handle namespaces here?
155
+ attr_dict: AttributeDict = self.attribute_dict_class()
156
+ for key, value in attrs:
157
+ # Change None attribute values to the empty string
158
+ # for consistency with the other tree builders.
159
+ if value is None:
160
+ value = ""
161
+ if key in attr_dict:
162
+ # A single attribute shows up multiple times in this
163
+ # tag. How to handle it depends on the
164
+ # on_duplicate_attribute setting.
165
+ on_dupe = self.on_duplicate_attribute
166
+ if on_dupe == self.IGNORE:
167
+ pass
168
+ elif on_dupe in (None, self.REPLACE):
169
+ attr_dict[key] = value
170
+ else:
171
+ on_dupe = cast(_DuplicateAttributeHandler, on_dupe)
172
+ on_dupe(attr_dict, key, value)
173
+ else:
174
+ attr_dict[key] = value
175
+ # print("START", tag)
176
+ sourceline: Optional[int]
177
+ sourcepos: Optional[int]
178
+ if self.soup.builder.store_line_numbers:
179
+ sourceline, sourcepos = self.getpos()
180
+ else:
181
+ sourceline = sourcepos = None
182
+ tagObj = self.soup.handle_starttag(
183
+ tag, None, None, attr_dict, sourceline=sourceline, sourcepos=sourcepos
184
+ )
185
+ if tagObj is not None and tagObj.is_empty_element and handle_empty_element:
186
+ # Unlike other parsers, html.parser doesn't send separate end tag
187
+ # events for empty-element tags. (It's handled in
188
+ # handle_startendtag, but only if the original markup looked like
189
+ # <tag/>.)
190
+ #
191
+ # So we need to call handle_endtag() ourselves. Since we
192
+ # know the start event is identical to the end event, we
193
+ # don't want handle_endtag() to cross off any previous end
194
+ # events for tags of this name.
195
+ self.handle_endtag(tag, check_already_closed=False)
196
+
197
+ # But we might encounter an explicit closing tag for this tag
198
+ # later on. If so, we want to ignore it.
199
+ self.already_closed_empty_element.append(tag)
200
+
201
+ if self._root_tag_name is None:
202
+ self._root_tag_encountered(tag)
203
+
204
+ def handle_endtag(self, tag: str, check_already_closed: bool = True) -> None:
205
+ """Handle a closing tag, e.g. '</tag>'
206
+
207
+ :param tag: A tag name.
208
+ :param check_already_closed: True if this tag is expected to
209
+ be the closing portion of an empty-element tag,
210
+ e.g. '<tag></tag>'.
211
+ """
212
+ # print("END", tag)
213
+ if check_already_closed and tag in self.already_closed_empty_element:
214
+ # This is a redundant end tag for an empty-element tag.
215
+ # We've already called handle_endtag() for it, so just
216
+ # check it off the list.
217
+ # print("ALREADY CLOSED", tag)
218
+ self.already_closed_empty_element.remove(tag)
219
+ else:
220
+ self.soup.handle_endtag(tag)
221
+
222
+ def handle_data(self, data: str) -> None:
223
+ """Handle some textual data that shows up between tags."""
224
+ self.soup.handle_data(data)
225
+
226
+ def handle_charref(self, name: str) -> None:
227
+ """Handle a numeric character reference by converting it to the
228
+ corresponding Unicode character and treating it as textual
229
+ data.
230
+
231
+ :param name: Character number, possibly in hexadecimal.
232
+ """
233
+ # TODO: This was originally a workaround for a bug in
234
+ # HTMLParser. (http://bugs.python.org/issue13633) The bug has
235
+ # been fixed, but removing this code still makes some
236
+ # Beautiful Soup tests fail. This needs investigation.
237
+ real_name:int
238
+ if name.startswith("x"):
239
+ real_name = int(name.lstrip("x"), 16)
240
+ elif name.startswith("X"):
241
+ real_name = int(name.lstrip("X"), 16)
242
+ else:
243
+ real_name = int(name)
244
+
245
+ data, replacement_added = UnicodeDammit.numeric_character_reference(real_name)
246
+ if replacement_added:
247
+ self.soup.contains_replacement_characters = True
248
+ self.handle_data(data)
249
+
250
+ def handle_entityref(self, name: str) -> None:
251
+ """Handle a named entity reference by converting it to the
252
+ corresponding Unicode character(s) and treating it as textual
253
+ data.
254
+
255
+ :param name: Name of the entity reference.
256
+ """
257
+ character = EntitySubstitution.HTML_ENTITY_TO_CHARACTER.get(name)
258
+ if character is not None:
259
+ data = character
260
+ else:
261
+ # If this were XML, it would be ambiguous whether "&foo"
262
+ # was an character entity reference with a missing
263
+ # semicolon or the literal string "&foo". Since this is
264
+ # HTML, we have a complete list of all character entity references,
265
+ # and this one wasn't found, so assume it's the literal string "&foo".
266
+ data = "&%s" % name
267
+ self.handle_data(data)
268
+
269
+ def handle_comment(self, data: str) -> None:
270
+ """Handle an HTML comment.
271
+
272
+ :param data: The text of the comment.
273
+ """
274
+ self.soup.endData()
275
+ self.soup.handle_data(data)
276
+ self.soup.endData(Comment)
277
+
278
+ def handle_decl(self, decl: str) -> None:
279
+ """Handle a DOCTYPE declaration.
280
+
281
+ :param data: The text of the declaration.
282
+ """
283
+ self.soup.endData()
284
+ decl = decl[len("DOCTYPE ") :]
285
+ self.soup.handle_data(decl)
286
+ self.soup.endData(Doctype)
287
+
288
+ def unknown_decl(self, data: str) -> None:
289
+ """Handle a declaration of unknown type -- probably a CDATA block.
290
+
291
+ :param data: The text of the declaration.
292
+ """
293
+ cls: Type[NavigableString]
294
+ if data.upper().startswith("CDATA["):
295
+ cls = CData
296
+ data = data[len("CDATA[") :]
297
+ else:
298
+ cls = Declaration
299
+ self.soup.endData()
300
+ self.soup.handle_data(data)
301
+ self.soup.endData(cls)
302
+
303
+ def handle_pi(self, data: str) -> None:
304
+ """Handle a processing instruction.
305
+
306
+ :param data: The text of the instruction.
307
+ """
308
+ self.soup.endData()
309
+ self.soup.handle_data(data)
310
+ self._document_might_be_xml(data)
311
+ self.soup.endData(ProcessingInstruction)
312
+
313
+
314
+ class HTMLParserTreeBuilder(HTMLTreeBuilder):
315
+ """A Beautiful soup `bs4.builder.TreeBuilder` that uses the
316
+ :py:class:`html.parser.HTMLParser` parser, found in the Python
317
+ standard library.
318
+
319
+ """
320
+
321
+ is_xml: bool = False
322
+ picklable: bool = True
323
+ NAME: str = HTMLPARSER
324
+ features: Iterable[str] = [NAME, HTML, STRICT]
325
+ parser_args: Tuple[Iterable[Any], Dict[str, Any]]
326
+
327
+ #: The html.parser knows which line number and position in the
328
+ #: original file is the source of an element.
329
+ TRACKS_LINE_NUMBERS: bool = True
330
+
331
+ def __init__(
332
+ self,
333
+ parser_args: Optional[Iterable[Any]] = None,
334
+ parser_kwargs: Optional[Dict[str, Any]] = None,
335
+ **kwargs: Any,
336
+ ):
337
+ """Constructor.
338
+
339
+ :param parser_args: Positional arguments to pass into
340
+ the BeautifulSoupHTMLParser constructor, once it's
341
+ invoked.
342
+ :param parser_kwargs: Keyword arguments to pass into
343
+ the BeautifulSoupHTMLParser constructor, once it's
344
+ invoked.
345
+ :param kwargs: Keyword arguments for the superclass constructor.
346
+ """
347
+ # Some keyword arguments will be pulled out of kwargs and placed
348
+ # into parser_kwargs.
349
+ extra_parser_kwargs = dict()
350
+ for arg in ("on_duplicate_attribute",):
351
+ if arg in kwargs:
352
+ value = kwargs.pop(arg)
353
+ extra_parser_kwargs[arg] = value
354
+ super(HTMLParserTreeBuilder, self).__init__(**kwargs)
355
+ parser_args = parser_args or []
356
+ parser_kwargs = parser_kwargs or {}
357
+ parser_kwargs.update(extra_parser_kwargs)
358
+ parser_kwargs["convert_charrefs"] = False
359
+ self.parser_args = (parser_args, parser_kwargs)
360
+
361
+ def prepare_markup(
362
+ self,
363
+ markup: _RawMarkup,
364
+ user_specified_encoding: Optional[_Encoding] = None,
365
+ document_declared_encoding: Optional[_Encoding] = None,
366
+ exclude_encodings: Optional[_Encodings] = None,
367
+ ) -> Iterable[Tuple[str, Optional[_Encoding], Optional[_Encoding], bool]]:
368
+ """Run any preliminary steps necessary to make incoming markup
369
+ acceptable to the parser.
370
+
371
+ :param markup: Some markup -- probably a bytestring.
372
+ :param user_specified_encoding: The user asked to try this encoding.
373
+ :param document_declared_encoding: The markup itself claims to be
374
+ in this encoding.
375
+ :param exclude_encodings: The user asked _not_ to try any of
376
+ these encodings.
377
+
378
+ :yield: A series of 4-tuples: (markup, encoding, declared encoding,
379
+ has undergone character replacement)
380
+
381
+ Each 4-tuple represents a strategy for parsing the document.
382
+ This TreeBuilder uses Unicode, Dammit to convert the markup
383
+ into Unicode, so the ``markup`` element of the tuple will
384
+ always be a string.
385
+ """
386
+ if isinstance(markup, str):
387
+ # Parse Unicode as-is.
388
+ yield (markup, None, None, False)
389
+ return
390
+
391
+ # Ask UnicodeDammit to sniff the most likely encoding.
392
+
393
+ known_definite_encodings: List[_Encoding] = []
394
+ if user_specified_encoding:
395
+ # This was provided by the end-user; treat it as a known
396
+ # definite encoding per the algorithm laid out in the
397
+ # HTML5 spec. (See the EncodingDetector class for
398
+ # details.)
399
+ known_definite_encodings.append(user_specified_encoding)
400
+
401
+ user_encodings: List[_Encoding] = []
402
+ if document_declared_encoding:
403
+ # This was found in the document; treat it as a slightly
404
+ # lower-priority user encoding.
405
+ user_encodings.append(document_declared_encoding)
406
+
407
+ dammit = UnicodeDammit(
408
+ markup,
409
+ known_definite_encodings=known_definite_encodings,
410
+ user_encodings=user_encodings,
411
+ is_html=True,
412
+ exclude_encodings=exclude_encodings,
413
+ )
414
+
415
+ if dammit.unicode_markup is None:
416
+ # In every case I've seen, Unicode, Dammit is able to
417
+ # convert the markup into Unicode, even if it needs to use
418
+ # REPLACEMENT CHARACTER. But there is a code path that
419
+ # could result in unicode_markup being None, and
420
+ # HTMLParser can only parse Unicode, so here we handle
421
+ # that code path.
422
+ raise ParserRejectedMarkup(
423
+ "Could not convert input to Unicode, and html.parser will not accept bytestrings."
424
+ )
425
+ else:
426
+ yield (
427
+ dammit.unicode_markup,
428
+ dammit.original_encoding,
429
+ dammit.declared_html_encoding,
430
+ dammit.contains_replacement_characters,
431
+ )
432
+
433
+ def feed(self, markup: _RawMarkup, _parser_class:type[BeautifulSoupHTMLParser] =BeautifulSoupHTMLParser) -> None:
434
+ """
435
+ :param markup: The markup to feed into the parser.
436
+ :param _parser_class: An HTMLParser subclass to use. This is only intended for use in unit tests.
437
+ """
438
+ args, kwargs = self.parser_args
439
+
440
+ # HTMLParser.feed will only handle str, but
441
+ # BeautifulSoup.markup is allowed to be _RawMarkup, because
442
+ # it's set by the yield value of
443
+ # TreeBuilder.prepare_markup. Fortunately,
444
+ # HTMLParserTreeBuilder.prepare_markup always yields a str
445
+ # (UnicodeDammit.unicode_markup).
446
+ assert isinstance(markup, str)
447
+
448
+ # We know BeautifulSoup calls TreeBuilder.initialize_soup
449
+ # before calling feed(), so we can assume self.soup
450
+ # is set.
451
+ assert self.soup is not None
452
+ parser = _parser_class(self.soup, *args, **kwargs)
453
+
454
+ try:
455
+ parser.feed(markup)
456
+ parser.close()
457
+ except AssertionError as e:
458
+ # html.parser raises AssertionError in rare cases to
459
+ # indicate a fatal problem with the markup, especially
460
+ # when there's an error in the doctype declaration.
461
+ raise ParserRejectedMarkup(e)
462
+ parser.already_closed_empty_element = []
data/conda_envs/evalclaw/lib/python3.11/site-packages/bs4/builder/_lxml.py ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # encoding: utf-8
2
+ from __future__ import annotations
3
+
4
+ # Use of this source code is governed by the MIT license.
5
+ __license__ = "MIT"
6
+
7
+ __all__ = [
8
+ "LXMLTreeBuilderForXML",
9
+ "LXMLTreeBuilder",
10
+ ]
11
+
12
+
13
+ from typing import (
14
+ Any,
15
+ Dict,
16
+ Iterable,
17
+ List,
18
+ Optional,
19
+ Set,
20
+ Tuple,
21
+ Type,
22
+ TYPE_CHECKING,
23
+ Union,
24
+ )
25
+
26
+ from io import BytesIO
27
+ from io import StringIO
28
+
29
+ from typing_extensions import TypeAlias
30
+
31
+ from lxml import etree # type:ignore
32
+ from bs4.element import (
33
+ AttributeDict,
34
+ XMLAttributeDict,
35
+ Comment,
36
+ Doctype,
37
+ NamespacedAttribute,
38
+ ProcessingInstruction,
39
+ XMLProcessingInstruction,
40
+ )
41
+ from bs4.builder import (
42
+ DetectsXMLParsedAsHTML,
43
+ FAST,
44
+ HTML,
45
+ HTMLTreeBuilder,
46
+ PERMISSIVE,
47
+ TreeBuilder,
48
+ XML,
49
+ )
50
+ from bs4.dammit import EncodingDetector
51
+ from bs4.exceptions import ParserRejectedMarkup
52
+
53
+ if TYPE_CHECKING:
54
+ from bs4._typing import (
55
+ _Encoding,
56
+ _Encodings,
57
+ _NamespacePrefix,
58
+ _NamespaceURL,
59
+ _NamespaceMapping,
60
+ _InvertedNamespaceMapping,
61
+ _RawMarkup,
62
+ )
63
+ from bs4 import BeautifulSoup
64
+
65
+ LXML: str = "lxml"
66
+
67
+
68
+ def _invert(d: dict[Any, Any]) -> dict[Any, Any]:
69
+ "Invert a dictionary."
70
+ return dict((v, k) for k, v in list(d.items()))
71
+
72
+
73
+ _LXMLParser: TypeAlias = Union[etree.XMLParser, etree.HTMLParser]
74
+ _ParserOrParserClass: TypeAlias = Union[
75
+ _LXMLParser, Type[etree.XMLParser], Type[etree.HTMLParser]
76
+ ]
77
+
78
+
79
+ class LXMLTreeBuilderForXML(TreeBuilder):
80
+ DEFAULT_PARSER_CLASS: Type[etree.XMLParser] = etree.XMLParser
81
+
82
+ is_xml: bool = True
83
+
84
+ #: Set this to true (probably by passing huge_tree=True into the :
85
+ #: BeautifulSoup constructor) to enable the lxml feature "disable security
86
+ #: restrictions and support very deep trees and very long text
87
+ #: content".
88
+ huge_tree: bool
89
+
90
+ processing_instruction_class: Type[ProcessingInstruction]
91
+
92
+ NAME: str = "lxml-xml"
93
+ ALTERNATE_NAMES: Iterable[str] = ["xml"]
94
+
95
+ # Well, it's permissive by XML parser standards.
96
+ features: Iterable[str] = [NAME, LXML, XML, FAST, PERMISSIVE]
97
+
98
+ CHUNK_SIZE: int = 512
99
+
100
+ # This namespace mapping is specified in the XML Namespace
101
+ # standard.
102
+ DEFAULT_NSMAPS: _NamespaceMapping = dict(xml="http://www.w3.org/XML/1998/namespace")
103
+
104
+ DEFAULT_NSMAPS_INVERTED: _InvertedNamespaceMapping = _invert(DEFAULT_NSMAPS)
105
+
106
+ nsmaps: List[Optional[_InvertedNamespaceMapping]]
107
+ empty_element_tags: Optional[Set[str]]
108
+ parser: Any
109
+ _default_parser: Optional[etree.XMLParser]
110
+
111
+ # NOTE: If we parsed Element objects and looked at .sourceline,
112
+ # we'd be able to see the line numbers from the original document.
113
+ # But instead we build an XMLParser or HTMLParser object to serve
114
+ # as the target of parse messages, and those messages don't include
115
+ # line numbers.
116
+ # See: https://bugs.launchpad.net/lxml/+bug/1846906
117
+
118
+ def initialize_soup(self, soup: BeautifulSoup) -> None:
119
+ """Let the BeautifulSoup object know about the standard namespace
120
+ mapping.
121
+
122
+ :param soup: A `BeautifulSoup`.
123
+ """
124
+ # Beyond this point, self.soup is set, so we can assume (and
125
+ # assert) it's not None whenever necessary.
126
+ super(LXMLTreeBuilderForXML, self).initialize_soup(soup)
127
+ self._register_namespaces(self.DEFAULT_NSMAPS)
128
+
129
+ def _register_namespaces(self, mapping: Dict[str, str]) -> None:
130
+ """Let the BeautifulSoup object know about namespaces encountered
131
+ while parsing the document.
132
+
133
+ This might be useful later on when creating CSS selectors.
134
+
135
+ This will track (almost) all namespaces, even ones that were
136
+ only in scope for part of the document. If two namespaces have
137
+ the same prefix, only the first one encountered will be
138
+ tracked. Un-prefixed namespaces are not tracked.
139
+
140
+ :param mapping: A dictionary mapping namespace prefixes to URIs.
141
+ """
142
+ assert self.soup is not None
143
+ for key, value in list(mapping.items()):
144
+ # This is 'if key' and not 'if key is not None' because we
145
+ # don't track un-prefixed namespaces. Soupselect will
146
+ # treat an un-prefixed namespace as the default, which
147
+ # causes confusion in some cases.
148
+ if key and key not in self.soup._namespaces:
149
+ # Let the BeautifulSoup object know about a new namespace.
150
+ # If there are multiple namespaces defined with the same
151
+ # prefix, the first one in the document takes precedence.
152
+ self.soup._namespaces[key] = value
153
+
154
+ def default_parser(self, encoding: Optional[_Encoding]) -> _ParserOrParserClass:
155
+ """Find the default parser for the given encoding.
156
+
157
+ :return: Either a parser object or a class, which
158
+ will be instantiated with default arguments.
159
+ """
160
+ if self._default_parser is not None:
161
+ return self._default_parser
162
+ return self.DEFAULT_PARSER_CLASS(target=self, recover=True, huge_tree=self.huge_tree, encoding=encoding)
163
+
164
+ def parser_for(self, encoding: Optional[_Encoding]) -> _LXMLParser:
165
+ """Instantiate an appropriate parser for the given encoding.
166
+
167
+ :param encoding: A string.
168
+ :return: A parser object such as an `etree.XMLParser`.
169
+ """
170
+ # Use the default parser.
171
+ parser = self.default_parser(encoding)
172
+
173
+ if callable(parser):
174
+ # Instantiate the parser with default arguments
175
+ parser = parser(target=self, recover=True, huge_tree=self.huge_tree, encoding=encoding)
176
+ return parser
177
+
178
+ def __init__(
179
+ self,
180
+ parser: Optional[etree.XMLParser] = None,
181
+ empty_element_tags: Optional[Set[str]] = None,
182
+ huge_tree: bool = False,
183
+ **kwargs: Any,
184
+ ):
185
+ # TODO: Issue a warning if parser is present but not a
186
+ # callable, since that means there's no way to create new
187
+ # parsers for different encodings.
188
+ self._default_parser = parser
189
+ self.soup = None
190
+ self.nsmaps = [self.DEFAULT_NSMAPS_INVERTED]
191
+ self.active_namespace_prefixes = [dict(self.DEFAULT_NSMAPS)]
192
+ if self.is_xml:
193
+ self.processing_instruction_class = XMLProcessingInstruction
194
+ else:
195
+ self.processing_instruction_class = ProcessingInstruction
196
+
197
+ if "attribute_dict_class" not in kwargs:
198
+ kwargs["attribute_dict_class"] = XMLAttributeDict
199
+ self.huge_tree = huge_tree
200
+
201
+ super(LXMLTreeBuilderForXML, self).__init__(**kwargs)
202
+
203
+ def _getNsTag(self, tag: str) -> Tuple[Optional[str], str]:
204
+ # Split the namespace URL out of a fully-qualified lxml tag
205
+ # name. Copied from lxml's src/lxml/sax.py.
206
+ if tag[0] == "{" and "}" in tag:
207
+ namespace, name = tag[1:].split("}", 1)
208
+ return (namespace, name)
209
+ return (None, tag)
210
+
211
+ def prepare_markup(
212
+ self,
213
+ markup: _RawMarkup,
214
+ user_specified_encoding: Optional[_Encoding] = None,
215
+ document_declared_encoding: Optional[_Encoding] = None,
216
+ exclude_encodings: Optional[_Encodings] = None,
217
+ ) -> Iterable[
218
+ Tuple[Union[str, bytes], Optional[_Encoding], Optional[_Encoding], bool]
219
+ ]:
220
+ """Run any preliminary steps necessary to make incoming markup
221
+ acceptable to the parser.
222
+
223
+ lxml really wants to get a bytestring and convert it to
224
+ Unicode itself. So instead of using UnicodeDammit to convert
225
+ the bytestring to Unicode using different encodings, this
226
+ implementation uses EncodingDetector to iterate over the
227
+ encodings, and tell lxml to try to parse the document as each
228
+ one in turn.
229
+
230
+ :param markup: Some markup -- hopefully a bytestring.
231
+ :param user_specified_encoding: The user asked to try this encoding.
232
+ :param document_declared_encoding: The markup itself claims to be
233
+ in this encoding.
234
+ :param exclude_encodings: The user asked _not_ to try any of
235
+ these encodings.
236
+
237
+ :yield: A series of 4-tuples: (markup, encoding, declared encoding,
238
+ has undergone character replacement)
239
+
240
+ Each 4-tuple represents a strategy for converting the
241
+ document to Unicode and parsing it. Each strategy will be tried
242
+ in turn.
243
+ """
244
+ if not self.is_xml:
245
+ # We're in HTML mode, so if we're given XML, that's worth
246
+ # noting.
247
+ DetectsXMLParsedAsHTML.warn_if_markup_looks_like_xml(markup, stacklevel=3)
248
+
249
+ if isinstance(markup, str):
250
+ # We were given Unicode. Maybe lxml can parse Unicode on
251
+ # this system?
252
+
253
+ # TODO: This is a workaround for
254
+ # https://bugs.launchpad.net/lxml/+bug/1948551.
255
+ # We can remove it once the upstream issue is fixed.
256
+ if len(markup) > 0 and markup[0] == "\N{BYTE ORDER MARK}":
257
+ markup = markup[1:]
258
+ yield markup, None, document_declared_encoding, False
259
+
260
+ if isinstance(markup, str):
261
+ # No, apparently not. Convert the Unicode to UTF-8 and
262
+ # tell lxml to parse it as UTF-8.
263
+ yield (markup.encode("utf8"), "utf8", document_declared_encoding, False)
264
+
265
+ # Since the document was Unicode in the first place, there
266
+ # is no need to try any more strategies; we know this will
267
+ # work.
268
+ return
269
+
270
+ known_definite_encodings: List[_Encoding] = []
271
+ if user_specified_encoding:
272
+ # This was provided by the end-user; treat it as a known
273
+ # definite encoding per the algorithm laid out in the
274
+ # HTML5 spec. (See the EncodingDetector class for
275
+ # details.)
276
+ known_definite_encodings.append(user_specified_encoding)
277
+
278
+ user_encodings: List[_Encoding] = []
279
+ if document_declared_encoding:
280
+ # This was found in the document; treat it as a slightly
281
+ # lower-priority user encoding.
282
+ user_encodings.append(document_declared_encoding)
283
+
284
+ detector = EncodingDetector(
285
+ markup,
286
+ known_definite_encodings=known_definite_encodings,
287
+ user_encodings=user_encodings,
288
+ is_html=not self.is_xml,
289
+ exclude_encodings=exclude_encodings,
290
+ )
291
+ for encoding in detector.encodings:
292
+ yield (detector.markup, encoding, document_declared_encoding, False)
293
+
294
+ def feed(self, markup: _RawMarkup) -> None:
295
+ io: Union[BytesIO, StringIO]
296
+ if isinstance(markup, bytes):
297
+ io = BytesIO(markup)
298
+ elif isinstance(markup, str):
299
+ io = StringIO(markup)
300
+
301
+ # initialize_soup is called before feed, so we know this
302
+ # is not None.
303
+ assert self.soup is not None
304
+
305
+ # Call feed() at least once, even if the markup is empty,
306
+ # or the parser won't be initialized.
307
+ data = io.read(self.CHUNK_SIZE)
308
+ try:
309
+ self.parser = self.parser_for(self.soup.original_encoding)
310
+ self.parser.feed(data)
311
+ while len(data) != 0:
312
+ # Now call feed() on the rest of the data, chunk by chunk.
313
+ data = io.read(self.CHUNK_SIZE)
314
+ if len(data) != 0:
315
+ self.parser.feed(data)
316
+ self.parser.close()
317
+ except (UnicodeDecodeError, LookupError, etree.ParserError) as e:
318
+ raise ParserRejectedMarkup(e)
319
+
320
+ def close(self) -> None:
321
+ self.nsmaps = [self.DEFAULT_NSMAPS_INVERTED]
322
+
323
+ def start(
324
+ self,
325
+ tag: str | bytes,
326
+ attrib: Dict[str | bytes, str | bytes],
327
+ nsmap: _NamespaceMapping = {},
328
+ ) -> None:
329
+ # This is called by lxml code as a result of calling
330
+ # BeautifulSoup.feed(), and we know self.soup is set by the time feed()
331
+ # is called.
332
+ assert self.soup is not None
333
+ assert isinstance(tag, str)
334
+
335
+ # We need to recreate the attribute dict for three
336
+ # reasons. First, for type checking, so we can assert there
337
+ # are no bytestrings in the keys or values. Second, because we
338
+ # need a mutable dict--lxml might send us an immutable
339
+ # dictproxy. Third, so we can handle namespaced attribute
340
+ # names by converting the keys to NamespacedAttributes.
341
+ new_attrib: Dict[Union[str, NamespacedAttribute], str] = (
342
+ self.attribute_dict_class()
343
+ )
344
+ for k, v in attrib.items():
345
+ assert isinstance(k, str)
346
+ assert isinstance(v, str)
347
+ new_attrib[k] = v
348
+
349
+ nsprefix: Optional[_NamespacePrefix] = None
350
+ namespace: Optional[_NamespaceURL] = None
351
+ # Invert each namespace map as it comes in.
352
+ if len(nsmap) == 0 and len(self.nsmaps) > 1:
353
+ # There are no new namespaces for this tag, but
354
+ # non-default namespaces are in play, so we need a
355
+ # separate tag stack to know when they end.
356
+ self.nsmaps.append(None)
357
+ elif len(nsmap) > 0:
358
+ # A new namespace mapping has come into play.
359
+
360
+ # First, Let the BeautifulSoup object know about it.
361
+ self._register_namespaces(nsmap)
362
+
363
+ # Then, add it to our running list of inverted namespace
364
+ # mappings.
365
+ self.nsmaps.append(_invert(nsmap))
366
+
367
+ # The currently active namespace prefixes have
368
+ # changed. Calculate the new mapping so it can be stored
369
+ # with all Tag objects created while these prefixes are in
370
+ # scope.
371
+ current_mapping = dict(self.active_namespace_prefixes[-1])
372
+ current_mapping.update(nsmap)
373
+
374
+ # We should not track un-prefixed namespaces as we can only hold one
375
+ # and it will be recognized as the default namespace by soupsieve,
376
+ # which may be confusing in some situations.
377
+ if "" in current_mapping:
378
+ del current_mapping[""]
379
+ self.active_namespace_prefixes.append(current_mapping)
380
+
381
+ # Also treat the namespace mapping as a set of attributes on the
382
+ # tag, so we can recreate it later.
383
+ for prefix, namespace in list(nsmap.items()):
384
+ attribute = NamespacedAttribute(
385
+ "xmlns", prefix, "http://www.w3.org/2000/xmlns/"
386
+ )
387
+ new_attrib[attribute] = namespace
388
+
389
+ # Namespaces are in play. Find any attributes that came in
390
+ # from lxml with namespaces attached to their names, and
391
+ # turn then into NamespacedAttribute objects.
392
+ final_attrib: AttributeDict = self.attribute_dict_class()
393
+ for attr, value in list(new_attrib.items()):
394
+ namespace, attr = self._getNsTag(attr)
395
+ if namespace is None:
396
+ final_attrib[attr] = value
397
+ else:
398
+ nsprefix = self._prefix_for_namespace(namespace)
399
+ attr = NamespacedAttribute(nsprefix, attr, namespace)
400
+ final_attrib[attr] = value
401
+
402
+ namespace, tag = self._getNsTag(tag)
403
+ nsprefix = self._prefix_for_namespace(namespace)
404
+ self.soup.handle_starttag(
405
+ tag,
406
+ namespace,
407
+ nsprefix,
408
+ final_attrib,
409
+ namespaces=self.active_namespace_prefixes[-1],
410
+ )
411
+
412
+ def _prefix_for_namespace(
413
+ self, namespace: Optional[_NamespaceURL]
414
+ ) -> Optional[_NamespacePrefix]:
415
+ """Find the currently active prefix for the given namespace."""
416
+ if namespace is None:
417
+ return None
418
+ for inverted_nsmap in reversed(self.nsmaps):
419
+ if inverted_nsmap is not None and namespace in inverted_nsmap:
420
+ return inverted_nsmap[namespace]
421
+ return None
422
+
423
+ def end(self, tag: str | bytes) -> None:
424
+ assert self.soup is not None
425
+ assert isinstance(tag, str)
426
+ self.soup.endData()
427
+ namespace, tag = self._getNsTag(tag)
428
+ nsprefix = None
429
+ if namespace is not None:
430
+ for inverted_nsmap in reversed(self.nsmaps):
431
+ if inverted_nsmap is not None and namespace in inverted_nsmap:
432
+ nsprefix = inverted_nsmap[namespace]
433
+ break
434
+ self.soup.handle_endtag(tag, nsprefix)
435
+ if len(self.nsmaps) > 1:
436
+ # This tag, or one of its parents, introduced a namespace
437
+ # mapping, so pop it off the stack.
438
+ out_of_scope_nsmap = self.nsmaps.pop()
439
+
440
+ if out_of_scope_nsmap is not None:
441
+ # This tag introduced a namespace mapping which is no
442
+ # longer in scope. Recalculate the currently active
443
+ # namespace prefixes.
444
+ self.active_namespace_prefixes.pop()
445
+
446
+ def pi(self, target: str, data: str) -> None:
447
+ assert self.soup is not None
448
+ self.soup.endData()
449
+ data = target + " " + data
450
+ self.soup.handle_data(data)
451
+ self.soup.endData(self.processing_instruction_class)
452
+
453
+ def data(self, data: str | bytes) -> None:
454
+ assert self.soup is not None
455
+ assert isinstance(data, str)
456
+ self.soup.handle_data(data)
457
+
458
+ def doctype(self, name: str, pubid: str, system: str) -> None:
459
+ assert self.soup is not None
460
+ self.soup.endData()
461
+ doctype_string = Doctype._string_for_name_and_ids(name, pubid, system)
462
+ self.soup.handle_data(doctype_string)
463
+ self.soup.endData(containerClass=Doctype)
464
+
465
+ def comment(self, text: str | bytes) -> None:
466
+ "Handle comments as Comment objects."
467
+ assert self.soup is not None
468
+ assert isinstance(text, str)
469
+ self.soup.endData()
470
+ self.soup.handle_data(text)
471
+ self.soup.endData(Comment)
472
+
473
+ def test_fragment_to_document(self, fragment: str) -> str:
474
+ """See `TreeBuilder`."""
475
+ return '<?xml version="1.0" encoding="utf-8"?>\n%s' % fragment
476
+
477
+
478
+ class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML):
479
+ NAME: str = LXML
480
+ ALTERNATE_NAMES: Iterable[str] = ["lxml-html"]
481
+
482
+ features: Iterable[str] = list(ALTERNATE_NAMES) + [NAME, HTML, FAST, PERMISSIVE]
483
+ is_xml: bool = False
484
+
485
+ def default_parser(self, encoding: Optional[_Encoding]) -> _ParserOrParserClass:
486
+ return etree.HTMLParser
487
+
488
+ def feed(self, markup: _RawMarkup) -> None:
489
+ # We know self.soup is set by the time feed() is called.
490
+ assert self.soup is not None
491
+ encoding = self.soup.original_encoding
492
+ try:
493
+ self.parser = self.parser_for(encoding)
494
+ self.parser.feed(markup)
495
+ self.parser.close()
496
+ except (UnicodeDecodeError, LookupError, etree.ParserError) as e:
497
+ raise ParserRejectedMarkup(e)
498
+
499
+ def test_fragment_to_document(self, fragment: str) -> str:
500
+ """See `TreeBuilder`."""
501
+ return "<html><body>%s</body></html>" % fragment
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (2.18 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_api.cpython-311.pyc ADDED
Binary file (25.8 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_async_read_write.cpython-311.pyc ADDED
Binary file (11.2 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_error.cpython-311.pyc ADDED
Binary file (1.95 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_read_write.cpython-311.pyc ADDED
Binary file (20.5 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_soft.cpython-311.pyc ADDED
Binary file (8.24 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_unix.cpython-311.pyc ADDED
Binary file (6.83 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_util.cpython-311.pyc ADDED
Binary file (2.19 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/_windows.cpython-311.pyc ADDED
Binary file (5.48 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/asyncio.cpython-311.pyc ADDED
Binary file (17.8 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/filelock/__pycache__/version.cpython-311.pyc ADDED
Binary file (897 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (922 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/__init__.py ADDED
File without changes
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (202 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/aot_autograd/__init__.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # This file has moved to under torch/_functorch. It is not public API.
2
+ # If you are not a PyTorch developer and you are relying on the following
3
+ # imports, please file an issue.
4
+ from torch._functorch.aot_autograd import (
5
+ aot_autograd_decompositions,
6
+ KNOWN_TYPES,
7
+ PytreeThunk,
8
+ )
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/aot_autograd/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (390 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/eager_transforms/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # This file has moved to under torch/_functorch. It is not public API.
2
+ # If you are not a PyTorch developer and you are relying on the following
3
+ # imports, please file an issue.
4
+ from torch._functorch.eager_transforms import (
5
+ _assert_wrapped_functional,
6
+ _unwrap_functional_tensor,
7
+ )
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/eager_transforms/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (379 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/make_functional/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # This file has moved to under torch/_functorch. It is not public API.
2
+ # If you are not a PyTorch developer and you are relying on the following
3
+ # imports, please file an issue.
4
+ from torch._functorch.make_functional import _swap_state
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/make_functional/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (302 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/vmap/__init__.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file has moved to under torch/_functorch. It is not public API.
2
+ # If you are not a PyTorch developer and you are relying on the following
3
+ # imports, please file an issue.
4
+ from torch._functorch.vmap import (
5
+ _add_batch_dim,
6
+ _broadcast_to_and_flatten,
7
+ _create_batched_inputs,
8
+ _get_name,
9
+ _process_batched_inputs,
10
+ _remove_batch_dim,
11
+ _unwrap_batched,
12
+ _validate_and_get_batch_size,
13
+ Tensor,
14
+ tree_flatten,
15
+ tree_unflatten,
16
+ )
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/_src/vmap/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (678 Bytes). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/compile/__init__.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from torch._functorch import config
2
+ from torch._functorch.aot_autograd import (
3
+ aot_function,
4
+ aot_module,
5
+ aot_module_simplified,
6
+ compiled_function,
7
+ compiled_module,
8
+ get_aot_compilation_context,
9
+ get_aot_graph_name,
10
+ get_graph_being_compiled,
11
+ make_boxed_compiler,
12
+ make_boxed_func,
13
+ )
14
+ from torch._functorch.compilers import (
15
+ debug_compile,
16
+ default_decompositions,
17
+ draw_graph_compile,
18
+ memory_efficient_fusion,
19
+ nnc_jit,
20
+ nop,
21
+ print_compile,
22
+ ts_compile,
23
+ )
24
+ from torch._functorch.fx_minifier import minifier
25
+ from torch._functorch.partitioners import (
26
+ default_partition,
27
+ draw_graph,
28
+ min_cut_rematerialization_partition,
29
+ )
30
+ from torch._functorch.python_key import pythonkey_decompose
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/compile/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (1.4 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/dim/__init__.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import dis
2
+ import inspect
3
+ from typing import Sequence, Union
4
+
5
+ import functorch._C
6
+ import torch
7
+ from functorch._C import dim as _C
8
+
9
+ from .tree_map import tree_flatten, tree_map
10
+ from .wrap_type import wrap_type
11
+
12
+
13
+ _C._patch_tensor_class()
14
+ dims, DimList, dimlists = _C.dims, _C.DimList, _C.dimlists
15
+
16
+
17
+ class DimensionMismatchError(Exception):
18
+ pass
19
+
20
+
21
+ class DimensionBindError(Exception):
22
+ pass
23
+
24
+
25
+ from . import op_properties
26
+
27
+
28
+ # use dict to avoid writing C++ bindings for set
29
+ pointwise = dict.fromkeys(op_properties.pointwise, True)
30
+
31
+ use_c = True
32
+ if not use_c:
33
+ from . import reference
34
+
35
+
36
+ class _Tensor:
37
+ # fast path around slow wrapping/unwrapping logic for simply queries used
38
+ # by the implementation...
39
+
40
+ @property
41
+ def dims(self):
42
+ return tuple(d for d in self._levels if isinstance(d, Dim))
43
+
44
+ def dim(self):
45
+ return self.ndim
46
+
47
+ if use_c:
48
+ __torch_function__ = classmethod(_C.__torch_function__)
49
+ expand = _C._instancemethod(_C.expand)
50
+ else:
51
+ __torch_function__ = reference.__torch_function__
52
+ expand = reference.expand
53
+
54
+ index = _C._instancemethod(_C.index)
55
+
56
+ def __repr__(self):
57
+ tensor, levels, ndim = self._tensor, self._levels, self.ndim
58
+ return f"{tensor}\nwith dims={tuple(l + ndim if isinstance(l, int) else l for l in levels)} sizes={tuple(tensor.size())}"
59
+
60
+
61
+ TensorLike = (_Tensor, torch.Tensor)
62
+
63
+
64
+ class Dim(_C.Dim, _Tensor):
65
+ # note that _C.Dim comes before tensor because we want the Dim API for things like size to take precendence.
66
+ # Tensor defines format, but we want to print Dims with special formatting
67
+ __format__ = object.__format__
68
+
69
+
70
+ class Tensor(_Tensor, _C.Tensor):
71
+ if not use_c:
72
+ from_batched = staticmethod(_C.Tensor_from_batched)
73
+ from_positional = staticmethod(_C.Tensor_from_positional)
74
+ sum = _C._instancemethod(_C.Tensor_sum)
75
+
76
+
77
+ def cat(tensors, dim, new_dim):
78
+ n = dims()
79
+ return stack(tensors, n, dim).index([n, dim], new_dim)
80
+
81
+
82
+ if use_c:
83
+ _wrap = _C._wrap
84
+
85
+ def _def(name, *args, **kwargs):
86
+ orig = getattr(torch.Tensor, name)
87
+ setattr(_Tensor, name, _C._instancemethod(_wrap(orig, *args, **kwargs)))
88
+
89
+ t__getitem__ = _C._instancemethod(_C.__getitem__)
90
+ stack = _C.stack
91
+ split = _C._instancemethod(_C.split)
92
+ else:
93
+ _wrap, _def = reference._wrap, reference._def
94
+ t__getitem__ = reference.t__getitem__
95
+ stack = reference.stack
96
+ split = reference.split
97
+
98
+ # note: there is no python reference
99
+ t__setitem__ = _C._instancemethod(_C.__setitem__)
100
+ # this is patched in the C API because otherwise torch.Tensor will
101
+ # no longer be considered a sequence and things will break
102
+ # torch.Tensor.__getitem__ = t__getitem__
103
+
104
+ _Tensor.__getitem__ = t__getitem__
105
+ # torch.Tensor.__setitem__ = t__setitem__
106
+ _Tensor.__setitem__ = t__setitem__
107
+
108
+ torch.Tensor.split = split
109
+ _Tensor.split = split
110
+ torch.Tensor.expand = _C._instancemethod(_C.expand)
111
+ torch.Tensor.index = _C._instancemethod(_C.index)
112
+ wrap_type(use_c, _Tensor, torch.Tensor, _Tensor.__torch_function__)
113
+ del _Tensor.ndim
114
+
115
+ if use_c:
116
+ _Tensor.order = _C._instancemethod(_C.order)
117
+ else:
118
+ _Tensor.order = reference.positional
119
+
120
+ _def("mean")
121
+ _def("sum")
122
+ _def("all")
123
+ _def("amax")
124
+ _def("amin")
125
+ _def("aminmax")
126
+ _def("any")
127
+ _def("count_nonzero")
128
+ _def("logsumexp")
129
+ _def("nanmean")
130
+ _def("nansum")
131
+ _def("prod")
132
+ _def("std", keepdim_offset=2)
133
+ _def("var", keepdim_offset=2)
134
+ _def("max", single_dim=True)
135
+ _def("min", single_dim=True)
136
+ _def("argmax", single_dim=True)
137
+ _def("argmin", single_dim=True)
138
+ _def("kthvalue", single_dim=True)
139
+ _def("median", single_dim=True)
140
+ _def("nanmedian", single_dim=True)
141
+ _def("mode", single_dim=True)
142
+ _def("sort", reduce=False)
143
+ _def("argsort", reduce=False)
144
+ _def("unbind", single_dim=True)
145
+ _def("chunk", dim_offset=1, reduce=False)
146
+ _def("cummax", single_dim=True, reduce=False)
147
+ _def("cummin", single_dim=True, reduce=False)
148
+ _def("cumprod", single_dim=True, reduce=False)
149
+ _def("cumprod_", single_dim=True, reduce=False)
150
+ _def("cumsum", single_dim=True, reduce=False)
151
+ _def("cumsum_", single_dim=True, reduce=False)
152
+ _def("logcumsumexp", single_dim=True, reduce=False)
153
+ _def("renorm", dim_offset=1, single_dim=True, reduce=False)
154
+ _def("softmax", single_dim=True, reduce=False)
155
+ softmax = _wrap(torch.nn.functional.softmax, single_dim=True, reduce=False)
156
+
157
+ # stuff to handle in the future, because they require special
158
+ # binding logic for dims
159
+ # cross
160
+ # diag_embed
161
+ # diagonal
162
+ # diagonal_scatter
163
+ # diff
164
+ # nanquantile
165
+ # quantile
166
+ # roll
167
+ # rot90
168
+ # topk (new dimes on output)
169
+ # should these all be subsumed by inplace indexing?
170
+ # index_add_
171
+ # index_add
172
+ # index_copy
173
+ # index_copy_
174
+ # index_fill
175
+ # index_fill_
176
+ # index_select
177
+ # scatter
178
+ # scatter_
179
+ # scatter_add
180
+ # scatter_add_
181
+ # scatter_reduce
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/dim/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (7.87 kB). View file
 
data/conda_envs/evalclaw/lib/python3.11/site-packages/functorch/dim/__pycache__/batch_tensor.cpython-311.pyc ADDED
Binary file (1.27 kB). View file