jasonfan commited on
Commit
d5a2398
·
verified ·
1 Parent(s): 8d98ffb

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. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/INSTALLER +1 -0
  2. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/METADATA +350 -0
  3. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/RECORD +24 -0
  4. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/REQUESTED +0 -0
  5. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/WHEEL +4 -0
  6. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/direct_url.json +1 -0
  7. miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/licenses/LICENSE +21 -0
  8. miniconda3/lib/python3.13/site-packages/platformdirs/api.py +299 -0
  9. miniconda3/lib/python3.13/site-packages/platformdirs/macos.py +146 -0
  10. miniconda3/lib/python3.13/site-packages/platformdirs/py.typed +0 -0
  11. miniconda3/lib/python3.13/site-packages/platformdirs/unix.py +272 -0
  12. miniconda3/lib/python3.13/site-packages/platformdirs/version.py +21 -0
  13. miniconda3/lib/python3.13/site-packages/platformdirs/windows.py +272 -0
  14. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/INSTALLER +1 -0
  15. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/LICENSE +21 -0
  16. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/METADATA +155 -0
  17. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/RECORD +25 -0
  18. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/REQUESTED +0 -0
  19. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/WHEEL +5 -0
  20. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/direct_url.json +1 -0
  21. miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/top_level.txt +1 -0
  22. miniconda3/lib/python3.13/site-packages/pluggy/__init__.py +37 -0
  23. miniconda3/lib/python3.13/site-packages/pluggy/_callers.py +182 -0
  24. miniconda3/lib/python3.13/site-packages/pluggy/_hooks.py +715 -0
  25. miniconda3/lib/python3.13/site-packages/pluggy/_manager.py +528 -0
  26. miniconda3/lib/python3.13/site-packages/pluggy/_result.py +104 -0
  27. miniconda3/lib/python3.13/site-packages/pluggy/_tracing.py +73 -0
  28. miniconda3/lib/python3.13/site-packages/pluggy/_version.py +16 -0
  29. miniconda3/lib/python3.13/site-packages/pluggy/_warnings.py +27 -0
  30. miniconda3/lib/python3.13/site-packages/pluggy/py.typed +0 -0
  31. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/AUTHORS.md +15 -0
  32. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/INSTALLER +1 -0
  33. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/LICENSE +19 -0
  34. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/METADATA +140 -0
  35. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/RECORD +12 -0
  36. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/REQUESTED +0 -0
  37. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/WHEEL +5 -0
  38. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/direct_url.json +1 -0
  39. miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/top_level.txt +2 -0
  40. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/INSTALLER +1 -0
  41. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/METADATA +39 -0
  42. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/RECORD +43 -0
  43. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/REQUESTED +0 -0
  44. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/WHEEL +5 -0
  45. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/direct_url.json +1 -0
  46. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/licenses/LICENSE +27 -0
  47. miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/top_level.txt +1 -0
  48. miniconda3/lib/python3.13/site-packages/pycparser/__init__.py +93 -0
  49. miniconda3/lib/python3.13/site-packages/pycparser/_ast_gen.py +336 -0
  50. miniconda3/lib/python3.13/site-packages/pycparser/_build_tables.py +40 -0
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/METADATA ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: platformdirs
3
+ Version: 4.5.0
4
+ Summary: A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.
5
+ Project-URL: Changelog, https://github.com/tox-dev/platformdirs/releases
6
+ Project-URL: Documentation, https://platformdirs.readthedocs.io
7
+ Project-URL: Homepage, https://github.com/tox-dev/platformdirs
8
+ Project-URL: Source, https://github.com/tox-dev/platformdirs
9
+ Project-URL: Tracker, https://github.com/tox-dev/platformdirs/issues
10
+ Maintainer-email: Bernát Gábor <gaborjbernat@gmail.com>, Julian Berman <Julian@GrayVines.com>, Ofek Lev <oss@ofek.dev>, Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: appdirs,application,cache,directory,log,user
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Programming Language :: Python :: Implementation :: CPython
26
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Requires-Python: >=3.10
29
+ Provides-Extra: docs
30
+ Requires-Dist: furo>=2025.9.25; extra == 'docs'
31
+ Requires-Dist: proselint>=0.14; extra == 'docs'
32
+ Requires-Dist: sphinx-autodoc-typehints>=3.2; extra == 'docs'
33
+ Requires-Dist: sphinx>=8.2.3; extra == 'docs'
34
+ Provides-Extra: test
35
+ Requires-Dist: appdirs==1.4.4; extra == 'test'
36
+ Requires-Dist: covdefaults>=2.3; extra == 'test'
37
+ Requires-Dist: pytest-cov>=7; extra == 'test'
38
+ Requires-Dist: pytest-mock>=3.15.1; extra == 'test'
39
+ Requires-Dist: pytest>=8.4.2; extra == 'test'
40
+ Provides-Extra: type
41
+ Requires-Dist: mypy>=1.18.2; extra == 'type'
42
+ Description-Content-Type: text/x-rst
43
+
44
+ The problem
45
+ ===========
46
+
47
+ .. image:: https://badge.fury.io/py/platformdirs.svg
48
+ :target: https://badge.fury.io/py/platformdirs
49
+ .. image:: https://img.shields.io/pypi/pyversions/platformdirs.svg
50
+ :target: https://pypi.python.org/pypi/platformdirs/
51
+ .. image:: https://github.com/tox-dev/platformdirs/actions/workflows/check.yaml/badge.svg
52
+ :target: https://github.com/platformdirs/platformdirs/actions
53
+ .. image:: https://static.pepy.tech/badge/platformdirs/month
54
+ :target: https://pepy.tech/project/platformdirs
55
+
56
+ When writing desktop application, finding the right location to store user data
57
+ and configuration varies per platform. Even for single-platform apps, there
58
+ may by plenty of nuances in figuring out the right location.
59
+
60
+ For example, if running on macOS, you should use::
61
+
62
+ ~/Library/Application Support/<AppName>
63
+
64
+ If on Windows (at least English Win) that should be::
65
+
66
+ C:\Users\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>
67
+
68
+ or possibly::
69
+
70
+ C:\Users\<User>\Application Data\<AppAuthor>\<AppName>
71
+
72
+ for `roaming profiles <https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc766489(v=ws.10)>`_ but that is another story.
73
+
74
+ On Linux (and other Unices), according to the `XDG Basedir Spec`_, it should be::
75
+
76
+ ~/.local/share/<AppName>
77
+
78
+ .. _XDG Basedir Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
79
+
80
+ ``platformdirs`` to the rescue
81
+ ==============================
82
+
83
+ This kind of thing is what the ``platformdirs`` package is for.
84
+ ``platformdirs`` will help you choose an appropriate:
85
+
86
+ - user data dir (``user_data_dir``)
87
+ - user config dir (``user_config_dir``)
88
+ - user cache dir (``user_cache_dir``)
89
+ - site data dir (``site_data_dir``)
90
+ - site config dir (``site_config_dir``)
91
+ - user log dir (``user_log_dir``)
92
+ - user documents dir (``user_documents_dir``)
93
+ - user downloads dir (``user_downloads_dir``)
94
+ - user pictures dir (``user_pictures_dir``)
95
+ - user videos dir (``user_videos_dir``)
96
+ - user music dir (``user_music_dir``)
97
+ - user desktop dir (``user_desktop_dir``)
98
+ - user runtime dir (``user_runtime_dir``)
99
+
100
+ And also:
101
+
102
+ - Is slightly opinionated on the directory names used. Look for "OPINION" in
103
+ documentation and code for when an opinion is being applied.
104
+
105
+ Example output
106
+ ==============
107
+
108
+ On macOS:
109
+
110
+ .. code-block:: pycon
111
+
112
+ >>> from platformdirs import *
113
+ >>> appname = "SuperApp"
114
+ >>> appauthor = "Acme"
115
+ >>> user_data_dir(appname, appauthor)
116
+ '/Users/trentm/Library/Application Support/SuperApp'
117
+ >>> user_config_dir(appname, appauthor)
118
+ '/Users/trentm/Library/Application Support/SuperApp'
119
+ >>> user_cache_dir(appname, appauthor)
120
+ '/Users/trentm/Library/Caches/SuperApp'
121
+ >>> site_data_dir(appname, appauthor)
122
+ '/Library/Application Support/SuperApp'
123
+ >>> site_config_dir(appname, appauthor)
124
+ '/Library/Application Support/SuperApp'
125
+ >>> user_log_dir(appname, appauthor)
126
+ '/Users/trentm/Library/Logs/SuperApp'
127
+ >>> user_documents_dir()
128
+ '/Users/trentm/Documents'
129
+ >>> user_downloads_dir()
130
+ '/Users/trentm/Downloads'
131
+ >>> user_pictures_dir()
132
+ '/Users/trentm/Pictures'
133
+ >>> user_videos_dir()
134
+ '/Users/trentm/Movies'
135
+ >>> user_music_dir()
136
+ '/Users/trentm/Music'
137
+ >>> user_desktop_dir()
138
+ '/Users/trentm/Desktop'
139
+ >>> user_runtime_dir(appname, appauthor)
140
+ '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
141
+
142
+ On Windows:
143
+
144
+ .. code-block:: pycon
145
+
146
+ >>> from platformdirs import *
147
+ >>> appname = "SuperApp"
148
+ >>> appauthor = "Acme"
149
+ >>> user_data_dir(appname, appauthor)
150
+ 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
151
+ >>> user_data_dir(appname, appauthor, roaming=True)
152
+ 'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp'
153
+ >>> user_config_dir(appname, appauthor)
154
+ 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
155
+ >>> user_cache_dir(appname, appauthor)
156
+ 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache'
157
+ >>> site_data_dir(appname, appauthor)
158
+ 'C:\\ProgramData\\Acme\\SuperApp'
159
+ >>> site_config_dir(appname, appauthor)
160
+ 'C:\\ProgramData\\Acme\\SuperApp'
161
+ >>> user_log_dir(appname, appauthor)
162
+ 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs'
163
+ >>> user_documents_dir()
164
+ 'C:\\Users\\trentm\\Documents'
165
+ >>> user_downloads_dir()
166
+ 'C:\\Users\\trentm\\Downloads'
167
+ >>> user_pictures_dir()
168
+ 'C:\\Users\\trentm\\Pictures'
169
+ >>> user_videos_dir()
170
+ 'C:\\Users\\trentm\\Videos'
171
+ >>> user_music_dir()
172
+ 'C:\\Users\\trentm\\Music'
173
+ >>> user_desktop_dir()
174
+ 'C:\\Users\\trentm\\Desktop'
175
+ >>> user_runtime_dir(appname, appauthor)
176
+ 'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp'
177
+
178
+ On Linux:
179
+
180
+ .. code-block:: pycon
181
+
182
+ >>> from platformdirs import *
183
+ >>> appname = "SuperApp"
184
+ >>> appauthor = "Acme"
185
+ >>> user_data_dir(appname, appauthor)
186
+ '/home/trentm/.local/share/SuperApp'
187
+ >>> user_config_dir(appname)
188
+ '/home/trentm/.config/SuperApp'
189
+ >>> user_cache_dir(appname, appauthor)
190
+ '/home/trentm/.cache/SuperApp'
191
+ >>> site_data_dir(appname, appauthor)
192
+ '/usr/local/share/SuperApp'
193
+ >>> site_data_dir(appname, appauthor, multipath=True)
194
+ '/usr/local/share/SuperApp:/usr/share/SuperApp'
195
+ >>> site_config_dir(appname)
196
+ '/etc/xdg/SuperApp'
197
+ >>> os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"
198
+ >>> site_config_dir(appname, multipath=True)
199
+ '/etc/SuperApp:/usr/local/etc/SuperApp'
200
+ >>> user_log_dir(appname, appauthor)
201
+ '/home/trentm/.local/state/SuperApp/log'
202
+ >>> user_documents_dir()
203
+ '/home/trentm/Documents'
204
+ >>> user_downloads_dir()
205
+ '/home/trentm/Downloads'
206
+ >>> user_pictures_dir()
207
+ '/home/trentm/Pictures'
208
+ >>> user_videos_dir()
209
+ '/home/trentm/Videos'
210
+ >>> user_music_dir()
211
+ '/home/trentm/Music'
212
+ >>> user_desktop_dir()
213
+ '/home/trentm/Desktop'
214
+ >>> user_runtime_dir(appname, appauthor)
215
+ '/run/user/{os.getuid()}/SuperApp'
216
+
217
+ On Android::
218
+
219
+ >>> from platformdirs import *
220
+ >>> appname = "SuperApp"
221
+ >>> appauthor = "Acme"
222
+ >>> user_data_dir(appname, appauthor)
223
+ '/data/data/com.myApp/files/SuperApp'
224
+ >>> user_config_dir(appname)
225
+ '/data/data/com.myApp/shared_prefs/SuperApp'
226
+ >>> user_cache_dir(appname, appauthor)
227
+ '/data/data/com.myApp/cache/SuperApp'
228
+ >>> site_data_dir(appname, appauthor)
229
+ '/data/data/com.myApp/files/SuperApp'
230
+ >>> site_config_dir(appname)
231
+ '/data/data/com.myApp/shared_prefs/SuperApp'
232
+ >>> user_log_dir(appname, appauthor)
233
+ '/data/data/com.myApp/cache/SuperApp/log'
234
+ >>> user_documents_dir()
235
+ '/storage/emulated/0/Documents'
236
+ >>> user_downloads_dir()
237
+ '/storage/emulated/0/Downloads'
238
+ >>> user_pictures_dir()
239
+ '/storage/emulated/0/Pictures'
240
+ >>> user_videos_dir()
241
+ '/storage/emulated/0/DCIM/Camera'
242
+ >>> user_music_dir()
243
+ '/storage/emulated/0/Music'
244
+ >>> user_desktop_dir()
245
+ '/storage/emulated/0/Desktop'
246
+ >>> user_runtime_dir(appname, appauthor)
247
+ '/data/data/com.myApp/cache/SuperApp/tmp'
248
+
249
+ Note: Some android apps like Termux and Pydroid are used as shells. These
250
+ apps are used by the end user to emulate Linux environment. Presence of
251
+ ``SHELL`` environment variable is used by Platformdirs to differentiate
252
+ between general android apps and android apps used as shells. Shell android
253
+ apps also support ``XDG_*`` environment variables.
254
+
255
+
256
+ ``PlatformDirs`` for convenience
257
+ ================================
258
+
259
+ .. code-block:: pycon
260
+
261
+ >>> from platformdirs import PlatformDirs
262
+ >>> dirs = PlatformDirs("SuperApp", "Acme")
263
+ >>> dirs.user_data_dir
264
+ '/Users/trentm/Library/Application Support/SuperApp'
265
+ >>> dirs.user_config_dir
266
+ '/Users/trentm/Library/Application Support/SuperApp'
267
+ >>> dirs.user_cache_dir
268
+ '/Users/trentm/Library/Caches/SuperApp'
269
+ >>> dirs.site_data_dir
270
+ '/Library/Application Support/SuperApp'
271
+ >>> dirs.site_config_dir
272
+ '/Library/Application Support/SuperApp'
273
+ >>> dirs.user_cache_dir
274
+ '/Users/trentm/Library/Caches/SuperApp'
275
+ >>> dirs.user_log_dir
276
+ '/Users/trentm/Library/Logs/SuperApp'
277
+ >>> dirs.user_documents_dir
278
+ '/Users/trentm/Documents'
279
+ >>> dirs.user_downloads_dir
280
+ '/Users/trentm/Downloads'
281
+ >>> dirs.user_pictures_dir
282
+ '/Users/trentm/Pictures'
283
+ >>> dirs.user_videos_dir
284
+ '/Users/trentm/Movies'
285
+ >>> dirs.user_music_dir
286
+ '/Users/trentm/Music'
287
+ >>> dirs.user_desktop_dir
288
+ '/Users/trentm/Desktop'
289
+ >>> dirs.user_runtime_dir
290
+ '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
291
+
292
+ Per-version isolation
293
+ =====================
294
+
295
+ If you have multiple versions of your app in use that you want to be
296
+ able to run side-by-side, then you may want version-isolation for these
297
+ dirs::
298
+
299
+ >>> from platformdirs import PlatformDirs
300
+ >>> dirs = PlatformDirs("SuperApp", "Acme", version="1.0")
301
+ >>> dirs.user_data_dir
302
+ '/Users/trentm/Library/Application Support/SuperApp/1.0'
303
+ >>> dirs.user_config_dir
304
+ '/Users/trentm/Library/Application Support/SuperApp/1.0'
305
+ >>> dirs.user_cache_dir
306
+ '/Users/trentm/Library/Caches/SuperApp/1.0'
307
+ >>> dirs.site_data_dir
308
+ '/Library/Application Support/SuperApp/1.0'
309
+ >>> dirs.site_config_dir
310
+ '/Library/Application Support/SuperApp/1.0'
311
+ >>> dirs.user_log_dir
312
+ '/Users/trentm/Library/Logs/SuperApp/1.0'
313
+ >>> dirs.user_documents_dir
314
+ '/Users/trentm/Documents'
315
+ >>> dirs.user_downloads_dir
316
+ '/Users/trentm/Downloads'
317
+ >>> dirs.user_pictures_dir
318
+ '/Users/trentm/Pictures'
319
+ >>> dirs.user_videos_dir
320
+ '/Users/trentm/Movies'
321
+ >>> dirs.user_music_dir
322
+ '/Users/trentm/Music'
323
+ >>> dirs.user_desktop_dir
324
+ '/Users/trentm/Desktop'
325
+ >>> dirs.user_runtime_dir
326
+ '/Users/trentm/Library/Caches/TemporaryItems/SuperApp/1.0'
327
+
328
+ Be wary of using this for configuration files though; you'll need to handle
329
+ migrating configuration files manually.
330
+
331
+ Why this Fork?
332
+ ==============
333
+
334
+ This repository is a friendly fork of the wonderful work started by
335
+ `ActiveState <https://github.com/ActiveState/appdirs>`_ who created
336
+ ``appdirs``, this package's ancestor.
337
+
338
+ Maintaining an open source project is no easy task, particularly
339
+ from within an organization, and the Python community is indebted
340
+ to ``appdirs`` (and to Trent Mick and Jeff Rouse in particular) for
341
+ creating an incredibly useful simple module, as evidenced by the wide
342
+ number of users it has attracted over the years.
343
+
344
+ Nonetheless, given the number of long-standing open issues
345
+ and pull requests, and no clear path towards `ensuring
346
+ that maintenance of the package would continue or grow
347
+ <https://github.com/ActiveState/appdirs/issues/79>`_, this fork was
348
+ created.
349
+
350
+ Contributions are most welcome.
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/RECORD ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ platformdirs-4.5.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ platformdirs-4.5.0.dist-info/METADATA,sha256=mFxZl6Q-fO2nCdWWCJT4WOr4p7U12jZX4lk26MqGy1o,12804
3
+ platformdirs-4.5.0.dist-info/RECORD,,
4
+ platformdirs-4.5.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ platformdirs-4.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ platformdirs-4.5.0.dist-info/direct_url.json,sha256=lQH-GplgUjaVTxy8DMxY3ERjzo9R5XJoFS0LVVsIgGw,102
7
+ platformdirs-4.5.0.dist-info/licenses/LICENSE,sha256=KeD9YukphQ6G6yjD_czwzv30-pSHkBHP-z0NS-1tTbY,1089
8
+ platformdirs/__init__.py,sha256=iORRy6_lZ9tXLvO0W6fJPn8QV7F532ivl-f2WGmabBc,22284
9
+ platformdirs/__main__.py,sha256=HnsUQHpiBaiTxwcmwVw-nFaPdVNZtQIdi1eWDtI-MzI,1493
10
+ platformdirs/__pycache__/__init__.cpython-313.pyc,,
11
+ platformdirs/__pycache__/__main__.cpython-313.pyc,,
12
+ platformdirs/__pycache__/android.cpython-313.pyc,,
13
+ platformdirs/__pycache__/api.cpython-313.pyc,,
14
+ platformdirs/__pycache__/macos.cpython-313.pyc,,
15
+ platformdirs/__pycache__/unix.cpython-313.pyc,,
16
+ platformdirs/__pycache__/version.cpython-313.pyc,,
17
+ platformdirs/__pycache__/windows.cpython-313.pyc,,
18
+ platformdirs/android.py,sha256=r0DshVBf-RO1jXJGX8C4Til7F1XWt-bkdWMgmvEiaYg,9013
19
+ platformdirs/api.py,sha256=wPHOlwOsfz2oqQZ6A2FcCu5kEAj-JondzoNOHYFQ0h8,9281
20
+ platformdirs/macos.py,sha256=0XoOgin1NK7Qki7iskD-oS8xKxw6bXgoKEgdqpCRAFQ,6322
21
+ platformdirs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ platformdirs/unix.py,sha256=WZmkUA--L3JNRGmz32s35YfoD3ica6xKIPdCV_HhLcs,10458
23
+ platformdirs/version.py,sha256=ghBiiwST_TekbxAaCoGDq-02Sb8IhzrkJl3n7HTe4dc,511
24
+ platformdirs/windows.py,sha256=IFpiohUBwxPtCzlyKwNtxyW4Jk8haa6W8o59mfrDXVo,10125
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/REQUESTED ADDED
File without changes
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/direct_url.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"dir_info": {}, "url": "file:///home/task_176235602006708/conda-bld/platformdirs_1762356487962/work"}
miniconda3/lib/python3.13/site-packages/platformdirs-4.5.0.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2010-202x The platformdirs developers
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 all
13
+ 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 THE
21
+ SOFTWARE.
miniconda3/lib/python3.13/site-packages/platformdirs/api.py ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Base API."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from abc import ABC, abstractmethod
7
+ from pathlib import Path
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ from collections.abc import Iterator
12
+ from typing import Literal
13
+
14
+
15
+ class PlatformDirsABC(ABC): # noqa: PLR0904
16
+ """Abstract base class for platform directories."""
17
+
18
+ def __init__( # noqa: PLR0913, PLR0917
19
+ self,
20
+ appname: str | None = None,
21
+ appauthor: str | Literal[False] | None = None,
22
+ version: str | None = None,
23
+ roaming: bool = False, # noqa: FBT001, FBT002
24
+ multipath: bool = False, # noqa: FBT001, FBT002
25
+ opinion: bool = True, # noqa: FBT001, FBT002
26
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
27
+ ) -> None:
28
+ """
29
+ Create a new platform directory.
30
+
31
+ :param appname: See `appname`.
32
+ :param appauthor: See `appauthor`.
33
+ :param version: See `version`.
34
+ :param roaming: See `roaming`.
35
+ :param multipath: See `multipath`.
36
+ :param opinion: See `opinion`.
37
+ :param ensure_exists: See `ensure_exists`.
38
+
39
+ """
40
+ self.appname = appname #: The name of application.
41
+ self.appauthor = appauthor
42
+ """
43
+ The name of the app author or distributing body for this application.
44
+
45
+ Typically, it is the owning company name. Defaults to `appname`. You may pass ``False`` to disable it.
46
+
47
+ """
48
+ self.version = version
49
+ """
50
+ An optional version path element to append to the path.
51
+
52
+ You might want to use this if you want multiple versions of your app to be able to run independently. If used,
53
+ this would typically be ``<major>.<minor>``.
54
+
55
+ """
56
+ self.roaming = roaming
57
+ """
58
+ Whether to use the roaming appdata directory on Windows.
59
+
60
+ That means that for users on a Windows network setup for roaming profiles, this user data will be synced on
61
+ login (see
62
+ `here <https://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_).
63
+
64
+ """
65
+ self.multipath = multipath
66
+ """
67
+ An optional parameter which indicates that the entire list of data dirs should be returned.
68
+
69
+ By default, the first item would only be returned.
70
+
71
+ """
72
+ self.opinion = opinion #: A flag to indicating to use opinionated values.
73
+ self.ensure_exists = ensure_exists
74
+ """
75
+ Optionally create the directory (and any missing parents) upon access if it does not exist.
76
+
77
+ By default, no directories are created.
78
+
79
+ """
80
+
81
+ def _append_app_name_and_version(self, *base: str) -> str:
82
+ params = list(base[1:])
83
+ if self.appname:
84
+ params.append(self.appname)
85
+ if self.version:
86
+ params.append(self.version)
87
+ path = os.path.join(base[0], *params) # noqa: PTH118
88
+ self._optionally_create_directory(path)
89
+ return path
90
+
91
+ def _optionally_create_directory(self, path: str) -> None:
92
+ if self.ensure_exists:
93
+ Path(path).mkdir(parents=True, exist_ok=True)
94
+
95
+ def _first_item_as_path_if_multipath(self, directory: str) -> Path:
96
+ if self.multipath:
97
+ # If multipath is True, the first path is returned.
98
+ directory = directory.partition(os.pathsep)[0]
99
+ return Path(directory)
100
+
101
+ @property
102
+ @abstractmethod
103
+ def user_data_dir(self) -> str:
104
+ """:return: data directory tied to the user"""
105
+
106
+ @property
107
+ @abstractmethod
108
+ def site_data_dir(self) -> str:
109
+ """:return: data directory shared by users"""
110
+
111
+ @property
112
+ @abstractmethod
113
+ def user_config_dir(self) -> str:
114
+ """:return: config directory tied to the user"""
115
+
116
+ @property
117
+ @abstractmethod
118
+ def site_config_dir(self) -> str:
119
+ """:return: config directory shared by the users"""
120
+
121
+ @property
122
+ @abstractmethod
123
+ def user_cache_dir(self) -> str:
124
+ """:return: cache directory tied to the user"""
125
+
126
+ @property
127
+ @abstractmethod
128
+ def site_cache_dir(self) -> str:
129
+ """:return: cache directory shared by users"""
130
+
131
+ @property
132
+ @abstractmethod
133
+ def user_state_dir(self) -> str:
134
+ """:return: state directory tied to the user"""
135
+
136
+ @property
137
+ @abstractmethod
138
+ def user_log_dir(self) -> str:
139
+ """:return: log directory tied to the user"""
140
+
141
+ @property
142
+ @abstractmethod
143
+ def user_documents_dir(self) -> str:
144
+ """:return: documents directory tied to the user"""
145
+
146
+ @property
147
+ @abstractmethod
148
+ def user_downloads_dir(self) -> str:
149
+ """:return: downloads directory tied to the user"""
150
+
151
+ @property
152
+ @abstractmethod
153
+ def user_pictures_dir(self) -> str:
154
+ """:return: pictures directory tied to the user"""
155
+
156
+ @property
157
+ @abstractmethod
158
+ def user_videos_dir(self) -> str:
159
+ """:return: videos directory tied to the user"""
160
+
161
+ @property
162
+ @abstractmethod
163
+ def user_music_dir(self) -> str:
164
+ """:return: music directory tied to the user"""
165
+
166
+ @property
167
+ @abstractmethod
168
+ def user_desktop_dir(self) -> str:
169
+ """:return: desktop directory tied to the user"""
170
+
171
+ @property
172
+ @abstractmethod
173
+ def user_runtime_dir(self) -> str:
174
+ """:return: runtime directory tied to the user"""
175
+
176
+ @property
177
+ @abstractmethod
178
+ def site_runtime_dir(self) -> str:
179
+ """:return: runtime directory shared by users"""
180
+
181
+ @property
182
+ def user_data_path(self) -> Path:
183
+ """:return: data path tied to the user"""
184
+ return Path(self.user_data_dir)
185
+
186
+ @property
187
+ def site_data_path(self) -> Path:
188
+ """:return: data path shared by users"""
189
+ return Path(self.site_data_dir)
190
+
191
+ @property
192
+ def user_config_path(self) -> Path:
193
+ """:return: config path tied to the user"""
194
+ return Path(self.user_config_dir)
195
+
196
+ @property
197
+ def site_config_path(self) -> Path:
198
+ """:return: config path shared by the users"""
199
+ return Path(self.site_config_dir)
200
+
201
+ @property
202
+ def user_cache_path(self) -> Path:
203
+ """:return: cache path tied to the user"""
204
+ return Path(self.user_cache_dir)
205
+
206
+ @property
207
+ def site_cache_path(self) -> Path:
208
+ """:return: cache path shared by users"""
209
+ return Path(self.site_cache_dir)
210
+
211
+ @property
212
+ def user_state_path(self) -> Path:
213
+ """:return: state path tied to the user"""
214
+ return Path(self.user_state_dir)
215
+
216
+ @property
217
+ def user_log_path(self) -> Path:
218
+ """:return: log path tied to the user"""
219
+ return Path(self.user_log_dir)
220
+
221
+ @property
222
+ def user_documents_path(self) -> Path:
223
+ """:return: documents a path tied to the user"""
224
+ return Path(self.user_documents_dir)
225
+
226
+ @property
227
+ def user_downloads_path(self) -> Path:
228
+ """:return: downloads path tied to the user"""
229
+ return Path(self.user_downloads_dir)
230
+
231
+ @property
232
+ def user_pictures_path(self) -> Path:
233
+ """:return: pictures path tied to the user"""
234
+ return Path(self.user_pictures_dir)
235
+
236
+ @property
237
+ def user_videos_path(self) -> Path:
238
+ """:return: videos path tied to the user"""
239
+ return Path(self.user_videos_dir)
240
+
241
+ @property
242
+ def user_music_path(self) -> Path:
243
+ """:return: music path tied to the user"""
244
+ return Path(self.user_music_dir)
245
+
246
+ @property
247
+ def user_desktop_path(self) -> Path:
248
+ """:return: desktop path tied to the user"""
249
+ return Path(self.user_desktop_dir)
250
+
251
+ @property
252
+ def user_runtime_path(self) -> Path:
253
+ """:return: runtime path tied to the user"""
254
+ return Path(self.user_runtime_dir)
255
+
256
+ @property
257
+ def site_runtime_path(self) -> Path:
258
+ """:return: runtime path shared by users"""
259
+ return Path(self.site_runtime_dir)
260
+
261
+ def iter_config_dirs(self) -> Iterator[str]:
262
+ """:yield: all user and site configuration directories."""
263
+ yield self.user_config_dir
264
+ yield self.site_config_dir
265
+
266
+ def iter_data_dirs(self) -> Iterator[str]:
267
+ """:yield: all user and site data directories."""
268
+ yield self.user_data_dir
269
+ yield self.site_data_dir
270
+
271
+ def iter_cache_dirs(self) -> Iterator[str]:
272
+ """:yield: all user and site cache directories."""
273
+ yield self.user_cache_dir
274
+ yield self.site_cache_dir
275
+
276
+ def iter_runtime_dirs(self) -> Iterator[str]:
277
+ """:yield: all user and site runtime directories."""
278
+ yield self.user_runtime_dir
279
+ yield self.site_runtime_dir
280
+
281
+ def iter_config_paths(self) -> Iterator[Path]:
282
+ """:yield: all user and site configuration paths."""
283
+ for path in self.iter_config_dirs():
284
+ yield Path(path)
285
+
286
+ def iter_data_paths(self) -> Iterator[Path]:
287
+ """:yield: all user and site data paths."""
288
+ for path in self.iter_data_dirs():
289
+ yield Path(path)
290
+
291
+ def iter_cache_paths(self) -> Iterator[Path]:
292
+ """:yield: all user and site cache paths."""
293
+ for path in self.iter_cache_dirs():
294
+ yield Path(path)
295
+
296
+ def iter_runtime_paths(self) -> Iterator[Path]:
297
+ """:yield: all user and site runtime paths."""
298
+ for path in self.iter_runtime_dirs():
299
+ yield Path(path)
miniconda3/lib/python3.13/site-packages/platformdirs/macos.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """macOS."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os.path
6
+ import sys
7
+ from typing import TYPE_CHECKING
8
+
9
+ from .api import PlatformDirsABC
10
+
11
+ if TYPE_CHECKING:
12
+ from pathlib import Path
13
+
14
+
15
+ class MacOS(PlatformDirsABC):
16
+ """
17
+ Platform directories for the macOS operating system.
18
+
19
+ Follows the guidance from
20
+ `Apple documentation <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
21
+ Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`,
22
+ `version <platformdirs.api.PlatformDirsABC.version>`,
23
+ `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
24
+
25
+ """
26
+
27
+ @property
28
+ def user_data_dir(self) -> str:
29
+ """:return: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``"""
30
+ return self._append_app_name_and_version(os.path.expanduser("~/Library/Application Support")) # noqa: PTH111
31
+
32
+ @property
33
+ def site_data_dir(self) -> str:
34
+ """
35
+ :return: data directory shared by users, e.g. ``/Library/Application Support/$appname/$version``.
36
+ If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
37
+ will be under the Homebrew prefix, e.g. ``$homebrew_prefix/share/$appname/$version``.
38
+ If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew,
39
+ the response is a multi-path string separated by ":", e.g.
40
+ ``$homebrew_prefix/share/$appname/$version:/Library/Application Support/$appname/$version``
41
+ """
42
+ is_homebrew = "/opt/python" in sys.prefix
43
+ homebrew_prefix = sys.prefix.split("/opt/python")[0] if is_homebrew else ""
44
+ path_list = [self._append_app_name_and_version(f"{homebrew_prefix}/share")] if is_homebrew else []
45
+ path_list.append(self._append_app_name_and_version("/Library/Application Support"))
46
+ if self.multipath:
47
+ return os.pathsep.join(path_list)
48
+ return path_list[0]
49
+
50
+ @property
51
+ def site_data_path(self) -> Path:
52
+ """:return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
53
+ return self._first_item_as_path_if_multipath(self.site_data_dir)
54
+
55
+ @property
56
+ def user_config_dir(self) -> str:
57
+ """:return: config directory tied to the user, same as `user_data_dir`"""
58
+ return self.user_data_dir
59
+
60
+ @property
61
+ def site_config_dir(self) -> str:
62
+ """:return: config directory shared by the users, same as `site_data_dir`"""
63
+ return self.site_data_dir
64
+
65
+ @property
66
+ def user_cache_dir(self) -> str:
67
+ """:return: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``"""
68
+ return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches")) # noqa: PTH111
69
+
70
+ @property
71
+ def site_cache_dir(self) -> str:
72
+ """
73
+ :return: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``.
74
+ If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
75
+ will be under the Homebrew prefix, e.g. ``$homebrew_prefix/var/cache/$appname/$version``.
76
+ If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew,
77
+ the response is a multi-path string separated by ":", e.g.
78
+ ``$homebrew_prefix/var/cache/$appname/$version:/Library/Caches/$appname/$version``
79
+ """
80
+ is_homebrew = "/opt/python" in sys.prefix
81
+ homebrew_prefix = sys.prefix.split("/opt/python")[0] if is_homebrew else ""
82
+ path_list = [self._append_app_name_and_version(f"{homebrew_prefix}/var/cache")] if is_homebrew else []
83
+ path_list.append(self._append_app_name_and_version("/Library/Caches"))
84
+ if self.multipath:
85
+ return os.pathsep.join(path_list)
86
+ return path_list[0]
87
+
88
+ @property
89
+ def site_cache_path(self) -> Path:
90
+ """:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
91
+ return self._first_item_as_path_if_multipath(self.site_cache_dir)
92
+
93
+ @property
94
+ def user_state_dir(self) -> str:
95
+ """:return: state directory tied to the user, same as `user_data_dir`"""
96
+ return self.user_data_dir
97
+
98
+ @property
99
+ def user_log_dir(self) -> str:
100
+ """:return: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``"""
101
+ return self._append_app_name_and_version(os.path.expanduser("~/Library/Logs")) # noqa: PTH111
102
+
103
+ @property
104
+ def user_documents_dir(self) -> str:
105
+ """:return: documents directory tied to the user, e.g. ``~/Documents``"""
106
+ return os.path.expanduser("~/Documents") # noqa: PTH111
107
+
108
+ @property
109
+ def user_downloads_dir(self) -> str:
110
+ """:return: downloads directory tied to the user, e.g. ``~/Downloads``"""
111
+ return os.path.expanduser("~/Downloads") # noqa: PTH111
112
+
113
+ @property
114
+ def user_pictures_dir(self) -> str:
115
+ """:return: pictures directory tied to the user, e.g. ``~/Pictures``"""
116
+ return os.path.expanduser("~/Pictures") # noqa: PTH111
117
+
118
+ @property
119
+ def user_videos_dir(self) -> str:
120
+ """:return: videos directory tied to the user, e.g. ``~/Movies``"""
121
+ return os.path.expanduser("~/Movies") # noqa: PTH111
122
+
123
+ @property
124
+ def user_music_dir(self) -> str:
125
+ """:return: music directory tied to the user, e.g. ``~/Music``"""
126
+ return os.path.expanduser("~/Music") # noqa: PTH111
127
+
128
+ @property
129
+ def user_desktop_dir(self) -> str:
130
+ """:return: desktop directory tied to the user, e.g. ``~/Desktop``"""
131
+ return os.path.expanduser("~/Desktop") # noqa: PTH111
132
+
133
+ @property
134
+ def user_runtime_dir(self) -> str:
135
+ """:return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``"""
136
+ return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches/TemporaryItems")) # noqa: PTH111
137
+
138
+ @property
139
+ def site_runtime_dir(self) -> str:
140
+ """:return: runtime directory shared by users, same as `user_runtime_dir`"""
141
+ return self.user_runtime_dir
142
+
143
+
144
+ __all__ = [
145
+ "MacOS",
146
+ ]
miniconda3/lib/python3.13/site-packages/platformdirs/py.typed ADDED
File without changes
miniconda3/lib/python3.13/site-packages/platformdirs/unix.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Unix."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ from configparser import ConfigParser
8
+ from pathlib import Path
9
+ from typing import TYPE_CHECKING, NoReturn
10
+
11
+ from .api import PlatformDirsABC
12
+
13
+ if TYPE_CHECKING:
14
+ from collections.abc import Iterator
15
+
16
+ if sys.platform == "win32":
17
+
18
+ def getuid() -> NoReturn:
19
+ msg = "should only be used on Unix"
20
+ raise RuntimeError(msg)
21
+
22
+ else:
23
+ from os import getuid
24
+
25
+
26
+ class Unix(PlatformDirsABC): # noqa: PLR0904
27
+ """
28
+ On Unix/Linux, we follow the `XDG Basedir Spec <https://specifications.freedesktop.org/basedir-spec/basedir-spec-
29
+ latest.html>`_.
30
+
31
+ The spec allows overriding directories with environment variables. The examples shown are the default values,
32
+ alongside the name of the environment variable that overrides them. Makes use of the `appname
33
+ <platformdirs.api.PlatformDirsABC.appname>`, `version <platformdirs.api.PlatformDirsABC.version>`, `multipath
34
+ <platformdirs.api.PlatformDirsABC.multipath>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
35
+ <platformdirs.api.PlatformDirsABC.ensure_exists>`.
36
+
37
+ """
38
+
39
+ @property
40
+ def user_data_dir(self) -> str:
41
+ """
42
+ :return: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or
43
+ ``$XDG_DATA_HOME/$appname/$version``
44
+ """
45
+ path = os.environ.get("XDG_DATA_HOME", "")
46
+ if not path.strip():
47
+ path = os.path.expanduser("~/.local/share") # noqa: PTH111
48
+ return self._append_app_name_and_version(path)
49
+
50
+ @property
51
+ def _site_data_dirs(self) -> list[str]:
52
+ path = os.environ.get("XDG_DATA_DIRS", "")
53
+ if not path.strip():
54
+ path = f"/usr/local/share{os.pathsep}/usr/share"
55
+ return [self._append_app_name_and_version(p) for p in path.split(os.pathsep)]
56
+
57
+ @property
58
+ def site_data_dir(self) -> str:
59
+ """
60
+ :return: data directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is
61
+ enabled and ``XDG_DATA_DIRS`` is set and a multi path the response is also a multi path separated by the
62
+ OS path separator), e.g. ``/usr/local/share/$appname/$version`` or ``/usr/share/$appname/$version``
63
+ """
64
+ # XDG default for $XDG_DATA_DIRS; only first, if multipath is False
65
+ dirs = self._site_data_dirs
66
+ if not self.multipath:
67
+ return dirs[0]
68
+ return os.pathsep.join(dirs)
69
+
70
+ @property
71
+ def user_config_dir(self) -> str:
72
+ """
73
+ :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or
74
+ ``$XDG_CONFIG_HOME/$appname/$version``
75
+ """
76
+ path = os.environ.get("XDG_CONFIG_HOME", "")
77
+ if not path.strip():
78
+ path = os.path.expanduser("~/.config") # noqa: PTH111
79
+ return self._append_app_name_and_version(path)
80
+
81
+ @property
82
+ def _site_config_dirs(self) -> list[str]:
83
+ path = os.environ.get("XDG_CONFIG_DIRS", "")
84
+ if not path.strip():
85
+ path = "/etc/xdg"
86
+ return [self._append_app_name_and_version(p) for p in path.split(os.pathsep)]
87
+
88
+ @property
89
+ def site_config_dir(self) -> str:
90
+ """
91
+ :return: config directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>`
92
+ is enabled and ``XDG_CONFIG_DIRS`` is set and a multi path the response is also a multi path separated by
93
+ the OS path separator), e.g. ``/etc/xdg/$appname/$version``
94
+ """
95
+ # XDG default for $XDG_CONFIG_DIRS only first, if multipath is False
96
+ dirs = self._site_config_dirs
97
+ if not self.multipath:
98
+ return dirs[0]
99
+ return os.pathsep.join(dirs)
100
+
101
+ @property
102
+ def user_cache_dir(self) -> str:
103
+ """
104
+ :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or
105
+ ``~/$XDG_CACHE_HOME/$appname/$version``
106
+ """
107
+ path = os.environ.get("XDG_CACHE_HOME", "")
108
+ if not path.strip():
109
+ path = os.path.expanduser("~/.cache") # noqa: PTH111
110
+ return self._append_app_name_and_version(path)
111
+
112
+ @property
113
+ def site_cache_dir(self) -> str:
114
+ """:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``"""
115
+ return self._append_app_name_and_version("/var/cache")
116
+
117
+ @property
118
+ def user_state_dir(self) -> str:
119
+ """
120
+ :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or
121
+ ``$XDG_STATE_HOME/$appname/$version``
122
+ """
123
+ path = os.environ.get("XDG_STATE_HOME", "")
124
+ if not path.strip():
125
+ path = os.path.expanduser("~/.local/state") # noqa: PTH111
126
+ return self._append_app_name_and_version(path)
127
+
128
+ @property
129
+ def user_log_dir(self) -> str:
130
+ """:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it"""
131
+ path = self.user_state_dir
132
+ if self.opinion:
133
+ path = os.path.join(path, "log") # noqa: PTH118
134
+ self._optionally_create_directory(path)
135
+ return path
136
+
137
+ @property
138
+ def user_documents_dir(self) -> str:
139
+ """:return: documents directory tied to the user, e.g. ``~/Documents``"""
140
+ return _get_user_media_dir("XDG_DOCUMENTS_DIR", "~/Documents")
141
+
142
+ @property
143
+ def user_downloads_dir(self) -> str:
144
+ """:return: downloads directory tied to the user, e.g. ``~/Downloads``"""
145
+ return _get_user_media_dir("XDG_DOWNLOAD_DIR", "~/Downloads")
146
+
147
+ @property
148
+ def user_pictures_dir(self) -> str:
149
+ """:return: pictures directory tied to the user, e.g. ``~/Pictures``"""
150
+ return _get_user_media_dir("XDG_PICTURES_DIR", "~/Pictures")
151
+
152
+ @property
153
+ def user_videos_dir(self) -> str:
154
+ """:return: videos directory tied to the user, e.g. ``~/Videos``"""
155
+ return _get_user_media_dir("XDG_VIDEOS_DIR", "~/Videos")
156
+
157
+ @property
158
+ def user_music_dir(self) -> str:
159
+ """:return: music directory tied to the user, e.g. ``~/Music``"""
160
+ return _get_user_media_dir("XDG_MUSIC_DIR", "~/Music")
161
+
162
+ @property
163
+ def user_desktop_dir(self) -> str:
164
+ """:return: desktop directory tied to the user, e.g. ``~/Desktop``"""
165
+ return _get_user_media_dir("XDG_DESKTOP_DIR", "~/Desktop")
166
+
167
+ @property
168
+ def user_runtime_dir(self) -> str:
169
+ """
170
+ :return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or
171
+ ``$XDG_RUNTIME_DIR/$appname/$version``.
172
+
173
+ For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/user/$(id -u)/$appname/$version`` if
174
+ exists, otherwise ``/tmp/runtime-$(id -u)/$appname/$version``, if``$XDG_RUNTIME_DIR``
175
+ is not set.
176
+ """
177
+ path = os.environ.get("XDG_RUNTIME_DIR", "")
178
+ if not path.strip():
179
+ if sys.platform.startswith(("freebsd", "openbsd", "netbsd")):
180
+ path = f"/var/run/user/{getuid()}"
181
+ if not Path(path).exists():
182
+ path = f"/tmp/runtime-{getuid()}" # noqa: S108
183
+ else:
184
+ path = f"/run/user/{getuid()}"
185
+ return self._append_app_name_and_version(path)
186
+
187
+ @property
188
+ def site_runtime_dir(self) -> str:
189
+ """
190
+ :return: runtime directory shared by users, e.g. ``/run/$appname/$version`` or \
191
+ ``$XDG_RUNTIME_DIR/$appname/$version``.
192
+
193
+ Note that this behaves almost exactly like `user_runtime_dir` if ``$XDG_RUNTIME_DIR`` is set, but will
194
+ fall back to paths associated to the root user instead of a regular logged-in user if it's not set.
195
+
196
+ If you wish to ensure that a logged-in root user path is returned e.g. ``/run/user/0``, use `user_runtime_dir`
197
+ instead.
198
+
199
+ For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/$appname/$version`` if ``$XDG_RUNTIME_DIR`` is not set.
200
+ """
201
+ path = os.environ.get("XDG_RUNTIME_DIR", "")
202
+ if not path.strip():
203
+ if sys.platform.startswith(("freebsd", "openbsd", "netbsd")):
204
+ path = "/var/run"
205
+ else:
206
+ path = "/run"
207
+ return self._append_app_name_and_version(path)
208
+
209
+ @property
210
+ def site_data_path(self) -> Path:
211
+ """:return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
212
+ return self._first_item_as_path_if_multipath(self.site_data_dir)
213
+
214
+ @property
215
+ def site_config_path(self) -> Path:
216
+ """:return: config path shared by the users, returns the first item, even if ``multipath`` is set to ``True``"""
217
+ return self._first_item_as_path_if_multipath(self.site_config_dir)
218
+
219
+ @property
220
+ def site_cache_path(self) -> Path:
221
+ """:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
222
+ return self._first_item_as_path_if_multipath(self.site_cache_dir)
223
+
224
+ def iter_config_dirs(self) -> Iterator[str]:
225
+ """:yield: all user and site configuration directories."""
226
+ yield self.user_config_dir
227
+ yield from self._site_config_dirs
228
+
229
+ def iter_data_dirs(self) -> Iterator[str]:
230
+ """:yield: all user and site data directories."""
231
+ yield self.user_data_dir
232
+ yield from self._site_data_dirs
233
+
234
+
235
+ def _get_user_media_dir(env_var: str, fallback_tilde_path: str) -> str:
236
+ media_dir = _get_user_dirs_folder(env_var)
237
+ if media_dir is None:
238
+ media_dir = os.environ.get(env_var, "").strip()
239
+ if not media_dir:
240
+ media_dir = os.path.expanduser(fallback_tilde_path) # noqa: PTH111
241
+
242
+ return media_dir
243
+
244
+
245
+ def _get_user_dirs_folder(key: str) -> str | None:
246
+ """
247
+ Return directory from user-dirs.dirs config file.
248
+
249
+ See https://freedesktop.org/wiki/Software/xdg-user-dirs/.
250
+
251
+ """
252
+ user_dirs_config_path = Path(Unix().user_config_dir) / "user-dirs.dirs"
253
+ if user_dirs_config_path.exists():
254
+ parser = ConfigParser()
255
+
256
+ with user_dirs_config_path.open() as stream:
257
+ # Add fake section header, so ConfigParser doesn't complain
258
+ parser.read_string(f"[top]\n{stream.read()}")
259
+
260
+ if key not in parser["top"]:
261
+ return None
262
+
263
+ path = parser["top"][key].strip('"')
264
+ # Handle relative home paths
265
+ return path.replace("$HOME", os.path.expanduser("~")) # noqa: PTH111
266
+
267
+ return None
268
+
269
+
270
+ __all__ = [
271
+ "Unix",
272
+ ]
miniconda3/lib/python3.13/site-packages/platformdirs/version.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
6
+ TYPE_CHECKING = False
7
+ if TYPE_CHECKING:
8
+ from typing import Tuple
9
+ from typing import Union
10
+
11
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
12
+ else:
13
+ VERSION_TUPLE = object
14
+
15
+ version: str
16
+ __version__: str
17
+ __version_tuple__: VERSION_TUPLE
18
+ version_tuple: VERSION_TUPLE
19
+
20
+ __version__ = version = '4.5.0'
21
+ __version_tuple__ = version_tuple = (4, 5, 0)
miniconda3/lib/python3.13/site-packages/platformdirs/windows.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Windows."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ from functools import lru_cache
8
+ from typing import TYPE_CHECKING
9
+
10
+ from .api import PlatformDirsABC
11
+
12
+ if TYPE_CHECKING:
13
+ from collections.abc import Callable
14
+
15
+
16
+ class Windows(PlatformDirsABC):
17
+ """
18
+ `MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.
19
+
20
+ Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `appauthor
21
+ <platformdirs.api.PlatformDirsABC.appauthor>`, `version <platformdirs.api.PlatformDirsABC.version>`, `roaming
22
+ <platformdirs.api.PlatformDirsABC.roaming>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
23
+ <platformdirs.api.PlatformDirsABC.ensure_exists>`.
24
+
25
+ """
26
+
27
+ @property
28
+ def user_data_dir(self) -> str:
29
+ """
30
+ :return: data directory tied to the user, e.g.
31
+ ``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname`` (not roaming) or
32
+ ``%USERPROFILE%\\AppData\\Roaming\\$appauthor\\$appname`` (roaming)
33
+ """
34
+ const = "CSIDL_APPDATA" if self.roaming else "CSIDL_LOCAL_APPDATA"
35
+ path = os.path.normpath(get_win_folder(const))
36
+ return self._append_parts(path)
37
+
38
+ def _append_parts(self, path: str, *, opinion_value: str | None = None) -> str:
39
+ params = []
40
+ if self.appname:
41
+ if self.appauthor is not False:
42
+ author = self.appauthor or self.appname
43
+ params.append(author)
44
+ params.append(self.appname)
45
+ if opinion_value is not None and self.opinion:
46
+ params.append(opinion_value)
47
+ if self.version:
48
+ params.append(self.version)
49
+ path = os.path.join(path, *params) # noqa: PTH118
50
+ self._optionally_create_directory(path)
51
+ return path
52
+
53
+ @property
54
+ def site_data_dir(self) -> str:
55
+ """:return: data directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname``"""
56
+ path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA"))
57
+ return self._append_parts(path)
58
+
59
+ @property
60
+ def user_config_dir(self) -> str:
61
+ """:return: config directory tied to the user, same as `user_data_dir`"""
62
+ return self.user_data_dir
63
+
64
+ @property
65
+ def site_config_dir(self) -> str:
66
+ """:return: config directory shared by the users, same as `site_data_dir`"""
67
+ return self.site_data_dir
68
+
69
+ @property
70
+ def user_cache_dir(self) -> str:
71
+ """
72
+ :return: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g.
73
+ ``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname\\Cache\\$version``
74
+ """
75
+ path = os.path.normpath(get_win_folder("CSIDL_LOCAL_APPDATA"))
76
+ return self._append_parts(path, opinion_value="Cache")
77
+
78
+ @property
79
+ def site_cache_dir(self) -> str:
80
+ """:return: cache directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname\\Cache\\$version``"""
81
+ path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA"))
82
+ return self._append_parts(path, opinion_value="Cache")
83
+
84
+ @property
85
+ def user_state_dir(self) -> str:
86
+ """:return: state directory tied to the user, same as `user_data_dir`"""
87
+ return self.user_data_dir
88
+
89
+ @property
90
+ def user_log_dir(self) -> str:
91
+ """:return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in it"""
92
+ path = self.user_data_dir
93
+ if self.opinion:
94
+ path = os.path.join(path, "Logs") # noqa: PTH118
95
+ self._optionally_create_directory(path)
96
+ return path
97
+
98
+ @property
99
+ def user_documents_dir(self) -> str:
100
+ """:return: documents directory tied to the user e.g. ``%USERPROFILE%\\Documents``"""
101
+ return os.path.normpath(get_win_folder("CSIDL_PERSONAL"))
102
+
103
+ @property
104
+ def user_downloads_dir(self) -> str:
105
+ """:return: downloads directory tied to the user e.g. ``%USERPROFILE%\\Downloads``"""
106
+ return os.path.normpath(get_win_folder("CSIDL_DOWNLOADS"))
107
+
108
+ @property
109
+ def user_pictures_dir(self) -> str:
110
+ """:return: pictures directory tied to the user e.g. ``%USERPROFILE%\\Pictures``"""
111
+ return os.path.normpath(get_win_folder("CSIDL_MYPICTURES"))
112
+
113
+ @property
114
+ def user_videos_dir(self) -> str:
115
+ """:return: videos directory tied to the user e.g. ``%USERPROFILE%\\Videos``"""
116
+ return os.path.normpath(get_win_folder("CSIDL_MYVIDEO"))
117
+
118
+ @property
119
+ def user_music_dir(self) -> str:
120
+ """:return: music directory tied to the user e.g. ``%USERPROFILE%\\Music``"""
121
+ return os.path.normpath(get_win_folder("CSIDL_MYMUSIC"))
122
+
123
+ @property
124
+ def user_desktop_dir(self) -> str:
125
+ """:return: desktop directory tied to the user, e.g. ``%USERPROFILE%\\Desktop``"""
126
+ return os.path.normpath(get_win_folder("CSIDL_DESKTOPDIRECTORY"))
127
+
128
+ @property
129
+ def user_runtime_dir(self) -> str:
130
+ """
131
+ :return: runtime directory tied to the user, e.g.
132
+ ``%USERPROFILE%\\AppData\\Local\\Temp\\$appauthor\\$appname``
133
+ """
134
+ path = os.path.normpath(os.path.join(get_win_folder("CSIDL_LOCAL_APPDATA"), "Temp")) # noqa: PTH118
135
+ return self._append_parts(path)
136
+
137
+ @property
138
+ def site_runtime_dir(self) -> str:
139
+ """:return: runtime directory shared by users, same as `user_runtime_dir`"""
140
+ return self.user_runtime_dir
141
+
142
+
143
+ def get_win_folder_from_env_vars(csidl_name: str) -> str:
144
+ """Get folder from environment variables."""
145
+ result = get_win_folder_if_csidl_name_not_env_var(csidl_name)
146
+ if result is not None:
147
+ return result
148
+
149
+ env_var_name = {
150
+ "CSIDL_APPDATA": "APPDATA",
151
+ "CSIDL_COMMON_APPDATA": "ALLUSERSPROFILE",
152
+ "CSIDL_LOCAL_APPDATA": "LOCALAPPDATA",
153
+ }.get(csidl_name)
154
+ if env_var_name is None:
155
+ msg = f"Unknown CSIDL name: {csidl_name}"
156
+ raise ValueError(msg)
157
+ result = os.environ.get(env_var_name)
158
+ if result is None:
159
+ msg = f"Unset environment variable: {env_var_name}"
160
+ raise ValueError(msg)
161
+ return result
162
+
163
+
164
+ def get_win_folder_if_csidl_name_not_env_var(csidl_name: str) -> str | None:
165
+ """Get a folder for a CSIDL name that does not exist as an environment variable."""
166
+ if csidl_name == "CSIDL_PERSONAL":
167
+ return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Documents") # noqa: PTH118
168
+
169
+ if csidl_name == "CSIDL_DOWNLOADS":
170
+ return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Downloads") # noqa: PTH118
171
+
172
+ if csidl_name == "CSIDL_MYPICTURES":
173
+ return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Pictures") # noqa: PTH118
174
+
175
+ if csidl_name == "CSIDL_MYVIDEO":
176
+ return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Videos") # noqa: PTH118
177
+
178
+ if csidl_name == "CSIDL_MYMUSIC":
179
+ return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Music") # noqa: PTH118
180
+ return None
181
+
182
+
183
+ def get_win_folder_from_registry(csidl_name: str) -> str:
184
+ """
185
+ Get folder from the registry.
186
+
187
+ This is a fallback technique at best. I'm not sure if using the registry for these guarantees us the correct answer
188
+ for all CSIDL_* names.
189
+
190
+ """
191
+ shell_folder_name = {
192
+ "CSIDL_APPDATA": "AppData",
193
+ "CSIDL_COMMON_APPDATA": "Common AppData",
194
+ "CSIDL_LOCAL_APPDATA": "Local AppData",
195
+ "CSIDL_PERSONAL": "Personal",
196
+ "CSIDL_DOWNLOADS": "{374DE290-123F-4565-9164-39C4925E467B}",
197
+ "CSIDL_MYPICTURES": "My Pictures",
198
+ "CSIDL_MYVIDEO": "My Video",
199
+ "CSIDL_MYMUSIC": "My Music",
200
+ }.get(csidl_name)
201
+ if shell_folder_name is None:
202
+ msg = f"Unknown CSIDL name: {csidl_name}"
203
+ raise ValueError(msg)
204
+ if sys.platform != "win32": # only needed for mypy type checker to know that this code runs only on Windows
205
+ raise NotImplementedError
206
+ import winreg # noqa: PLC0415
207
+
208
+ key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
209
+ directory, _ = winreg.QueryValueEx(key, shell_folder_name)
210
+ return str(directory)
211
+
212
+
213
+ def get_win_folder_via_ctypes(csidl_name: str) -> str:
214
+ """Get folder with ctypes."""
215
+ # There is no 'CSIDL_DOWNLOADS'.
216
+ # Use 'CSIDL_PROFILE' (40) and append the default folder 'Downloads' instead.
217
+ # https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid
218
+
219
+ import ctypes # noqa: PLC0415
220
+
221
+ csidl_const = {
222
+ "CSIDL_APPDATA": 26,
223
+ "CSIDL_COMMON_APPDATA": 35,
224
+ "CSIDL_LOCAL_APPDATA": 28,
225
+ "CSIDL_PERSONAL": 5,
226
+ "CSIDL_MYPICTURES": 39,
227
+ "CSIDL_MYVIDEO": 14,
228
+ "CSIDL_MYMUSIC": 13,
229
+ "CSIDL_DOWNLOADS": 40,
230
+ "CSIDL_DESKTOPDIRECTORY": 16,
231
+ }.get(csidl_name)
232
+ if csidl_const is None:
233
+ msg = f"Unknown CSIDL name: {csidl_name}"
234
+ raise ValueError(msg)
235
+
236
+ buf = ctypes.create_unicode_buffer(1024)
237
+ windll = getattr(ctypes, "windll") # noqa: B009 # using getattr to avoid false positive with mypy type checker
238
+ windll.shell32.SHGetFolderPathW(None, csidl_const, None, 0, buf)
239
+
240
+ # Downgrade to short path name if it has high-bit chars.
241
+ if any(ord(c) > 255 for c in buf): # noqa: PLR2004
242
+ buf2 = ctypes.create_unicode_buffer(1024)
243
+ if windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
244
+ buf = buf2
245
+
246
+ if csidl_name == "CSIDL_DOWNLOADS":
247
+ return os.path.join(buf.value, "Downloads") # noqa: PTH118
248
+
249
+ return buf.value
250
+
251
+
252
+ def _pick_get_win_folder() -> Callable[[str], str]:
253
+ try:
254
+ import ctypes # noqa: PLC0415
255
+ except ImportError:
256
+ pass
257
+ else:
258
+ if hasattr(ctypes, "windll"):
259
+ return get_win_folder_via_ctypes
260
+ try:
261
+ import winreg # noqa: PLC0415, F401
262
+ except ImportError:
263
+ return get_win_folder_from_env_vars
264
+ else:
265
+ return get_win_folder_from_registry
266
+
267
+
268
+ get_win_folder = lru_cache(maxsize=None)(_pick_get_win_folder())
269
+
270
+ __all__ = [
271
+ "Windows",
272
+ ]
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 holger krekel (rather uses bitbucket/hpk42)
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 all
13
+ 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 THE
21
+ SOFTWARE.
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/METADATA ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: pluggy
3
+ Version: 1.5.0
4
+ Summary: plugin and hook calling mechanisms for python
5
+ Home-page: https://github.com/pytest-dev/pluggy
6
+ Author: Holger Krekel
7
+ Author-email: holger@merlinux.eu
8
+ License: MIT
9
+ Platform: unix
10
+ Platform: linux
11
+ Platform: osx
12
+ Platform: win32
13
+ Classifier: Development Status :: 6 - Mature
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: MacOS :: MacOS X
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Utilities
22
+ Classifier: Programming Language :: Python :: Implementation :: CPython
23
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
24
+ Classifier: Programming Language :: Python :: 3
25
+ Classifier: Programming Language :: Python :: 3 :: Only
26
+ Classifier: Programming Language :: Python :: 3.8
27
+ Classifier: Programming Language :: Python :: 3.9
28
+ Classifier: Programming Language :: Python :: 3.10
29
+ Classifier: Programming Language :: Python :: 3.11
30
+ Requires-Python: >=3.8
31
+ Description-Content-Type: text/x-rst
32
+ License-File: LICENSE
33
+ Provides-Extra: dev
34
+ Requires-Dist: pre-commit; extra == "dev"
35
+ Requires-Dist: tox; extra == "dev"
36
+ Provides-Extra: testing
37
+ Requires-Dist: pytest; extra == "testing"
38
+ Requires-Dist: pytest-benchmark; extra == "testing"
39
+
40
+ ====================================================
41
+ pluggy - A minimalist production ready plugin system
42
+ ====================================================
43
+
44
+ |pypi| |conda-forge| |versions| |github-actions| |gitter| |black| |codecov|
45
+
46
+ This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.
47
+
48
+ Please `read the docs`_ to learn more!
49
+
50
+ A definitive example
51
+ ====================
52
+ .. code-block:: python
53
+
54
+ import pluggy
55
+
56
+ hookspec = pluggy.HookspecMarker("myproject")
57
+ hookimpl = pluggy.HookimplMarker("myproject")
58
+
59
+
60
+ class MySpec:
61
+ """A hook specification namespace."""
62
+
63
+ @hookspec
64
+ def myhook(self, arg1, arg2):
65
+ """My special little hook that you can customize."""
66
+
67
+
68
+ class Plugin_1:
69
+ """A hook implementation namespace."""
70
+
71
+ @hookimpl
72
+ def myhook(self, arg1, arg2):
73
+ print("inside Plugin_1.myhook()")
74
+ return arg1 + arg2
75
+
76
+
77
+ class Plugin_2:
78
+ """A 2nd hook implementation namespace."""
79
+
80
+ @hookimpl
81
+ def myhook(self, arg1, arg2):
82
+ print("inside Plugin_2.myhook()")
83
+ return arg1 - arg2
84
+
85
+
86
+ # create a manager and add the spec
87
+ pm = pluggy.PluginManager("myproject")
88
+ pm.add_hookspecs(MySpec)
89
+
90
+ # register plugins
91
+ pm.register(Plugin_1())
92
+ pm.register(Plugin_2())
93
+
94
+ # call our ``myhook`` hook
95
+ results = pm.hook.myhook(arg1=1, arg2=2)
96
+ print(results)
97
+
98
+
99
+ Running this directly gets us::
100
+
101
+ $ python docs/examples/toy-example.py
102
+ inside Plugin_2.myhook()
103
+ inside Plugin_1.myhook()
104
+ [-1, 3]
105
+
106
+
107
+ .. badges
108
+
109
+ .. |pypi| image:: https://img.shields.io/pypi/v/pluggy.svg
110
+ :target: https://pypi.org/pypi/pluggy
111
+
112
+ .. |versions| image:: https://img.shields.io/pypi/pyversions/pluggy.svg
113
+ :target: https://pypi.org/pypi/pluggy
114
+
115
+ .. |github-actions| image:: https://github.com/pytest-dev/pluggy/workflows/main/badge.svg
116
+ :target: https://github.com/pytest-dev/pluggy/actions
117
+
118
+ .. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pluggy.svg
119
+ :target: https://anaconda.org/conda-forge/pytest
120
+
121
+ .. |gitter| image:: https://badges.gitter.im/pytest-dev/pluggy.svg
122
+ :alt: Join the chat at https://gitter.im/pytest-dev/pluggy
123
+ :target: https://gitter.im/pytest-dev/pluggy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
124
+
125
+ .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
126
+ :target: https://github.com/ambv/black
127
+
128
+ .. |codecov| image:: https://codecov.io/gh/pytest-dev/pluggy/branch/master/graph/badge.svg
129
+ :target: https://codecov.io/gh/pytest-dev/pluggy
130
+ :alt: Code coverage Status
131
+
132
+ .. links
133
+ .. _pytest:
134
+ http://pytest.org
135
+ .. _tox:
136
+ https://tox.readthedocs.org
137
+ .. _devpi:
138
+ http://doc.devpi.net
139
+ .. _read the docs:
140
+ https://pluggy.readthedocs.io/en/latest/
141
+
142
+
143
+ Support pluggy
144
+ --------------
145
+
146
+ `Open Collective`_ is an online funding platform for open and transparent communities.
147
+ It provides tools to raise money and share your finances in full transparency.
148
+
149
+ It is the platform of choice for individuals and companies that want to make one-time or
150
+ monthly donations directly to the project.
151
+
152
+ ``pluggy`` is part of the ``pytest-dev`` project, see more details in the `pytest collective`_.
153
+
154
+ .. _Open Collective: https://opencollective.com
155
+ .. _pytest collective: https://opencollective.com/pytest
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/RECORD ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pluggy-1.5.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ pluggy-1.5.0.dist-info/LICENSE,sha256=1rZebCE6XQtXeRHTTW5ZSbn1nXbCOMUHGi8_wWz7JgY,1110
3
+ pluggy-1.5.0.dist-info/METADATA,sha256=K6NDj23d11k0w_a5B5guyo40ckGf0mTULd30dB5lNoA,4808
4
+ pluggy-1.5.0.dist-info/RECORD,,
5
+ pluggy-1.5.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pluggy-1.5.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
7
+ pluggy-1.5.0.dist-info/direct_url.json,sha256=_xW06hdsA8Ro8d5o3hCxgcE3aJZguCSHurVkM-QCWQs,66
8
+ pluggy-1.5.0.dist-info/top_level.txt,sha256=xKSCRhai-v9MckvMuWqNz16c1tbsmOggoMSwTgcpYHE,7
9
+ pluggy/__init__.py,sha256=U8qtIRmmr0SRdbxAF8VJJs01jMUYgKAc9oAjYYCLgz4,980
10
+ pluggy/__pycache__/__init__.cpython-313.pyc,,
11
+ pluggy/__pycache__/_callers.cpython-313.pyc,,
12
+ pluggy/__pycache__/_hooks.cpython-313.pyc,,
13
+ pluggy/__pycache__/_manager.cpython-313.pyc,,
14
+ pluggy/__pycache__/_result.cpython-313.pyc,,
15
+ pluggy/__pycache__/_tracing.cpython-313.pyc,,
16
+ pluggy/__pycache__/_version.cpython-313.pyc,,
17
+ pluggy/__pycache__/_warnings.cpython-313.pyc,,
18
+ pluggy/_callers.py,sha256=8k8i3GVBT_gtccCPFpN8Ww0towWSnSazrl0vbP9UXSY,7316
19
+ pluggy/_hooks.py,sha256=m-3qVLDdn4S9y3pffLOpMQeDI4PDw8hrATK1SC8rQkU,25108
20
+ pluggy/_manager.py,sha256=ylIDFwrUP_mMAGpdRPj9zwxukG7nWJAfY1yylXyXAMo,20265
21
+ pluggy/_result.py,sha256=eEak-7Ie88bRkylsgbLwB6iMogogIMZheq8W3bImmcs,2849
22
+ pluggy/_tracing.py,sha256=kSBr25F_rNklV2QhLD6h1jx6Z1kcKDRbuYvF5jv35pU,2089
23
+ pluggy/_version.py,sha256=OYzqgMEgfFG0au4hzbEdgYI-c7Hxo3wdBtrpEjK1RoY,411
24
+ pluggy/_warnings.py,sha256=td0AvZBpfamriCC3OqsLwxMh-SzAMjfjmc58T5vP3lw,828
25
+ pluggy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/REQUESTED ADDED
File without changes
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/direct_url.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"dir_info": {}, "url": "file:///croot/pluggy_1733169602837/work"}
miniconda3/lib/python3.13/site-packages/pluggy-1.5.0.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pluggy
miniconda3/lib/python3.13/site-packages/pluggy/__init__.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ try:
2
+ from ._version import version as __version__
3
+ except ImportError:
4
+ # broken installation, we don't even try
5
+ # unknown only works because we do poor mans version compare
6
+ __version__ = "unknown"
7
+
8
+ __all__ = [
9
+ "__version__",
10
+ "PluginManager",
11
+ "PluginValidationError",
12
+ "HookCaller",
13
+ "HookCallError",
14
+ "HookspecOpts",
15
+ "HookimplOpts",
16
+ "HookImpl",
17
+ "HookRelay",
18
+ "HookspecMarker",
19
+ "HookimplMarker",
20
+ "Result",
21
+ "PluggyWarning",
22
+ "PluggyTeardownRaisedWarning",
23
+ ]
24
+
25
+ from ._hooks import HookCaller
26
+ from ._hooks import HookImpl
27
+ from ._hooks import HookimplMarker
28
+ from ._hooks import HookimplOpts
29
+ from ._hooks import HookRelay
30
+ from ._hooks import HookspecMarker
31
+ from ._hooks import HookspecOpts
32
+ from ._manager import PluginManager
33
+ from ._manager import PluginValidationError
34
+ from ._result import HookCallError
35
+ from ._result import Result
36
+ from ._warnings import PluggyTeardownRaisedWarning
37
+ from ._warnings import PluggyWarning
miniconda3/lib/python3.13/site-packages/pluggy/_callers.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Call loop machinery
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import cast
8
+ from typing import Generator
9
+ from typing import Mapping
10
+ from typing import NoReturn
11
+ from typing import Sequence
12
+ from typing import Tuple
13
+ from typing import Union
14
+ import warnings
15
+
16
+ from ._hooks import HookImpl
17
+ from ._result import HookCallError
18
+ from ._result import Result
19
+ from ._warnings import PluggyTeardownRaisedWarning
20
+
21
+
22
+ # Need to distinguish between old- and new-style hook wrappers.
23
+ # Wrapping with a tuple is the fastest type-safe way I found to do it.
24
+ Teardown = Union[
25
+ Tuple[Generator[None, Result[object], None], HookImpl],
26
+ Generator[None, object, object],
27
+ ]
28
+
29
+
30
+ def _raise_wrapfail(
31
+ wrap_controller: (
32
+ Generator[None, Result[object], None] | Generator[None, object, object]
33
+ ),
34
+ msg: str,
35
+ ) -> NoReturn:
36
+ co = wrap_controller.gi_code
37
+ raise RuntimeError(
38
+ "wrap_controller at %r %s:%d %s"
39
+ % (co.co_name, co.co_filename, co.co_firstlineno, msg)
40
+ )
41
+
42
+
43
+ def _warn_teardown_exception(
44
+ hook_name: str, hook_impl: HookImpl, e: BaseException
45
+ ) -> None:
46
+ msg = "A plugin raised an exception during an old-style hookwrapper teardown.\n"
47
+ msg += f"Plugin: {hook_impl.plugin_name}, Hook: {hook_name}\n"
48
+ msg += f"{type(e).__name__}: {e}\n"
49
+ msg += "For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning" # noqa: E501
50
+ warnings.warn(PluggyTeardownRaisedWarning(msg), stacklevel=5)
51
+
52
+
53
+ def _multicall(
54
+ hook_name: str,
55
+ hook_impls: Sequence[HookImpl],
56
+ caller_kwargs: Mapping[str, object],
57
+ firstresult: bool,
58
+ ) -> object | list[object]:
59
+ """Execute a call into multiple python functions/methods and return the
60
+ result(s).
61
+
62
+ ``caller_kwargs`` comes from HookCaller.__call__().
63
+ """
64
+ __tracebackhide__ = True
65
+ results: list[object] = []
66
+ exception = None
67
+ only_new_style_wrappers = True
68
+ try: # run impl and wrapper setup functions in a loop
69
+ teardowns: list[Teardown] = []
70
+ try:
71
+ for hook_impl in reversed(hook_impls):
72
+ try:
73
+ args = [caller_kwargs[argname] for argname in hook_impl.argnames]
74
+ except KeyError:
75
+ for argname in hook_impl.argnames:
76
+ if argname not in caller_kwargs:
77
+ raise HookCallError(
78
+ f"hook call must provide argument {argname!r}"
79
+ )
80
+
81
+ if hook_impl.hookwrapper:
82
+ only_new_style_wrappers = False
83
+ try:
84
+ # If this cast is not valid, a type error is raised below,
85
+ # which is the desired response.
86
+ res = hook_impl.function(*args)
87
+ wrapper_gen = cast(Generator[None, Result[object], None], res)
88
+ next(wrapper_gen) # first yield
89
+ teardowns.append((wrapper_gen, hook_impl))
90
+ except StopIteration:
91
+ _raise_wrapfail(wrapper_gen, "did not yield")
92
+ elif hook_impl.wrapper:
93
+ try:
94
+ # If this cast is not valid, a type error is raised below,
95
+ # which is the desired response.
96
+ res = hook_impl.function(*args)
97
+ function_gen = cast(Generator[None, object, object], res)
98
+ next(function_gen) # first yield
99
+ teardowns.append(function_gen)
100
+ except StopIteration:
101
+ _raise_wrapfail(function_gen, "did not yield")
102
+ else:
103
+ res = hook_impl.function(*args)
104
+ if res is not None:
105
+ results.append(res)
106
+ if firstresult: # halt further impl calls
107
+ break
108
+ except BaseException as exc:
109
+ exception = exc
110
+ finally:
111
+ # Fast path - only new-style wrappers, no Result.
112
+ if only_new_style_wrappers:
113
+ if firstresult: # first result hooks return a single value
114
+ result = results[0] if results else None
115
+ else:
116
+ result = results
117
+
118
+ # run all wrapper post-yield blocks
119
+ for teardown in reversed(teardowns):
120
+ try:
121
+ if exception is not None:
122
+ teardown.throw(exception) # type: ignore[union-attr]
123
+ else:
124
+ teardown.send(result) # type: ignore[union-attr]
125
+ # Following is unreachable for a well behaved hook wrapper.
126
+ # Try to force finalizers otherwise postponed till GC action.
127
+ # Note: close() may raise if generator handles GeneratorExit.
128
+ teardown.close() # type: ignore[union-attr]
129
+ except StopIteration as si:
130
+ result = si.value
131
+ exception = None
132
+ continue
133
+ except BaseException as e:
134
+ exception = e
135
+ continue
136
+ _raise_wrapfail(teardown, "has second yield") # type: ignore[arg-type]
137
+
138
+ if exception is not None:
139
+ raise exception.with_traceback(exception.__traceback__)
140
+ else:
141
+ return result
142
+
143
+ # Slow path - need to support old-style wrappers.
144
+ else:
145
+ if firstresult: # first result hooks return a single value
146
+ outcome: Result[object | list[object]] = Result(
147
+ results[0] if results else None, exception
148
+ )
149
+ else:
150
+ outcome = Result(results, exception)
151
+
152
+ # run all wrapper post-yield blocks
153
+ for teardown in reversed(teardowns):
154
+ if isinstance(teardown, tuple):
155
+ try:
156
+ teardown[0].send(outcome)
157
+ except StopIteration:
158
+ pass
159
+ except BaseException as e:
160
+ _warn_teardown_exception(hook_name, teardown[1], e)
161
+ raise
162
+ else:
163
+ _raise_wrapfail(teardown[0], "has second yield")
164
+ else:
165
+ try:
166
+ if outcome._exception is not None:
167
+ teardown.throw(outcome._exception)
168
+ else:
169
+ teardown.send(outcome._result)
170
+ # Following is unreachable for a well behaved hook wrapper.
171
+ # Try to force finalizers otherwise postponed till GC action.
172
+ # Note: close() may raise if generator handles GeneratorExit.
173
+ teardown.close()
174
+ except StopIteration as si:
175
+ outcome.force_result(si.value)
176
+ continue
177
+ except BaseException as e:
178
+ outcome.force_exception(e)
179
+ continue
180
+ _raise_wrapfail(teardown, "has second yield")
181
+
182
+ return outcome.get_result()
miniconda3/lib/python3.13/site-packages/pluggy/_hooks.py ADDED
@@ -0,0 +1,715 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Internal hook annotation, representation and calling machinery.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import inspect
8
+ import sys
9
+ from types import ModuleType
10
+ from typing import AbstractSet
11
+ from typing import Any
12
+ from typing import Callable
13
+ from typing import Final
14
+ from typing import final
15
+ from typing import Generator
16
+ from typing import List
17
+ from typing import Mapping
18
+ from typing import Optional
19
+ from typing import overload
20
+ from typing import Sequence
21
+ from typing import Tuple
22
+ from typing import TYPE_CHECKING
23
+ from typing import TypedDict
24
+ from typing import TypeVar
25
+ from typing import Union
26
+ import warnings
27
+
28
+ from ._result import Result
29
+
30
+
31
+ _T = TypeVar("_T")
32
+ _F = TypeVar("_F", bound=Callable[..., object])
33
+ _Namespace = Union[ModuleType, type]
34
+ _Plugin = object
35
+ _HookExec = Callable[
36
+ [str, Sequence["HookImpl"], Mapping[str, object], bool],
37
+ Union[object, List[object]],
38
+ ]
39
+ _HookImplFunction = Callable[..., Union[_T, Generator[None, Result[_T], None]]]
40
+
41
+
42
+ class HookspecOpts(TypedDict):
43
+ """Options for a hook specification."""
44
+
45
+ #: Whether the hook is :ref:`first result only <firstresult>`.
46
+ firstresult: bool
47
+ #: Whether the hook is :ref:`historic <historic>`.
48
+ historic: bool
49
+ #: Whether the hook :ref:`warns when implemented <warn_on_impl>`.
50
+ warn_on_impl: Warning | None
51
+ #: Whether the hook warns when :ref:`certain arguments are requested
52
+ #: <warn_on_impl>`.
53
+ #:
54
+ #: .. versionadded:: 1.5
55
+ warn_on_impl_args: Mapping[str, Warning] | None
56
+
57
+
58
+ class HookimplOpts(TypedDict):
59
+ """Options for a hook implementation."""
60
+
61
+ #: Whether the hook implementation is a :ref:`wrapper <hookwrapper>`.
62
+ wrapper: bool
63
+ #: Whether the hook implementation is an :ref:`old-style wrapper
64
+ #: <old_style_hookwrappers>`.
65
+ hookwrapper: bool
66
+ #: Whether validation against a hook specification is :ref:`optional
67
+ #: <optionalhook>`.
68
+ optionalhook: bool
69
+ #: Whether to try to order this hook implementation :ref:`first
70
+ #: <callorder>`.
71
+ tryfirst: bool
72
+ #: Whether to try to order this hook implementation :ref:`last
73
+ #: <callorder>`.
74
+ trylast: bool
75
+ #: The name of the hook specification to match, see :ref:`specname`.
76
+ specname: str | None
77
+
78
+
79
+ @final
80
+ class HookspecMarker:
81
+ """Decorator for marking functions as hook specifications.
82
+
83
+ Instantiate it with a project_name to get a decorator.
84
+ Calling :meth:`PluginManager.add_hookspecs` later will discover all marked
85
+ functions if the :class:`PluginManager` uses the same project name.
86
+ """
87
+
88
+ __slots__ = ("project_name",)
89
+
90
+ def __init__(self, project_name: str) -> None:
91
+ self.project_name: Final = project_name
92
+
93
+ @overload
94
+ def __call__(
95
+ self,
96
+ function: _F,
97
+ firstresult: bool = False,
98
+ historic: bool = False,
99
+ warn_on_impl: Warning | None = None,
100
+ warn_on_impl_args: Mapping[str, Warning] | None = None,
101
+ ) -> _F: ...
102
+
103
+ @overload # noqa: F811
104
+ def __call__( # noqa: F811
105
+ self,
106
+ function: None = ...,
107
+ firstresult: bool = ...,
108
+ historic: bool = ...,
109
+ warn_on_impl: Warning | None = ...,
110
+ warn_on_impl_args: Mapping[str, Warning] | None = ...,
111
+ ) -> Callable[[_F], _F]: ...
112
+
113
+ def __call__( # noqa: F811
114
+ self,
115
+ function: _F | None = None,
116
+ firstresult: bool = False,
117
+ historic: bool = False,
118
+ warn_on_impl: Warning | None = None,
119
+ warn_on_impl_args: Mapping[str, Warning] | None = None,
120
+ ) -> _F | Callable[[_F], _F]:
121
+ """If passed a function, directly sets attributes on the function
122
+ which will make it discoverable to :meth:`PluginManager.add_hookspecs`.
123
+
124
+ If passed no function, returns a decorator which can be applied to a
125
+ function later using the attributes supplied.
126
+
127
+ :param firstresult:
128
+ If ``True``, the 1:N hook call (N being the number of registered
129
+ hook implementation functions) will stop at I<=N when the I'th
130
+ function returns a non-``None`` result. See :ref:`firstresult`.
131
+
132
+ :param historic:
133
+ If ``True``, every call to the hook will be memorized and replayed
134
+ on plugins registered after the call was made. See :ref:`historic`.
135
+
136
+ :param warn_on_impl:
137
+ If given, every implementation of this hook will trigger the given
138
+ warning. See :ref:`warn_on_impl`.
139
+
140
+ :param warn_on_impl_args:
141
+ If given, every implementation of this hook which requests one of
142
+ the arguments in the dict will trigger the corresponding warning.
143
+ See :ref:`warn_on_impl`.
144
+
145
+ .. versionadded:: 1.5
146
+ """
147
+
148
+ def setattr_hookspec_opts(func: _F) -> _F:
149
+ if historic and firstresult:
150
+ raise ValueError("cannot have a historic firstresult hook")
151
+ opts: HookspecOpts = {
152
+ "firstresult": firstresult,
153
+ "historic": historic,
154
+ "warn_on_impl": warn_on_impl,
155
+ "warn_on_impl_args": warn_on_impl_args,
156
+ }
157
+ setattr(func, self.project_name + "_spec", opts)
158
+ return func
159
+
160
+ if function is not None:
161
+ return setattr_hookspec_opts(function)
162
+ else:
163
+ return setattr_hookspec_opts
164
+
165
+
166
+ @final
167
+ class HookimplMarker:
168
+ """Decorator for marking functions as hook implementations.
169
+
170
+ Instantiate it with a ``project_name`` to get a decorator.
171
+ Calling :meth:`PluginManager.register` later will discover all marked
172
+ functions if the :class:`PluginManager` uses the same project name.
173
+ """
174
+
175
+ __slots__ = ("project_name",)
176
+
177
+ def __init__(self, project_name: str) -> None:
178
+ self.project_name: Final = project_name
179
+
180
+ @overload
181
+ def __call__(
182
+ self,
183
+ function: _F,
184
+ hookwrapper: bool = ...,
185
+ optionalhook: bool = ...,
186
+ tryfirst: bool = ...,
187
+ trylast: bool = ...,
188
+ specname: str | None = ...,
189
+ wrapper: bool = ...,
190
+ ) -> _F: ...
191
+
192
+ @overload # noqa: F811
193
+ def __call__( # noqa: F811
194
+ self,
195
+ function: None = ...,
196
+ hookwrapper: bool = ...,
197
+ optionalhook: bool = ...,
198
+ tryfirst: bool = ...,
199
+ trylast: bool = ...,
200
+ specname: str | None = ...,
201
+ wrapper: bool = ...,
202
+ ) -> Callable[[_F], _F]: ...
203
+
204
+ def __call__( # noqa: F811
205
+ self,
206
+ function: _F | None = None,
207
+ hookwrapper: bool = False,
208
+ optionalhook: bool = False,
209
+ tryfirst: bool = False,
210
+ trylast: bool = False,
211
+ specname: str | None = None,
212
+ wrapper: bool = False,
213
+ ) -> _F | Callable[[_F], _F]:
214
+ """If passed a function, directly sets attributes on the function
215
+ which will make it discoverable to :meth:`PluginManager.register`.
216
+
217
+ If passed no function, returns a decorator which can be applied to a
218
+ function later using the attributes supplied.
219
+
220
+ :param optionalhook:
221
+ If ``True``, a missing matching hook specification will not result
222
+ in an error (by default it is an error if no matching spec is
223
+ found). See :ref:`optionalhook`.
224
+
225
+ :param tryfirst:
226
+ If ``True``, this hook implementation will run as early as possible
227
+ in the chain of N hook implementations for a specification. See
228
+ :ref:`callorder`.
229
+
230
+ :param trylast:
231
+ If ``True``, this hook implementation will run as late as possible
232
+ in the chain of N hook implementations for a specification. See
233
+ :ref:`callorder`.
234
+
235
+ :param wrapper:
236
+ If ``True`` ("new-style hook wrapper"), the hook implementation
237
+ needs to execute exactly one ``yield``. The code before the
238
+ ``yield`` is run early before any non-hook-wrapper function is run.
239
+ The code after the ``yield`` is run after all non-hook-wrapper
240
+ functions have run. The ``yield`` receives the result value of the
241
+ inner calls, or raises the exception of inner calls (including
242
+ earlier hook wrapper calls). The return value of the function
243
+ becomes the return value of the hook, and a raised exception becomes
244
+ the exception of the hook. See :ref:`hookwrapper`.
245
+
246
+ :param hookwrapper:
247
+ If ``True`` ("old-style hook wrapper"), the hook implementation
248
+ needs to execute exactly one ``yield``. The code before the
249
+ ``yield`` is run early before any non-hook-wrapper function is run.
250
+ The code after the ``yield`` is run after all non-hook-wrapper
251
+ function have run The ``yield`` receives a :class:`Result` object
252
+ representing the exception or result outcome of the inner calls
253
+ (including earlier hook wrapper calls). This option is mutually
254
+ exclusive with ``wrapper``. See :ref:`old_style_hookwrapper`.
255
+
256
+ :param specname:
257
+ If provided, the given name will be used instead of the function
258
+ name when matching this hook implementation to a hook specification
259
+ during registration. See :ref:`specname`.
260
+
261
+ .. versionadded:: 1.2.0
262
+ The ``wrapper`` parameter.
263
+ """
264
+
265
+ def setattr_hookimpl_opts(func: _F) -> _F:
266
+ opts: HookimplOpts = {
267
+ "wrapper": wrapper,
268
+ "hookwrapper": hookwrapper,
269
+ "optionalhook": optionalhook,
270
+ "tryfirst": tryfirst,
271
+ "trylast": trylast,
272
+ "specname": specname,
273
+ }
274
+ setattr(func, self.project_name + "_impl", opts)
275
+ return func
276
+
277
+ if function is None:
278
+ return setattr_hookimpl_opts
279
+ else:
280
+ return setattr_hookimpl_opts(function)
281
+
282
+
283
+ def normalize_hookimpl_opts(opts: HookimplOpts) -> None:
284
+ opts.setdefault("tryfirst", False)
285
+ opts.setdefault("trylast", False)
286
+ opts.setdefault("wrapper", False)
287
+ opts.setdefault("hookwrapper", False)
288
+ opts.setdefault("optionalhook", False)
289
+ opts.setdefault("specname", None)
290
+
291
+
292
+ _PYPY = hasattr(sys, "pypy_version_info")
293
+
294
+
295
+ def varnames(func: object) -> tuple[tuple[str, ...], tuple[str, ...]]:
296
+ """Return tuple of positional and keywrord argument names for a function,
297
+ method, class or callable.
298
+
299
+ In case of a class, its ``__init__`` method is considered.
300
+ For methods the ``self`` parameter is not included.
301
+ """
302
+ if inspect.isclass(func):
303
+ try:
304
+ func = func.__init__
305
+ except AttributeError:
306
+ return (), ()
307
+ elif not inspect.isroutine(func): # callable object?
308
+ try:
309
+ func = getattr(func, "__call__", func)
310
+ except Exception:
311
+ return (), ()
312
+
313
+ try:
314
+ # func MUST be a function or method here or we won't parse any args.
315
+ sig = inspect.signature(
316
+ func.__func__ if inspect.ismethod(func) else func # type:ignore[arg-type]
317
+ )
318
+ except TypeError:
319
+ return (), ()
320
+
321
+ _valid_param_kinds = (
322
+ inspect.Parameter.POSITIONAL_ONLY,
323
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
324
+ )
325
+ _valid_params = {
326
+ name: param
327
+ for name, param in sig.parameters.items()
328
+ if param.kind in _valid_param_kinds
329
+ }
330
+ args = tuple(_valid_params)
331
+ defaults = (
332
+ tuple(
333
+ param.default
334
+ for param in _valid_params.values()
335
+ if param.default is not param.empty
336
+ )
337
+ or None
338
+ )
339
+
340
+ if defaults:
341
+ index = -len(defaults)
342
+ args, kwargs = args[:index], tuple(args[index:])
343
+ else:
344
+ kwargs = ()
345
+
346
+ # strip any implicit instance arg
347
+ # pypy3 uses "obj" instead of "self" for default dunder methods
348
+ if not _PYPY:
349
+ implicit_names: tuple[str, ...] = ("self",)
350
+ else:
351
+ implicit_names = ("self", "obj")
352
+ if args:
353
+ qualname: str = getattr(func, "__qualname__", "")
354
+ if inspect.ismethod(func) or ("." in qualname and args[0] in implicit_names):
355
+ args = args[1:]
356
+
357
+ return args, kwargs
358
+
359
+
360
+ @final
361
+ class HookRelay:
362
+ """Hook holder object for performing 1:N hook calls where N is the number
363
+ of registered plugins."""
364
+
365
+ __slots__ = ("__dict__",)
366
+
367
+ def __init__(self) -> None:
368
+ """:meta private:"""
369
+
370
+ if TYPE_CHECKING:
371
+
372
+ def __getattr__(self, name: str) -> HookCaller: ...
373
+
374
+
375
+ # Historical name (pluggy<=1.2), kept for backward compatibility.
376
+ _HookRelay = HookRelay
377
+
378
+
379
+ _CallHistory = List[Tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]
380
+
381
+
382
+ class HookCaller:
383
+ """A caller of all registered implementations of a hook specification."""
384
+
385
+ __slots__ = (
386
+ "name",
387
+ "spec",
388
+ "_hookexec",
389
+ "_hookimpls",
390
+ "_call_history",
391
+ )
392
+
393
+ def __init__(
394
+ self,
395
+ name: str,
396
+ hook_execute: _HookExec,
397
+ specmodule_or_class: _Namespace | None = None,
398
+ spec_opts: HookspecOpts | None = None,
399
+ ) -> None:
400
+ """:meta private:"""
401
+ #: Name of the hook getting called.
402
+ self.name: Final = name
403
+ self._hookexec: Final = hook_execute
404
+ # The hookimpls list. The caller iterates it *in reverse*. Format:
405
+ # 1. trylast nonwrappers
406
+ # 2. nonwrappers
407
+ # 3. tryfirst nonwrappers
408
+ # 4. trylast wrappers
409
+ # 5. wrappers
410
+ # 6. tryfirst wrappers
411
+ self._hookimpls: Final[list[HookImpl]] = []
412
+ self._call_history: _CallHistory | None = None
413
+ # TODO: Document, or make private.
414
+ self.spec: HookSpec | None = None
415
+ if specmodule_or_class is not None:
416
+ assert spec_opts is not None
417
+ self.set_specification(specmodule_or_class, spec_opts)
418
+
419
+ # TODO: Document, or make private.
420
+ def has_spec(self) -> bool:
421
+ return self.spec is not None
422
+
423
+ # TODO: Document, or make private.
424
+ def set_specification(
425
+ self,
426
+ specmodule_or_class: _Namespace,
427
+ spec_opts: HookspecOpts,
428
+ ) -> None:
429
+ if self.spec is not None:
430
+ raise ValueError(
431
+ f"Hook {self.spec.name!r} is already registered "
432
+ f"within namespace {self.spec.namespace}"
433
+ )
434
+ self.spec = HookSpec(specmodule_or_class, self.name, spec_opts)
435
+ if spec_opts.get("historic"):
436
+ self._call_history = []
437
+
438
+ def is_historic(self) -> bool:
439
+ """Whether this caller is :ref:`historic <historic>`."""
440
+ return self._call_history is not None
441
+
442
+ def _remove_plugin(self, plugin: _Plugin) -> None:
443
+ for i, method in enumerate(self._hookimpls):
444
+ if method.plugin == plugin:
445
+ del self._hookimpls[i]
446
+ return
447
+ raise ValueError(f"plugin {plugin!r} not found")
448
+
449
+ def get_hookimpls(self) -> list[HookImpl]:
450
+ """Get all registered hook implementations for this hook."""
451
+ return self._hookimpls.copy()
452
+
453
+ def _add_hookimpl(self, hookimpl: HookImpl) -> None:
454
+ """Add an implementation to the callback chain."""
455
+ for i, method in enumerate(self._hookimpls):
456
+ if method.hookwrapper or method.wrapper:
457
+ splitpoint = i
458
+ break
459
+ else:
460
+ splitpoint = len(self._hookimpls)
461
+ if hookimpl.hookwrapper or hookimpl.wrapper:
462
+ start, end = splitpoint, len(self._hookimpls)
463
+ else:
464
+ start, end = 0, splitpoint
465
+
466
+ if hookimpl.trylast:
467
+ self._hookimpls.insert(start, hookimpl)
468
+ elif hookimpl.tryfirst:
469
+ self._hookimpls.insert(end, hookimpl)
470
+ else:
471
+ # find last non-tryfirst method
472
+ i = end - 1
473
+ while i >= start and self._hookimpls[i].tryfirst:
474
+ i -= 1
475
+ self._hookimpls.insert(i + 1, hookimpl)
476
+
477
+ def __repr__(self) -> str:
478
+ return f"<HookCaller {self.name!r}>"
479
+
480
+ def _verify_all_args_are_provided(self, kwargs: Mapping[str, object]) -> None:
481
+ # This is written to avoid expensive operations when not needed.
482
+ if self.spec:
483
+ for argname in self.spec.argnames:
484
+ if argname not in kwargs:
485
+ notincall = ", ".join(
486
+ repr(argname)
487
+ for argname in self.spec.argnames
488
+ # Avoid self.spec.argnames - kwargs.keys() - doesn't preserve order.
489
+ if argname not in kwargs.keys()
490
+ )
491
+ warnings.warn(
492
+ "Argument(s) {} which are declared in the hookspec "
493
+ "cannot be found in this hook call".format(notincall),
494
+ stacklevel=2,
495
+ )
496
+ break
497
+
498
+ def __call__(self, **kwargs: object) -> Any:
499
+ """Call the hook.
500
+
501
+ Only accepts keyword arguments, which should match the hook
502
+ specification.
503
+
504
+ Returns the result(s) of calling all registered plugins, see
505
+ :ref:`calling`.
506
+ """
507
+ assert (
508
+ not self.is_historic()
509
+ ), "Cannot directly call a historic hook - use call_historic instead."
510
+ self._verify_all_args_are_provided(kwargs)
511
+ firstresult = self.spec.opts.get("firstresult", False) if self.spec else False
512
+ # Copy because plugins may register other plugins during iteration (#438).
513
+ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
514
+
515
+ def call_historic(
516
+ self,
517
+ result_callback: Callable[[Any], None] | None = None,
518
+ kwargs: Mapping[str, object] | None = None,
519
+ ) -> None:
520
+ """Call the hook with given ``kwargs`` for all registered plugins and
521
+ for all plugins which will be registered afterwards, see
522
+ :ref:`historic`.
523
+
524
+ :param result_callback:
525
+ If provided, will be called for each non-``None`` result obtained
526
+ from a hook implementation.
527
+ """
528
+ assert self._call_history is not None
529
+ kwargs = kwargs or {}
530
+ self._verify_all_args_are_provided(kwargs)
531
+ self._call_history.append((kwargs, result_callback))
532
+ # Historizing hooks don't return results.
533
+ # Remember firstresult isn't compatible with historic.
534
+ # Copy because plugins may register other plugins during iteration (#438).
535
+ res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
536
+ if result_callback is None:
537
+ return
538
+ if isinstance(res, list):
539
+ for x in res:
540
+ result_callback(x)
541
+
542
+ def call_extra(
543
+ self, methods: Sequence[Callable[..., object]], kwargs: Mapping[str, object]
544
+ ) -> Any:
545
+ """Call the hook with some additional temporarily participating
546
+ methods using the specified ``kwargs`` as call parameters, see
547
+ :ref:`call_extra`."""
548
+ assert (
549
+ not self.is_historic()
550
+ ), "Cannot directly call a historic hook - use call_historic instead."
551
+ self._verify_all_args_are_provided(kwargs)
552
+ opts: HookimplOpts = {
553
+ "wrapper": False,
554
+ "hookwrapper": False,
555
+ "optionalhook": False,
556
+ "trylast": False,
557
+ "tryfirst": False,
558
+ "specname": None,
559
+ }
560
+ hookimpls = self._hookimpls.copy()
561
+ for method in methods:
562
+ hookimpl = HookImpl(None, "<temp>", method, opts)
563
+ # Find last non-tryfirst nonwrapper method.
564
+ i = len(hookimpls) - 1
565
+ while i >= 0 and (
566
+ # Skip wrappers.
567
+ (hookimpls[i].hookwrapper or hookimpls[i].wrapper)
568
+ # Skip tryfirst nonwrappers.
569
+ or hookimpls[i].tryfirst
570
+ ):
571
+ i -= 1
572
+ hookimpls.insert(i + 1, hookimpl)
573
+ firstresult = self.spec.opts.get("firstresult", False) if self.spec else False
574
+ return self._hookexec(self.name, hookimpls, kwargs, firstresult)
575
+
576
+ def _maybe_apply_history(self, method: HookImpl) -> None:
577
+ """Apply call history to a new hookimpl if it is marked as historic."""
578
+ if self.is_historic():
579
+ assert self._call_history is not None
580
+ for kwargs, result_callback in self._call_history:
581
+ res = self._hookexec(self.name, [method], kwargs, False)
582
+ if res and result_callback is not None:
583
+ # XXX: remember firstresult isn't compat with historic
584
+ assert isinstance(res, list)
585
+ result_callback(res[0])
586
+
587
+
588
+ # Historical name (pluggy<=1.2), kept for backward compatibility.
589
+ _HookCaller = HookCaller
590
+
591
+
592
+ class _SubsetHookCaller(HookCaller):
593
+ """A proxy to another HookCaller which manages calls to all registered
594
+ plugins except the ones from remove_plugins."""
595
+
596
+ # This class is unusual: in inhertits from `HookCaller` so all of
597
+ # the *code* runs in the class, but it delegates all underlying *data*
598
+ # to the original HookCaller.
599
+ # `subset_hook_caller` used to be implemented by creating a full-fledged
600
+ # HookCaller, copying all hookimpls from the original. This had problems
601
+ # with memory leaks (#346) and historic calls (#347), which make a proxy
602
+ # approach better.
603
+ # An alternative implementation is to use a `_getattr__`/`__getattribute__`
604
+ # proxy, however that adds more overhead and is more tricky to implement.
605
+
606
+ __slots__ = (
607
+ "_orig",
608
+ "_remove_plugins",
609
+ )
610
+
611
+ def __init__(self, orig: HookCaller, remove_plugins: AbstractSet[_Plugin]) -> None:
612
+ self._orig = orig
613
+ self._remove_plugins = remove_plugins
614
+ self.name = orig.name # type: ignore[misc]
615
+ self._hookexec = orig._hookexec # type: ignore[misc]
616
+
617
+ @property # type: ignore[misc]
618
+ def _hookimpls(self) -> list[HookImpl]:
619
+ return [
620
+ impl
621
+ for impl in self._orig._hookimpls
622
+ if impl.plugin not in self._remove_plugins
623
+ ]
624
+
625
+ @property
626
+ def spec(self) -> HookSpec | None: # type: ignore[override]
627
+ return self._orig.spec
628
+
629
+ @property
630
+ def _call_history(self) -> _CallHistory | None: # type: ignore[override]
631
+ return self._orig._call_history
632
+
633
+ def __repr__(self) -> str:
634
+ return f"<_SubsetHookCaller {self.name!r}>"
635
+
636
+
637
+ @final
638
+ class HookImpl:
639
+ """A hook implementation in a :class:`HookCaller`."""
640
+
641
+ __slots__ = (
642
+ "function",
643
+ "argnames",
644
+ "kwargnames",
645
+ "plugin",
646
+ "opts",
647
+ "plugin_name",
648
+ "wrapper",
649
+ "hookwrapper",
650
+ "optionalhook",
651
+ "tryfirst",
652
+ "trylast",
653
+ )
654
+
655
+ def __init__(
656
+ self,
657
+ plugin: _Plugin,
658
+ plugin_name: str,
659
+ function: _HookImplFunction[object],
660
+ hook_impl_opts: HookimplOpts,
661
+ ) -> None:
662
+ """:meta private:"""
663
+ #: The hook implementation function.
664
+ self.function: Final = function
665
+ argnames, kwargnames = varnames(self.function)
666
+ #: The positional parameter names of ``function```.
667
+ self.argnames: Final = argnames
668
+ #: The keyword parameter names of ``function```.
669
+ self.kwargnames: Final = kwargnames
670
+ #: The plugin which defined this hook implementation.
671
+ self.plugin: Final = plugin
672
+ #: The :class:`HookimplOpts` used to configure this hook implementation.
673
+ self.opts: Final = hook_impl_opts
674
+ #: The name of the plugin which defined this hook implementation.
675
+ self.plugin_name: Final = plugin_name
676
+ #: Whether the hook implementation is a :ref:`wrapper <hookwrapper>`.
677
+ self.wrapper: Final = hook_impl_opts["wrapper"]
678
+ #: Whether the hook implementation is an :ref:`old-style wrapper
679
+ #: <old_style_hookwrappers>`.
680
+ self.hookwrapper: Final = hook_impl_opts["hookwrapper"]
681
+ #: Whether validation against a hook specification is :ref:`optional
682
+ #: <optionalhook>`.
683
+ self.optionalhook: Final = hook_impl_opts["optionalhook"]
684
+ #: Whether to try to order this hook implementation :ref:`first
685
+ #: <callorder>`.
686
+ self.tryfirst: Final = hook_impl_opts["tryfirst"]
687
+ #: Whether to try to order this hook implementation :ref:`last
688
+ #: <callorder>`.
689
+ self.trylast: Final = hook_impl_opts["trylast"]
690
+
691
+ def __repr__(self) -> str:
692
+ return f"<HookImpl plugin_name={self.plugin_name!r}, plugin={self.plugin!r}>"
693
+
694
+
695
+ @final
696
+ class HookSpec:
697
+ __slots__ = (
698
+ "namespace",
699
+ "function",
700
+ "name",
701
+ "argnames",
702
+ "kwargnames",
703
+ "opts",
704
+ "warn_on_impl",
705
+ "warn_on_impl_args",
706
+ )
707
+
708
+ def __init__(self, namespace: _Namespace, name: str, opts: HookspecOpts) -> None:
709
+ self.namespace = namespace
710
+ self.function: Callable[..., object] = getattr(namespace, name)
711
+ self.name = name
712
+ self.argnames, self.kwargnames = varnames(self.function)
713
+ self.opts = opts
714
+ self.warn_on_impl = opts.get("warn_on_impl")
715
+ self.warn_on_impl_args = opts.get("warn_on_impl_args")
miniconda3/lib/python3.13/site-packages/pluggy/_manager.py ADDED
@@ -0,0 +1,528 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import inspect
4
+ import types
5
+ from typing import Any
6
+ from typing import Callable
7
+ from typing import cast
8
+ from typing import Final
9
+ from typing import Iterable
10
+ from typing import Mapping
11
+ from typing import Sequence
12
+ from typing import TYPE_CHECKING
13
+ import warnings
14
+
15
+ from . import _tracing
16
+ from ._callers import _multicall
17
+ from ._hooks import _HookImplFunction
18
+ from ._hooks import _Namespace
19
+ from ._hooks import _Plugin
20
+ from ._hooks import _SubsetHookCaller
21
+ from ._hooks import HookCaller
22
+ from ._hooks import HookImpl
23
+ from ._hooks import HookimplOpts
24
+ from ._hooks import HookRelay
25
+ from ._hooks import HookspecOpts
26
+ from ._hooks import normalize_hookimpl_opts
27
+ from ._result import Result
28
+
29
+
30
+ if TYPE_CHECKING:
31
+ # importtlib.metadata import is slow, defer it.
32
+ import importlib.metadata
33
+
34
+
35
+ _BeforeTrace = Callable[[str, Sequence[HookImpl], Mapping[str, Any]], None]
36
+ _AfterTrace = Callable[[Result[Any], str, Sequence[HookImpl], Mapping[str, Any]], None]
37
+
38
+
39
+ def _warn_for_function(warning: Warning, function: Callable[..., object]) -> None:
40
+ func = cast(types.FunctionType, function)
41
+ warnings.warn_explicit(
42
+ warning,
43
+ type(warning),
44
+ lineno=func.__code__.co_firstlineno,
45
+ filename=func.__code__.co_filename,
46
+ )
47
+
48
+
49
+ class PluginValidationError(Exception):
50
+ """Plugin failed validation.
51
+
52
+ :param plugin: The plugin which failed validation.
53
+ :param message: Error message.
54
+ """
55
+
56
+ def __init__(self, plugin: _Plugin, message: str) -> None:
57
+ super().__init__(message)
58
+ #: The plugin which failed validation.
59
+ self.plugin = plugin
60
+
61
+
62
+ class DistFacade:
63
+ """Emulate a pkg_resources Distribution"""
64
+
65
+ def __init__(self, dist: importlib.metadata.Distribution) -> None:
66
+ self._dist = dist
67
+
68
+ @property
69
+ def project_name(self) -> str:
70
+ name: str = self.metadata["name"]
71
+ return name
72
+
73
+ def __getattr__(self, attr: str, default=None):
74
+ return getattr(self._dist, attr, default)
75
+
76
+ def __dir__(self) -> list[str]:
77
+ return sorted(dir(self._dist) + ["_dist", "project_name"])
78
+
79
+
80
+ class PluginManager:
81
+ """Core class which manages registration of plugin objects and 1:N hook
82
+ calling.
83
+
84
+ You can register new hooks by calling :meth:`add_hookspecs(module_or_class)
85
+ <PluginManager.add_hookspecs>`.
86
+
87
+ You can register plugin objects (which contain hook implementations) by
88
+ calling :meth:`register(plugin) <PluginManager.register>`.
89
+
90
+ For debugging purposes you can call :meth:`PluginManager.enable_tracing`
91
+ which will subsequently send debug information to the trace helper.
92
+
93
+ :param project_name:
94
+ The short project name. Prefer snake case. Make sure it's unique!
95
+ """
96
+
97
+ def __init__(self, project_name: str) -> None:
98
+ #: The project name.
99
+ self.project_name: Final = project_name
100
+ self._name2plugin: Final[dict[str, _Plugin]] = {}
101
+ self._plugin_distinfo: Final[list[tuple[_Plugin, DistFacade]]] = []
102
+ #: The "hook relay", used to call a hook on all registered plugins.
103
+ #: See :ref:`calling`.
104
+ self.hook: Final = HookRelay()
105
+ #: The tracing entry point. See :ref:`tracing`.
106
+ self.trace: Final[_tracing.TagTracerSub] = _tracing.TagTracer().get(
107
+ "pluginmanage"
108
+ )
109
+ self._inner_hookexec = _multicall
110
+
111
+ def _hookexec(
112
+ self,
113
+ hook_name: str,
114
+ methods: Sequence[HookImpl],
115
+ kwargs: Mapping[str, object],
116
+ firstresult: bool,
117
+ ) -> object | list[object]:
118
+ # called from all hookcaller instances.
119
+ # enable_tracing will set its own wrapping function at self._inner_hookexec
120
+ return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
121
+
122
+ def register(self, plugin: _Plugin, name: str | None = None) -> str | None:
123
+ """Register a plugin and return its name.
124
+
125
+ :param name:
126
+ The name under which to register the plugin. If not specified, a
127
+ name is generated using :func:`get_canonical_name`.
128
+
129
+ :returns:
130
+ The plugin name. If the name is blocked from registering, returns
131
+ ``None``.
132
+
133
+ If the plugin is already registered, raises a :exc:`ValueError`.
134
+ """
135
+ plugin_name = name or self.get_canonical_name(plugin)
136
+
137
+ if plugin_name in self._name2plugin:
138
+ if self._name2plugin.get(plugin_name, -1) is None:
139
+ return None # blocked plugin, return None to indicate no registration
140
+ raise ValueError(
141
+ "Plugin name already registered: %s=%s\n%s"
142
+ % (plugin_name, plugin, self._name2plugin)
143
+ )
144
+
145
+ if plugin in self._name2plugin.values():
146
+ raise ValueError(
147
+ "Plugin already registered under a different name: %s=%s\n%s"
148
+ % (plugin_name, plugin, self._name2plugin)
149
+ )
150
+
151
+ # XXX if an error happens we should make sure no state has been
152
+ # changed at point of return
153
+ self._name2plugin[plugin_name] = plugin
154
+
155
+ # register matching hook implementations of the plugin
156
+ for name in dir(plugin):
157
+ hookimpl_opts = self.parse_hookimpl_opts(plugin, name)
158
+ if hookimpl_opts is not None:
159
+ normalize_hookimpl_opts(hookimpl_opts)
160
+ method: _HookImplFunction[object] = getattr(plugin, name)
161
+ hookimpl = HookImpl(plugin, plugin_name, method, hookimpl_opts)
162
+ name = hookimpl_opts.get("specname") or name
163
+ hook: HookCaller | None = getattr(self.hook, name, None)
164
+ if hook is None:
165
+ hook = HookCaller(name, self._hookexec)
166
+ setattr(self.hook, name, hook)
167
+ elif hook.has_spec():
168
+ self._verify_hook(hook, hookimpl)
169
+ hook._maybe_apply_history(hookimpl)
170
+ hook._add_hookimpl(hookimpl)
171
+ return plugin_name
172
+
173
+ def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookimplOpts | None:
174
+ """Try to obtain a hook implementation from an item with the given name
175
+ in the given plugin which is being searched for hook impls.
176
+
177
+ :returns:
178
+ The parsed hookimpl options, or None to skip the given item.
179
+
180
+ This method can be overridden by ``PluginManager`` subclasses to
181
+ customize how hook implementation are picked up. By default, returns the
182
+ options for items decorated with :class:`HookimplMarker`.
183
+ """
184
+ method: object = getattr(plugin, name)
185
+ if not inspect.isroutine(method):
186
+ return None
187
+ try:
188
+ res: HookimplOpts | None = getattr(
189
+ method, self.project_name + "_impl", None
190
+ )
191
+ except Exception:
192
+ res = {} # type: ignore[assignment]
193
+ if res is not None and not isinstance(res, dict):
194
+ # false positive
195
+ res = None # type:ignore[unreachable]
196
+ return res
197
+
198
+ def unregister(
199
+ self, plugin: _Plugin | None = None, name: str | None = None
200
+ ) -> Any | None:
201
+ """Unregister a plugin and all of its hook implementations.
202
+
203
+ The plugin can be specified either by the plugin object or the plugin
204
+ name. If both are specified, they must agree.
205
+
206
+ Returns the unregistered plugin, or ``None`` if not found.
207
+ """
208
+ if name is None:
209
+ assert plugin is not None, "one of name or plugin needs to be specified"
210
+ name = self.get_name(plugin)
211
+ assert name is not None, "plugin is not registered"
212
+
213
+ if plugin is None:
214
+ plugin = self.get_plugin(name)
215
+ if plugin is None:
216
+ return None
217
+
218
+ hookcallers = self.get_hookcallers(plugin)
219
+ if hookcallers:
220
+ for hookcaller in hookcallers:
221
+ hookcaller._remove_plugin(plugin)
222
+
223
+ # if self._name2plugin[name] == None registration was blocked: ignore
224
+ if self._name2plugin.get(name):
225
+ assert name is not None
226
+ del self._name2plugin[name]
227
+
228
+ return plugin
229
+
230
+ def set_blocked(self, name: str) -> None:
231
+ """Block registrations of the given name, unregister if already registered."""
232
+ self.unregister(name=name)
233
+ self._name2plugin[name] = None
234
+
235
+ def is_blocked(self, name: str) -> bool:
236
+ """Return whether the given plugin name is blocked."""
237
+ return name in self._name2plugin and self._name2plugin[name] is None
238
+
239
+ def unblock(self, name: str) -> bool:
240
+ """Unblocks a name.
241
+
242
+ Returns whether the name was actually blocked.
243
+ """
244
+ if self._name2plugin.get(name, -1) is None:
245
+ del self._name2plugin[name]
246
+ return True
247
+ return False
248
+
249
+ def add_hookspecs(self, module_or_class: _Namespace) -> None:
250
+ """Add new hook specifications defined in the given ``module_or_class``.
251
+
252
+ Functions are recognized as hook specifications if they have been
253
+ decorated with a matching :class:`HookspecMarker`.
254
+ """
255
+ names = []
256
+ for name in dir(module_or_class):
257
+ spec_opts = self.parse_hookspec_opts(module_or_class, name)
258
+ if spec_opts is not None:
259
+ hc: HookCaller | None = getattr(self.hook, name, None)
260
+ if hc is None:
261
+ hc = HookCaller(name, self._hookexec, module_or_class, spec_opts)
262
+ setattr(self.hook, name, hc)
263
+ else:
264
+ # Plugins registered this hook without knowing the spec.
265
+ hc.set_specification(module_or_class, spec_opts)
266
+ for hookfunction in hc.get_hookimpls():
267
+ self._verify_hook(hc, hookfunction)
268
+ names.append(name)
269
+
270
+ if not names:
271
+ raise ValueError(
272
+ f"did not find any {self.project_name!r} hooks in {module_or_class!r}"
273
+ )
274
+
275
+ def parse_hookspec_opts(
276
+ self, module_or_class: _Namespace, name: str
277
+ ) -> HookspecOpts | None:
278
+ """Try to obtain a hook specification from an item with the given name
279
+ in the given module or class which is being searched for hook specs.
280
+
281
+ :returns:
282
+ The parsed hookspec options for defining a hook, or None to skip the
283
+ given item.
284
+
285
+ This method can be overridden by ``PluginManager`` subclasses to
286
+ customize how hook specifications are picked up. By default, returns the
287
+ options for items decorated with :class:`HookspecMarker`.
288
+ """
289
+ method = getattr(module_or_class, name)
290
+ opts: HookspecOpts | None = getattr(method, self.project_name + "_spec", None)
291
+ return opts
292
+
293
+ def get_plugins(self) -> set[Any]:
294
+ """Return a set of all registered plugin objects."""
295
+ return {x for x in self._name2plugin.values() if x is not None}
296
+
297
+ def is_registered(self, plugin: _Plugin) -> bool:
298
+ """Return whether the plugin is already registered."""
299
+ return any(plugin == val for val in self._name2plugin.values())
300
+
301
+ def get_canonical_name(self, plugin: _Plugin) -> str:
302
+ """Return a canonical name for a plugin object.
303
+
304
+ Note that a plugin may be registered under a different name
305
+ specified by the caller of :meth:`register(plugin, name) <register>`.
306
+ To obtain the name of a registered plugin use :meth:`get_name(plugin)
307
+ <get_name>` instead.
308
+ """
309
+ name: str | None = getattr(plugin, "__name__", None)
310
+ return name or str(id(plugin))
311
+
312
+ def get_plugin(self, name: str) -> Any | None:
313
+ """Return the plugin registered under the given name, if any."""
314
+ return self._name2plugin.get(name)
315
+
316
+ def has_plugin(self, name: str) -> bool:
317
+ """Return whether a plugin with the given name is registered."""
318
+ return self.get_plugin(name) is not None
319
+
320
+ def get_name(self, plugin: _Plugin) -> str | None:
321
+ """Return the name the plugin is registered under, or ``None`` if
322
+ is isn't."""
323
+ for name, val in self._name2plugin.items():
324
+ if plugin == val:
325
+ return name
326
+ return None
327
+
328
+ def _verify_hook(self, hook: HookCaller, hookimpl: HookImpl) -> None:
329
+ if hook.is_historic() and (hookimpl.hookwrapper or hookimpl.wrapper):
330
+ raise PluginValidationError(
331
+ hookimpl.plugin,
332
+ "Plugin %r\nhook %r\nhistoric incompatible with yield/wrapper/hookwrapper"
333
+ % (hookimpl.plugin_name, hook.name),
334
+ )
335
+
336
+ assert hook.spec is not None
337
+ if hook.spec.warn_on_impl:
338
+ _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
339
+
340
+ # positional arg checking
341
+ notinspec = set(hookimpl.argnames) - set(hook.spec.argnames)
342
+ if notinspec:
343
+ raise PluginValidationError(
344
+ hookimpl.plugin,
345
+ "Plugin %r for hook %r\nhookimpl definition: %s\n"
346
+ "Argument(s) %s are declared in the hookimpl but "
347
+ "can not be found in the hookspec"
348
+ % (
349
+ hookimpl.plugin_name,
350
+ hook.name,
351
+ _formatdef(hookimpl.function),
352
+ notinspec,
353
+ ),
354
+ )
355
+
356
+ if hook.spec.warn_on_impl_args:
357
+ for hookimpl_argname in hookimpl.argnames:
358
+ argname_warning = hook.spec.warn_on_impl_args.get(hookimpl_argname)
359
+ if argname_warning is not None:
360
+ _warn_for_function(argname_warning, hookimpl.function)
361
+
362
+ if (
363
+ hookimpl.wrapper or hookimpl.hookwrapper
364
+ ) and not inspect.isgeneratorfunction(hookimpl.function):
365
+ raise PluginValidationError(
366
+ hookimpl.plugin,
367
+ "Plugin %r for hook %r\nhookimpl definition: %s\n"
368
+ "Declared as wrapper=True or hookwrapper=True "
369
+ "but function is not a generator function"
370
+ % (hookimpl.plugin_name, hook.name, _formatdef(hookimpl.function)),
371
+ )
372
+
373
+ if hookimpl.wrapper and hookimpl.hookwrapper:
374
+ raise PluginValidationError(
375
+ hookimpl.plugin,
376
+ "Plugin %r for hook %r\nhookimpl definition: %s\n"
377
+ "The wrapper=True and hookwrapper=True options are mutually exclusive"
378
+ % (hookimpl.plugin_name, hook.name, _formatdef(hookimpl.function)),
379
+ )
380
+
381
+ def check_pending(self) -> None:
382
+ """Verify that all hooks which have not been verified against a
383
+ hook specification are optional, otherwise raise
384
+ :exc:`PluginValidationError`."""
385
+ for name in self.hook.__dict__:
386
+ if name[0] != "_":
387
+ hook: HookCaller = getattr(self.hook, name)
388
+ if not hook.has_spec():
389
+ for hookimpl in hook.get_hookimpls():
390
+ if not hookimpl.optionalhook:
391
+ raise PluginValidationError(
392
+ hookimpl.plugin,
393
+ "unknown hook %r in plugin %r"
394
+ % (name, hookimpl.plugin),
395
+ )
396
+
397
+ def load_setuptools_entrypoints(self, group: str, name: str | None = None) -> int:
398
+ """Load modules from querying the specified setuptools ``group``.
399
+
400
+ :param group:
401
+ Entry point group to load plugins.
402
+ :param name:
403
+ If given, loads only plugins with the given ``name``.
404
+
405
+ :return:
406
+ The number of plugins loaded by this call.
407
+ """
408
+ import importlib.metadata
409
+
410
+ count = 0
411
+ for dist in list(importlib.metadata.distributions()):
412
+ for ep in dist.entry_points:
413
+ if (
414
+ ep.group != group
415
+ or (name is not None and ep.name != name)
416
+ # already registered
417
+ or self.get_plugin(ep.name)
418
+ or self.is_blocked(ep.name)
419
+ ):
420
+ continue
421
+ plugin = ep.load()
422
+ self.register(plugin, name=ep.name)
423
+ self._plugin_distinfo.append((plugin, DistFacade(dist)))
424
+ count += 1
425
+ return count
426
+
427
+ def list_plugin_distinfo(self) -> list[tuple[_Plugin, DistFacade]]:
428
+ """Return a list of (plugin, distinfo) pairs for all
429
+ setuptools-registered plugins."""
430
+ return list(self._plugin_distinfo)
431
+
432
+ def list_name_plugin(self) -> list[tuple[str, _Plugin]]:
433
+ """Return a list of (name, plugin) pairs for all registered plugins."""
434
+ return list(self._name2plugin.items())
435
+
436
+ def get_hookcallers(self, plugin: _Plugin) -> list[HookCaller] | None:
437
+ """Get all hook callers for the specified plugin.
438
+
439
+ :returns:
440
+ The hook callers, or ``None`` if ``plugin`` is not registered in
441
+ this plugin manager.
442
+ """
443
+ if self.get_name(plugin) is None:
444
+ return None
445
+ hookcallers = []
446
+ for hookcaller in self.hook.__dict__.values():
447
+ for hookimpl in hookcaller.get_hookimpls():
448
+ if hookimpl.plugin is plugin:
449
+ hookcallers.append(hookcaller)
450
+ return hookcallers
451
+
452
+ def add_hookcall_monitoring(
453
+ self, before: _BeforeTrace, after: _AfterTrace
454
+ ) -> Callable[[], None]:
455
+ """Add before/after tracing functions for all hooks.
456
+
457
+ Returns an undo function which, when called, removes the added tracers.
458
+
459
+ ``before(hook_name, hook_impls, kwargs)`` will be called ahead
460
+ of all hook calls and receive a hookcaller instance, a list
461
+ of HookImpl instances and the keyword arguments for the hook call.
462
+
463
+ ``after(outcome, hook_name, hook_impls, kwargs)`` receives the
464
+ same arguments as ``before`` but also a :class:`~pluggy.Result` object
465
+ which represents the result of the overall hook call.
466
+ """
467
+ oldcall = self._inner_hookexec
468
+
469
+ def traced_hookexec(
470
+ hook_name: str,
471
+ hook_impls: Sequence[HookImpl],
472
+ caller_kwargs: Mapping[str, object],
473
+ firstresult: bool,
474
+ ) -> object | list[object]:
475
+ before(hook_name, hook_impls, caller_kwargs)
476
+ outcome = Result.from_call(
477
+ lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
478
+ )
479
+ after(outcome, hook_name, hook_impls, caller_kwargs)
480
+ return outcome.get_result()
481
+
482
+ self._inner_hookexec = traced_hookexec
483
+
484
+ def undo() -> None:
485
+ self._inner_hookexec = oldcall
486
+
487
+ return undo
488
+
489
+ def enable_tracing(self) -> Callable[[], None]:
490
+ """Enable tracing of hook calls.
491
+
492
+ Returns an undo function which, when called, removes the added tracing.
493
+ """
494
+ hooktrace = self.trace.root.get("hook")
495
+
496
+ def before(
497
+ hook_name: str, methods: Sequence[HookImpl], kwargs: Mapping[str, object]
498
+ ) -> None:
499
+ hooktrace.root.indent += 1
500
+ hooktrace(hook_name, kwargs)
501
+
502
+ def after(
503
+ outcome: Result[object],
504
+ hook_name: str,
505
+ methods: Sequence[HookImpl],
506
+ kwargs: Mapping[str, object],
507
+ ) -> None:
508
+ if outcome.exception is None:
509
+ hooktrace("finish", hook_name, "-->", outcome.get_result())
510
+ hooktrace.root.indent -= 1
511
+
512
+ return self.add_hookcall_monitoring(before, after)
513
+
514
+ def subset_hook_caller(
515
+ self, name: str, remove_plugins: Iterable[_Plugin]
516
+ ) -> HookCaller:
517
+ """Return a proxy :class:`~pluggy.HookCaller` instance for the named
518
+ method which manages calls to all registered plugins except the ones
519
+ from remove_plugins."""
520
+ orig: HookCaller = getattr(self.hook, name)
521
+ plugins_to_remove = {plug for plug in remove_plugins if hasattr(plug, name)}
522
+ if plugins_to_remove:
523
+ return _SubsetHookCaller(orig, plugins_to_remove)
524
+ return orig
525
+
526
+
527
+ def _formatdef(func: Callable[..., object]) -> str:
528
+ return f"{func.__name__}{inspect.signature(func)}"
miniconda3/lib/python3.13/site-packages/pluggy/_result.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Hook wrapper "result" utilities.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from types import TracebackType
8
+ from typing import Callable
9
+ from typing import cast
10
+ from typing import final
11
+ from typing import Generic
12
+ from typing import Optional
13
+ from typing import Tuple
14
+ from typing import Type
15
+ from typing import TypeVar
16
+
17
+
18
+ _ExcInfo = Tuple[Type[BaseException], BaseException, Optional[TracebackType]]
19
+ ResultType = TypeVar("ResultType")
20
+
21
+
22
+ class HookCallError(Exception):
23
+ """Hook was called incorrectly."""
24
+
25
+
26
+ @final
27
+ class Result(Generic[ResultType]):
28
+ """An object used to inspect and set the result in a :ref:`hook wrapper
29
+ <hookwrappers>`."""
30
+
31
+ __slots__ = ("_result", "_exception")
32
+
33
+ def __init__(
34
+ self,
35
+ result: ResultType | None,
36
+ exception: BaseException | None,
37
+ ) -> None:
38
+ """:meta private:"""
39
+ self._result = result
40
+ self._exception = exception
41
+
42
+ @property
43
+ def excinfo(self) -> _ExcInfo | None:
44
+ """:meta private:"""
45
+ exc = self._exception
46
+ if exc is None:
47
+ return None
48
+ else:
49
+ return (type(exc), exc, exc.__traceback__)
50
+
51
+ @property
52
+ def exception(self) -> BaseException | None:
53
+ """:meta private:"""
54
+ return self._exception
55
+
56
+ @classmethod
57
+ def from_call(cls, func: Callable[[], ResultType]) -> Result[ResultType]:
58
+ """:meta private:"""
59
+ __tracebackhide__ = True
60
+ result = exception = None
61
+ try:
62
+ result = func()
63
+ except BaseException as exc:
64
+ exception = exc
65
+ return cls(result, exception)
66
+
67
+ def force_result(self, result: ResultType) -> None:
68
+ """Force the result(s) to ``result``.
69
+
70
+ If the hook was marked as a ``firstresult`` a single value should
71
+ be set, otherwise set a (modified) list of results. Any exceptions
72
+ found during invocation will be deleted.
73
+
74
+ This overrides any previous result or exception.
75
+ """
76
+ self._result = result
77
+ self._exception = None
78
+
79
+ def force_exception(self, exception: BaseException) -> None:
80
+ """Force the result to fail with ``exception``.
81
+
82
+ This overrides any previous result or exception.
83
+
84
+ .. versionadded:: 1.1.0
85
+ """
86
+ self._result = None
87
+ self._exception = exception
88
+
89
+ def get_result(self) -> ResultType:
90
+ """Get the result(s) for this hook call.
91
+
92
+ If the hook was marked as a ``firstresult`` only a single value
93
+ will be returned, otherwise a list of results.
94
+ """
95
+ __tracebackhide__ = True
96
+ exc = self._exception
97
+ if exc is None:
98
+ return cast(ResultType, self._result)
99
+ else:
100
+ raise exc.with_traceback(exc.__traceback__)
101
+
102
+
103
+ # Historical name (pluggy<=1.2), kept for backward compatibility.
104
+ _Result = Result
miniconda3/lib/python3.13/site-packages/pluggy/_tracing.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tracing utils
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import Any
8
+ from typing import Callable
9
+ from typing import Sequence
10
+ from typing import Tuple
11
+
12
+
13
+ _Writer = Callable[[str], object]
14
+ _Processor = Callable[[Tuple[str, ...], Tuple[Any, ...]], object]
15
+
16
+
17
+ class TagTracer:
18
+ def __init__(self) -> None:
19
+ self._tags2proc: dict[tuple[str, ...], _Processor] = {}
20
+ self._writer: _Writer | None = None
21
+ self.indent = 0
22
+
23
+ def get(self, name: str) -> TagTracerSub:
24
+ return TagTracerSub(self, (name,))
25
+
26
+ def _format_message(self, tags: Sequence[str], args: Sequence[object]) -> str:
27
+ if isinstance(args[-1], dict):
28
+ extra = args[-1]
29
+ args = args[:-1]
30
+ else:
31
+ extra = {}
32
+
33
+ content = " ".join(map(str, args))
34
+ indent = " " * self.indent
35
+
36
+ lines = ["{}{} [{}]\n".format(indent, content, ":".join(tags))]
37
+
38
+ for name, value in extra.items():
39
+ lines.append(f"{indent} {name}: {value}\n")
40
+
41
+ return "".join(lines)
42
+
43
+ def _processmessage(self, tags: tuple[str, ...], args: tuple[object, ...]) -> None:
44
+ if self._writer is not None and args:
45
+ self._writer(self._format_message(tags, args))
46
+ try:
47
+ processor = self._tags2proc[tags]
48
+ except KeyError:
49
+ pass
50
+ else:
51
+ processor(tags, args)
52
+
53
+ def setwriter(self, writer: _Writer | None) -> None:
54
+ self._writer = writer
55
+
56
+ def setprocessor(self, tags: str | tuple[str, ...], processor: _Processor) -> None:
57
+ if isinstance(tags, str):
58
+ tags = tuple(tags.split(":"))
59
+ else:
60
+ assert isinstance(tags, tuple)
61
+ self._tags2proc[tags] = processor
62
+
63
+
64
+ class TagTracerSub:
65
+ def __init__(self, root: TagTracer, tags: tuple[str, ...]) -> None:
66
+ self.root = root
67
+ self.tags = tags
68
+
69
+ def __call__(self, *args: object) -> None:
70
+ self.root._processmessage(self.tags, args)
71
+
72
+ def get(self, name: str) -> TagTracerSub:
73
+ return self.__class__(self.root, self.tags + (name,))
miniconda3/lib/python3.13/site-packages/pluggy/_version.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '1.5.0'
16
+ __version_tuple__ = version_tuple = (1, 5, 0)
miniconda3/lib/python3.13/site-packages/pluggy/_warnings.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import final
2
+
3
+
4
+ class PluggyWarning(UserWarning):
5
+ """Base class for all warnings emitted by pluggy."""
6
+
7
+ __module__ = "pluggy"
8
+
9
+
10
+ @final
11
+ class PluggyTeardownRaisedWarning(PluggyWarning):
12
+ """A plugin raised an exception during an :ref:`old-style hookwrapper
13
+ <old_style_hookwrappers>` teardown.
14
+
15
+ Such exceptions are not handled by pluggy, and may cause subsequent
16
+ teardowns to be executed at unexpected times, or be skipped entirely.
17
+
18
+ This is an issue in the plugin implementation.
19
+
20
+ If the exception is unintended, fix the underlying cause.
21
+
22
+ If the exception is intended, switch to :ref:`new-style hook wrappers
23
+ <hookwrappers>`, or use :func:`result.force_exception()
24
+ <pluggy.Result.force_exception>` to set the exception instead of raising.
25
+ """
26
+
27
+ __module__ = "pluggy"
miniconda3/lib/python3.13/site-packages/pluggy/py.typed ADDED
File without changes
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/AUTHORS.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ All of the people who have made at least one contribution to pycosat.
2
+ Authors are sorted alphabetically.
3
+
4
+ * Aaron Meurer
5
+ * Bradley M. Froehle
6
+ * Conda Bot
7
+ * Daniel Holth
8
+ * Ilan Schnell
9
+ * Jannis Leidel
10
+ * Ken Odegard
11
+ * Mike Sarahan
12
+ * Ondřej Čertík
13
+ * Ray Donnelly
14
+ * Travis E. Oliphant
15
+ * William Schwartz
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2013, Ilan Schnell, Continuum Analytics, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ IN THE SOFTWARE.
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/METADATA ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: pycosat
3
+ Version: 0.6.6
4
+ Summary: bindings to picosat (a SAT solver)
5
+ Home-page: https://github.com/ContinuumIO/pycosat
6
+ Author: Ilan Schnell
7
+ Author-email: ilan@continuum.io
8
+ License: MIT
9
+ Classifier: Development Status :: 6 - Mature
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: C
13
+ Classifier: Programming Language :: Python :: 2
14
+ Classifier: Programming Language :: Python :: 2.7
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Topic :: Utilities
22
+ License-File: LICENSE
23
+ License-File: AUTHORS.md
24
+
25
+ ===========================================
26
+ pycosat: bindings to picosat (a SAT solver)
27
+ ===========================================
28
+
29
+ `PicoSAT <http://fmv.jku.at/picosat/>`_ is a popular
30
+ `SAT <http://en.wikipedia.org/wiki/Boolean_satisfiability_problem>`_ solver
31
+ written by Armin Biere in pure C.
32
+ This package provides efficient Python bindings to picosat on the C level,
33
+ i.e. when importing pycosat, the picosat solver becomes part of the
34
+ Python process itself. For ease of deployment, the picosat source (namely
35
+ picosat.c and picosat.h) is included in this project. These files have
36
+ been extracted from the picosat source (picosat-965.tar.gz).
37
+
38
+ Usage
39
+ -----
40
+
41
+ The ``pycosat`` module has two functions ``solve`` and ``itersolve``,
42
+ both of which take an iterable of clauses as an argument. Each clause
43
+ is itself represented as an iterable of (non-zero) integers.
44
+
45
+ The function ``solve`` returns one of the following:
46
+ * one solution (a list of integers)
47
+ * the string "UNSAT" (when the clauses are unsatisfiable)
48
+ * the string "UNKNOWN" (when a solution could not be determined within the
49
+ propagation limit)
50
+
51
+ The function ``itersolve`` returns an iterator over solutions. When the
52
+ propagation limit is specified, exhausting the iterator may not yield all
53
+ possible solutions.
54
+
55
+ Both functions take the following keyword arguments:
56
+ * ``prop_limit``: the propagation limit (integer)
57
+ * ``vars``: number of variables (integer)
58
+ * ``verbose``: the verbosity level (integer)
59
+
60
+
61
+ Example
62
+ -------
63
+
64
+ Let us consider the following clauses, represented using
65
+ the DIMACS `cnf <http://en.wikipedia.org/wiki/Conjunctive_normal_form>`_
66
+ format::
67
+
68
+ p cnf 5 3
69
+ 1 -5 4 0
70
+ -1 5 3 4 0
71
+ -3 -4 0
72
+
73
+ Here, we have 5 variables and 3 clauses, the first clause being
74
+ (x\ :sub:`1` or not x\ :sub:`5` or x\ :sub:`4`).
75
+ Note that the variable x\ :sub:`2` is not used in any of the clauses,
76
+ which means that for each solution with x\ :sub:`2` = True, we must
77
+ also have a solution with x\ :sub:`2` = False. In Python, each clause is
78
+ most conveniently represented as a list of integers. Naturally, it makes
79
+ sense to represent each solution also as a list of integers, where the sign
80
+ corresponds to the Boolean value (+ for True and - for False) and the
81
+ absolute value corresponds to i\ :sup:`th` variable::
82
+
83
+ >>> import pycosat
84
+ >>> cnf = [[1, -5, 4], [-1, 5, 3, 4], [-3, -4]]
85
+ >>> pycosat.solve(cnf)
86
+ [1, -2, -3, -4, 5]
87
+
88
+ This solution translates to: x\ :sub:`1` = x\ :sub:`5` = True,
89
+ x\ :sub:`2` = x\ :sub:`3` = x\ :sub:`4` = False
90
+
91
+ To find all solutions, use ``itersolve``::
92
+
93
+ >>> for sol in pycosat.itersolve(cnf):
94
+ ... print sol
95
+ ...
96
+ [1, -2, -3, -4, 5]
97
+ [1, -2, -3, 4, -5]
98
+ [1, -2, -3, 4, 5]
99
+ ...
100
+ >>> len(list(pycosat.itersolve(cnf)))
101
+ 18
102
+
103
+ In this example, there are a total of 18 possible solutions, which had to
104
+ be an even number because x\ :sub:`2` was left unspecified in the clauses.
105
+
106
+ The fact that ``itersolve`` returns an iterator, makes it very elegant
107
+ and efficient for many types of operations. For example, using
108
+ the ``itertools`` module from the standard library, here is how one
109
+ would construct a list of (up to) 3 solutions::
110
+
111
+ >>> import itertools
112
+ >>> list(itertools.islice(pycosat.itersolve(cnf), 3))
113
+ [[1, -2, -3, -4, 5], [1, -2, -3, 4, -5], [1, -2, -3, 4, 5]]
114
+
115
+
116
+ Implementation of itersolve
117
+ ---------------------------
118
+
119
+ How does one go from having found one solution to another solution?
120
+ The answer is surprisingly simple. One adds the *inverse* of the already
121
+ found solution as a new clause. This new clause ensures that another
122
+ solution is searched for, as it *excludes* the already found solution.
123
+ Here is basically a pure Python implementation of ``itersolve`` in terms
124
+ of ``solve``::
125
+
126
+ def py_itersolve(clauses): # don't use this function!
127
+ while True: # (it is only here to explain things)
128
+ sol = pycosat.solve(clauses)
129
+ if isinstance(sol, list):
130
+ yield sol
131
+ clauses.append([-x for x in sol])
132
+ else: # no more solutions -- stop iteration
133
+ return
134
+
135
+ This implementation has several problems. Firstly, it is quite slow as
136
+ ``pycosat.solve`` has to convert the list of clauses over and over and over
137
+ again. Secondly, after calling ``py_itersolve`` the list of clauses will
138
+ be modified. In pycosat, ``itersolve`` is implemented on the C level,
139
+ making use of the picosat C interface (which makes it much, much faster
140
+ than the naive Python implementation above).
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/RECORD ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/test_pycosat.cpython-313.pyc,,
2
+ pycosat-0.6.6.dist-info/AUTHORS.md,sha256=3P0IzZhVbjKQ3pYkPwB4MUdDKHBuWPsu3AEY69so1V4,303
3
+ pycosat-0.6.6.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
4
+ pycosat-0.6.6.dist-info/LICENSE,sha256=Iz2aOx2eDYr7Eg7na5jmXFXt4EFi_jfC6AOj04loAh4,1084
5
+ pycosat-0.6.6.dist-info/METADATA,sha256=w99oSIpweubW4OxchuumR4sQkQt062ooow_Vovr5zH0,5361
6
+ pycosat-0.6.6.dist-info/RECORD,,
7
+ pycosat-0.6.6.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pycosat-0.6.6.dist-info/WHEEL,sha256=3AguxfouGTsGAUBIAhZzQTW_LrLKlfFbnX4zFO0vyHo,104
9
+ pycosat-0.6.6.dist-info/direct_url.json,sha256=YFMQnCu9d0zDZmDhxXboqaSkBd2A1r19s_t4w3VfnSU,67
10
+ pycosat-0.6.6.dist-info/top_level.txt,sha256=R99AzohPlZWIOjm1RWK9iv6o4d_YKzkWUJnHcczYONE,21
11
+ pycosat.cpython-313-x86_64-linux-gnu.so,sha256=NvfcDnTx5K4ARE8RlfFugIqweBO0G7LHGsRAgh9MHm8,97176
12
+ test_pycosat.py,sha256=hIjXavDNbynIk-Hmh2H3uXTs0coRRhoxnpsHNrUH5k0,8836
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/REQUESTED ADDED
File without changes
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.1.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-linux_x86_64
5
+
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/direct_url.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"dir_info": {}, "url": "file:///croot/pycosat_1736868416091/work"}
miniconda3/lib/python3.13/site-packages/pycosat-0.6.6.dist-info/top_level.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ pycosat
2
+ test_pycosat
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/METADATA ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: pycparser
3
+ Version: 2.23
4
+ Summary: C parser in Python
5
+ Home-page: https://github.com/eliben/pycparser
6
+ Author: Eli Bendersky
7
+ Author-email: eliben@gmail.com
8
+ Maintainer: Eli Bendersky
9
+ License: BSD-3-Clause
10
+ Platform: Cross Platform
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.8
21
+ License-File: LICENSE
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: home-page
27
+ Dynamic: license
28
+ Dynamic: license-file
29
+ Dynamic: maintainer
30
+ Dynamic: platform
31
+ Dynamic: requires-python
32
+ Dynamic: summary
33
+
34
+
35
+ pycparser is a complete parser of the C language, written in
36
+ pure Python using the PLY parsing library.
37
+ It parses C code into an AST and can serve as a front-end for
38
+ C compilers or analysis tools.
39
+
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/RECORD ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pycparser-2.23.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ pycparser-2.23.dist-info/METADATA,sha256=5fb53n_0XoR9_Ddek-LMiJPKpEAY6247CHz9MMzi2F0,1210
3
+ pycparser-2.23.dist-info/RECORD,,
4
+ pycparser-2.23.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pycparser-2.23.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
6
+ pycparser-2.23.dist-info/direct_url.json,sha256=WY4-hl51f7oMIAnkgwV2p5hVRTZIZ2R46isFZd8c3AU,99
7
+ pycparser-2.23.dist-info/licenses/LICENSE,sha256=DIRjmTaep23de1xE_m0WSXQV_PAV9cu1CMJL-YuBxbE,1543
8
+ pycparser-2.23.dist-info/top_level.txt,sha256=c-lPcS74L_8KoH7IE6PQF5ofyirRQNV4VhkbSFIPeWM,10
9
+ pycparser/__init__.py,sha256=FQFl5XuxXZiYHrBuN1EElN1COlR8k4aCSdG7h7a7zLw,2918
10
+ pycparser/__pycache__/__init__.cpython-313.pyc,,
11
+ pycparser/__pycache__/_ast_gen.cpython-313.pyc,,
12
+ pycparser/__pycache__/_build_tables.cpython-313.pyc,,
13
+ pycparser/__pycache__/ast_transforms.cpython-313.pyc,,
14
+ pycparser/__pycache__/c_ast.cpython-313.pyc,,
15
+ pycparser/__pycache__/c_generator.cpython-313.pyc,,
16
+ pycparser/__pycache__/c_lexer.cpython-313.pyc,,
17
+ pycparser/__pycache__/c_parser.cpython-313.pyc,,
18
+ pycparser/__pycache__/lextab.cpython-313.pyc,,
19
+ pycparser/__pycache__/plyparser.cpython-313.pyc,,
20
+ pycparser/__pycache__/yacctab.cpython-313.pyc,,
21
+ pycparser/_ast_gen.py,sha256=0JRVnDW-Jw-3IjVlo8je9rbAcp6Ko7toHAnB5zi7h0Q,10555
22
+ pycparser/_build_tables.py,sha256=4d_UkIxJ4YfHTVn6xBzBA52wDo7qxg1B6aZAJYJas9Q,1087
23
+ pycparser/_c_ast.cfg,sha256=ld5ezE9yzIJFIVAUfw7ezJSlMi4nXKNCzfmqjOyQTNo,4255
24
+ pycparser/ast_transforms.py,sha256=GTMYlUgWmXd5wJVyovXY1qzzAqjxzCpVVg0664dKGBs,5691
25
+ pycparser/c_ast.py,sha256=HWeOrfYdCY0u5XaYhE1i60uVyE3yMWdcxzECUX-DqJw,31445
26
+ pycparser/c_generator.py,sha256=XWK3oGM_eVD5d_JfgJxFO95Y6vUMfRi8pov5FQjHH2s,17790
27
+ pycparser/c_lexer.py,sha256=bq7LALBDUw452KT3J7QzHj2qMoCugGWjITNPWD7yiOE,17728
28
+ pycparser/c_parser.py,sha256=ujQZ7y6Qded9h5SDrhtgSlHw0vSYVa_yiMtW9ZnsezY,75462
29
+ pycparser/lextab.py,sha256=eLh3spnPArpAKCVAEK1JCOgUX0L9wrJdfOTLyw8sLRE,8776
30
+ pycparser/ply/__init__.py,sha256=q4s86QwRsYRa20L9ueSxfh-hPihpftBjDOvYa2_SS2Y,102
31
+ pycparser/ply/__pycache__/__init__.cpython-313.pyc,,
32
+ pycparser/ply/__pycache__/cpp.cpython-313.pyc,,
33
+ pycparser/ply/__pycache__/ctokens.cpython-313.pyc,,
34
+ pycparser/ply/__pycache__/lex.cpython-313.pyc,,
35
+ pycparser/ply/__pycache__/yacc.cpython-313.pyc,,
36
+ pycparser/ply/__pycache__/ygen.cpython-313.pyc,,
37
+ pycparser/ply/cpp.py,sha256=UtC3ylTWp5_1MKA-PLCuwKQR8zSOnlGuGGIdzj8xS98,33282
38
+ pycparser/ply/ctokens.py,sha256=MKksnN40TehPhgVfxCJhjj_BjL943apreABKYz-bl0Y,3177
39
+ pycparser/ply/lex.py,sha256=rCMi0yjlZmjH5SNXj_Yds1VxSDkaG2thS7351YvfN-I,42926
40
+ pycparser/ply/yacc.py,sha256=eatSDkRLgRr6X3-hoDk_SQQv065R0BdL2K7fQ54CgVM,137323
41
+ pycparser/ply/ygen.py,sha256=2JYNeYtrPz1JzLSLO3d4GsS8zJU8jY_I_CR1VI9gWrA,2251
42
+ pycparser/plyparser.py,sha256=8tLOoEytcapvWrr1JfCf7Dog-wulBtS1YrDs8S7JfMo,4875
43
+ pycparser/yacctab.py,sha256=ovX4pQW7sjbRf8c-GxpU6J65pqVGAgbU_G_YuW5NPHM,213007
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/REQUESTED ADDED
File without changes
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/direct_url.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"dir_info": {}, "url": "file:///home/task_175749564936714/conda-bld/pycparser_1757496040682/work"}
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pycparser -- A C parser in Python
2
+
3
+ Copyright (c) 2008-2022, Eli Bendersky
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without modification,
7
+ are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+ * Neither the name of the copyright holder nor the names of its contributors may
15
+ be used to endorse or promote products derived from this software without
16
+ specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
miniconda3/lib/python3.13/site-packages/pycparser-2.23.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pycparser
miniconda3/lib/python3.13/site-packages/pycparser/__init__.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-----------------------------------------------------------------
2
+ # pycparser: __init__.py
3
+ #
4
+ # This package file exports some convenience functions for
5
+ # interacting with pycparser
6
+ #
7
+ # Eli Bendersky [https://eli.thegreenplace.net/]
8
+ # License: BSD
9
+ #-----------------------------------------------------------------
10
+ __all__ = ['c_lexer', 'c_parser', 'c_ast']
11
+ __version__ = '2.23'
12
+
13
+ import io
14
+ from subprocess import check_output
15
+ from .c_parser import CParser
16
+
17
+
18
+ def preprocess_file(filename, cpp_path='cpp', cpp_args=''):
19
+ """ Preprocess a file using cpp.
20
+
21
+ filename:
22
+ Name of the file you want to preprocess.
23
+
24
+ cpp_path:
25
+ cpp_args:
26
+ Refer to the documentation of parse_file for the meaning of these
27
+ arguments.
28
+
29
+ When successful, returns the preprocessed file's contents.
30
+ Errors from cpp will be printed out.
31
+ """
32
+ path_list = [cpp_path]
33
+ if isinstance(cpp_args, list):
34
+ path_list += cpp_args
35
+ elif cpp_args != '':
36
+ path_list += [cpp_args]
37
+ path_list += [filename]
38
+
39
+ try:
40
+ # Note the use of universal_newlines to treat all newlines
41
+ # as \n for Python's purpose
42
+ text = check_output(path_list, universal_newlines=True)
43
+ except OSError as e:
44
+ raise RuntimeError("Unable to invoke 'cpp'. " +
45
+ 'Make sure its path was passed correctly\n' +
46
+ ('Original error: %s' % e))
47
+
48
+ return text
49
+
50
+
51
+ def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='',
52
+ parser=None, encoding=None):
53
+ """ Parse a C file using pycparser.
54
+
55
+ filename:
56
+ Name of the file you want to parse.
57
+
58
+ use_cpp:
59
+ Set to True if you want to execute the C pre-processor
60
+ on the file prior to parsing it.
61
+
62
+ cpp_path:
63
+ If use_cpp is True, this is the path to 'cpp' on your
64
+ system. If no path is provided, it attempts to just
65
+ execute 'cpp', so it must be in your PATH.
66
+
67
+ cpp_args:
68
+ If use_cpp is True, set this to the command line arguments strings
69
+ to cpp. Be careful with quotes - it's best to pass a raw string
70
+ (r'') here. For example:
71
+ r'-I../utils/fake_libc_include'
72
+ If several arguments are required, pass a list of strings.
73
+
74
+ encoding:
75
+ Encoding to use for the file to parse
76
+
77
+ parser:
78
+ Optional parser object to be used instead of the default CParser
79
+
80
+ When successful, an AST is returned. ParseError can be
81
+ thrown if the file doesn't parse successfully.
82
+
83
+ Errors from cpp will be printed out.
84
+ """
85
+ if use_cpp:
86
+ text = preprocess_file(filename, cpp_path, cpp_args)
87
+ else:
88
+ with io.open(filename, encoding=encoding) as f:
89
+ text = f.read()
90
+
91
+ if parser is None:
92
+ parser = CParser()
93
+ return parser.parse(text, filename)
miniconda3/lib/python3.13/site-packages/pycparser/_ast_gen.py ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-----------------------------------------------------------------
2
+ # _ast_gen.py
3
+ #
4
+ # Generates the AST Node classes from a specification given in
5
+ # a configuration file
6
+ #
7
+ # The design of this module was inspired by astgen.py from the
8
+ # Python 2.5 code-base.
9
+ #
10
+ # Eli Bendersky [https://eli.thegreenplace.net/]
11
+ # License: BSD
12
+ #-----------------------------------------------------------------
13
+ from string import Template
14
+
15
+
16
+ class ASTCodeGenerator(object):
17
+ def __init__(self, cfg_filename='_c_ast.cfg'):
18
+ """ Initialize the code generator from a configuration
19
+ file.
20
+ """
21
+ self.cfg_filename = cfg_filename
22
+ self.node_cfg = [NodeCfg(name, contents)
23
+ for (name, contents) in self.parse_cfgfile(cfg_filename)]
24
+
25
+ def generate(self, file=None):
26
+ """ Generates the code into file, an open file buffer.
27
+ """
28
+ src = Template(_PROLOGUE_COMMENT).substitute(
29
+ cfg_filename=self.cfg_filename)
30
+
31
+ src += _PROLOGUE_CODE
32
+ for node_cfg in self.node_cfg:
33
+ src += node_cfg.generate_source() + '\n\n'
34
+
35
+ file.write(src)
36
+
37
+ def parse_cfgfile(self, filename):
38
+ """ Parse the configuration file and yield pairs of
39
+ (name, contents) for each node.
40
+ """
41
+ with open(filename, "r") as f:
42
+ for line in f:
43
+ line = line.strip()
44
+ if not line or line.startswith('#'):
45
+ continue
46
+ colon_i = line.find(':')
47
+ lbracket_i = line.find('[')
48
+ rbracket_i = line.find(']')
49
+ if colon_i < 1 or lbracket_i <= colon_i or rbracket_i <= lbracket_i:
50
+ raise RuntimeError("Invalid line in %s:\n%s\n" % (filename, line))
51
+
52
+ name = line[:colon_i]
53
+ val = line[lbracket_i + 1:rbracket_i]
54
+ vallist = [v.strip() for v in val.split(',')] if val else []
55
+ yield name, vallist
56
+
57
+
58
+ class NodeCfg(object):
59
+ """ Node configuration.
60
+
61
+ name: node name
62
+ contents: a list of contents - attributes and child nodes
63
+ See comment at the top of the configuration file for details.
64
+ """
65
+
66
+ def __init__(self, name, contents):
67
+ self.name = name
68
+ self.all_entries = []
69
+ self.attr = []
70
+ self.child = []
71
+ self.seq_child = []
72
+
73
+ for entry in contents:
74
+ clean_entry = entry.rstrip('*')
75
+ self.all_entries.append(clean_entry)
76
+
77
+ if entry.endswith('**'):
78
+ self.seq_child.append(clean_entry)
79
+ elif entry.endswith('*'):
80
+ self.child.append(clean_entry)
81
+ else:
82
+ self.attr.append(entry)
83
+
84
+ def generate_source(self):
85
+ src = self._gen_init()
86
+ src += '\n' + self._gen_children()
87
+ src += '\n' + self._gen_iter()
88
+ src += '\n' + self._gen_attr_names()
89
+ return src
90
+
91
+ def _gen_init(self):
92
+ src = "class %s(Node):\n" % self.name
93
+
94
+ if self.all_entries:
95
+ args = ', '.join(self.all_entries)
96
+ slots = ', '.join("'{0}'".format(e) for e in self.all_entries)
97
+ slots += ", 'coord', '__weakref__'"
98
+ arglist = '(self, %s, coord=None)' % args
99
+ else:
100
+ slots = "'coord', '__weakref__'"
101
+ arglist = '(self, coord=None)'
102
+
103
+ src += " __slots__ = (%s)\n" % slots
104
+ src += " def __init__%s:\n" % arglist
105
+
106
+ for name in self.all_entries + ['coord']:
107
+ src += " self.%s = %s\n" % (name, name)
108
+
109
+ return src
110
+
111
+ def _gen_children(self):
112
+ src = ' def children(self):\n'
113
+
114
+ if self.all_entries:
115
+ src += ' nodelist = []\n'
116
+
117
+ for child in self.child:
118
+ src += (
119
+ ' if self.%(child)s is not None:' +
120
+ ' nodelist.append(("%(child)s", self.%(child)s))\n') % (
121
+ dict(child=child))
122
+
123
+ for seq_child in self.seq_child:
124
+ src += (
125
+ ' for i, child in enumerate(self.%(child)s or []):\n'
126
+ ' nodelist.append(("%(child)s[%%d]" %% i, child))\n') % (
127
+ dict(child=seq_child))
128
+
129
+ src += ' return tuple(nodelist)\n'
130
+ else:
131
+ src += ' return ()\n'
132
+
133
+ return src
134
+
135
+ def _gen_iter(self):
136
+ src = ' def __iter__(self):\n'
137
+
138
+ if self.all_entries:
139
+ for child in self.child:
140
+ src += (
141
+ ' if self.%(child)s is not None:\n' +
142
+ ' yield self.%(child)s\n') % (dict(child=child))
143
+
144
+ for seq_child in self.seq_child:
145
+ src += (
146
+ ' for child in (self.%(child)s or []):\n'
147
+ ' yield child\n') % (dict(child=seq_child))
148
+
149
+ if not (self.child or self.seq_child):
150
+ # Empty generator
151
+ src += (
152
+ ' return\n' +
153
+ ' yield\n')
154
+ else:
155
+ # Empty generator
156
+ src += (
157
+ ' return\n' +
158
+ ' yield\n')
159
+
160
+ return src
161
+
162
+ def _gen_attr_names(self):
163
+ src = " attr_names = (" + ''.join("%r, " % nm for nm in self.attr) + ')'
164
+ return src
165
+
166
+
167
+ _PROLOGUE_COMMENT = \
168
+ r'''#-----------------------------------------------------------------
169
+ # ** ATTENTION **
170
+ # This code was automatically generated from the file:
171
+ # $cfg_filename
172
+ #
173
+ # Do not modify it directly. Modify the configuration file and
174
+ # run the generator again.
175
+ # ** ** *** ** **
176
+ #
177
+ # pycparser: c_ast.py
178
+ #
179
+ # AST Node classes.
180
+ #
181
+ # Eli Bendersky [https://eli.thegreenplace.net/]
182
+ # License: BSD
183
+ #-----------------------------------------------------------------
184
+
185
+ '''
186
+
187
+ _PROLOGUE_CODE = r'''
188
+ import sys
189
+
190
+ def _repr(obj):
191
+ """
192
+ Get the representation of an object, with dedicated pprint-like format for lists.
193
+ """
194
+ if isinstance(obj, list):
195
+ return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
196
+ else:
197
+ return repr(obj)
198
+
199
+ class Node(object):
200
+ __slots__ = ()
201
+ """ Abstract base class for AST nodes.
202
+ """
203
+ def __repr__(self):
204
+ """ Generates a python representation of the current node
205
+ """
206
+ result = self.__class__.__name__ + '('
207
+
208
+ indent = ''
209
+ separator = ''
210
+ for name in self.__slots__[:-2]:
211
+ result += separator
212
+ result += indent
213
+ result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n ' + (' ' * (len(name) + len(self.__class__.__name__)))))
214
+
215
+ separator = ','
216
+ indent = '\n ' + (' ' * len(self.__class__.__name__))
217
+
218
+ result += indent + ')'
219
+
220
+ return result
221
+
222
+ def children(self):
223
+ """ A sequence of all children that are Nodes
224
+ """
225
+ pass
226
+
227
+ def show(self, buf=sys.stdout, offset=0, attrnames=False, nodenames=False, showcoord=False, _my_node_name=None):
228
+ """ Pretty print the Node and all its attributes and
229
+ children (recursively) to a buffer.
230
+
231
+ buf:
232
+ Open IO buffer into which the Node is printed.
233
+
234
+ offset:
235
+ Initial offset (amount of leading spaces)
236
+
237
+ attrnames:
238
+ True if you want to see the attribute names in
239
+ name=value pairs. False to only see the values.
240
+
241
+ nodenames:
242
+ True if you want to see the actual node names
243
+ within their parents.
244
+
245
+ showcoord:
246
+ Do you want the coordinates of each Node to be
247
+ displayed.
248
+ """
249
+ lead = ' ' * offset
250
+ if nodenames and _my_node_name is not None:
251
+ buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
252
+ else:
253
+ buf.write(lead + self.__class__.__name__+ ': ')
254
+
255
+ if self.attr_names:
256
+ if attrnames:
257
+ nvlist = [(n, getattr(self,n)) for n in self.attr_names]
258
+ attrstr = ', '.join('%s=%s' % nv for nv in nvlist)
259
+ else:
260
+ vlist = [getattr(self, n) for n in self.attr_names]
261
+ attrstr = ', '.join('%s' % v for v in vlist)
262
+ buf.write(attrstr)
263
+
264
+ if showcoord:
265
+ buf.write(' (at %s)' % self.coord)
266
+ buf.write('\n')
267
+
268
+ for (child_name, child) in self.children():
269
+ child.show(
270
+ buf,
271
+ offset=offset + 2,
272
+ attrnames=attrnames,
273
+ nodenames=nodenames,
274
+ showcoord=showcoord,
275
+ _my_node_name=child_name)
276
+
277
+
278
+ class NodeVisitor(object):
279
+ """ A base NodeVisitor class for visiting c_ast nodes.
280
+ Subclass it and define your own visit_XXX methods, where
281
+ XXX is the class name you want to visit with these
282
+ methods.
283
+
284
+ For example:
285
+
286
+ class ConstantVisitor(NodeVisitor):
287
+ def __init__(self):
288
+ self.values = []
289
+
290
+ def visit_Constant(self, node):
291
+ self.values.append(node.value)
292
+
293
+ Creates a list of values of all the constant nodes
294
+ encountered below the given node. To use it:
295
+
296
+ cv = ConstantVisitor()
297
+ cv.visit(node)
298
+
299
+ Notes:
300
+
301
+ * generic_visit() will be called for AST nodes for which
302
+ no visit_XXX method was defined.
303
+ * The children of nodes for which a visit_XXX was
304
+ defined will not be visited - if you need this, call
305
+ generic_visit() on the node.
306
+ You can use:
307
+ NodeVisitor.generic_visit(self, node)
308
+ * Modeled after Python's own AST visiting facilities
309
+ (the ast module of Python 3.0)
310
+ """
311
+
312
+ _method_cache = None
313
+
314
+ def visit(self, node):
315
+ """ Visit a node.
316
+ """
317
+
318
+ if self._method_cache is None:
319
+ self._method_cache = {}
320
+
321
+ visitor = self._method_cache.get(node.__class__.__name__, None)
322
+ if visitor is None:
323
+ method = 'visit_' + node.__class__.__name__
324
+ visitor = getattr(self, method, self.generic_visit)
325
+ self._method_cache[node.__class__.__name__] = visitor
326
+
327
+ return visitor(node)
328
+
329
+ def generic_visit(self, node):
330
+ """ Called if no explicit visitor function exists for a
331
+ node. Implements preorder visiting of the node.
332
+ """
333
+ for c in node:
334
+ self.visit(c)
335
+
336
+ '''
miniconda3/lib/python3.13/site-packages/pycparser/_build_tables.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-----------------------------------------------------------------
2
+ # pycparser: _build_tables.py
3
+ #
4
+ # A dummy for generating the lexing/parsing tables and and
5
+ # compiling them into .pyc for faster execution in optimized mode.
6
+ # Also generates AST code from the configuration file.
7
+ # Should be called from the pycparser directory.
8
+ #
9
+ # Eli Bendersky [https://eli.thegreenplace.net/]
10
+ # License: BSD
11
+ #-----------------------------------------------------------------
12
+
13
+ # Insert '.' and '..' as first entries to the search path for modules.
14
+ # Restricted environments like embeddable python do not include the
15
+ # current working directory on startup.
16
+ import importlib
17
+ import sys
18
+ sys.path[0:0] = ['.', '..']
19
+
20
+ # Generate c_ast.py
21
+ from _ast_gen import ASTCodeGenerator
22
+ ast_gen = ASTCodeGenerator('_c_ast.cfg')
23
+ ast_gen.generate(open('c_ast.py', 'w'))
24
+
25
+ from pycparser import c_parser
26
+
27
+ # Generates the tables
28
+ #
29
+ c_parser.CParser(
30
+ lex_optimize=True,
31
+ yacc_debug=False,
32
+ yacc_optimize=True)
33
+
34
+ # Load to compile into .pyc
35
+ #
36
+ importlib.invalidate_caches()
37
+
38
+ import lextab
39
+ import yacctab
40
+ import c_ast