codekingpro commited on
Commit
ae95ec9
·
verified ·
1 Parent(s): 1ec957c

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. python/user_packages/Python313/site-packages/importlib_resources-7.1.0.dist-info/licenses/LICENSE +73 -0
  2. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_adapters.cpython-313.pyc +0 -0
  3. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_common.cpython-313.pyc +0 -0
  4. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_functional.cpython-313.pyc +0 -0
  5. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_itertools.cpython-313.pyc +0 -0
  6. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/abc.cpython-313.pyc +0 -0
  7. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/readers.cpython-313.pyc +0 -0
  8. python/user_packages/Python313/site-packages/importlib_resources/__pycache__/simple.cpython-313.pyc +0 -0
  9. python/user_packages/Python313/site-packages/importlib_resources/compat/__init__.py +0 -0
  10. python/user_packages/Python313/site-packages/importlib_resources/compat/py39.py +9 -0
  11. python/user_packages/Python313/site-packages/importlib_resources/future/__init__.py +0 -0
  12. python/user_packages/Python313/site-packages/importlib_resources/future/adapters.py +102 -0
  13. python/user_packages/Python313/site-packages/importlib_resources/tests/__init__.py +0 -0
  14. python/user_packages/Python313/site-packages/importlib_resources/tests/_path.py +90 -0
  15. python/user_packages/Python313/site-packages/importlib_resources/tests/test_compatibilty_files.py +98 -0
  16. python/user_packages/Python313/site-packages/importlib_resources/tests/test_contents.py +39 -0
  17. python/user_packages/Python313/site-packages/importlib_resources/tests/test_custom.py +48 -0
  18. python/user_packages/Python313/site-packages/importlib_resources/tests/test_files.py +186 -0
  19. python/user_packages/Python313/site-packages/importlib_resources/tests/test_functional.py +261 -0
  20. python/user_packages/Python313/site-packages/importlib_resources/tests/test_open.py +84 -0
  21. python/user_packages/Python313/site-packages/importlib_resources/tests/test_path.py +63 -0
  22. python/user_packages/Python313/site-packages/importlib_resources/tests/test_read.py +96 -0
  23. python/user_packages/Python313/site-packages/importlib_resources/tests/test_reader.py +125 -0
  24. python/user_packages/Python313/site-packages/importlib_resources/tests/test_resource.py +243 -0
  25. python/user_packages/Python313/site-packages/importlib_resources/tests/test_util.py +29 -0
  26. python/user_packages/Python313/site-packages/importlib_resources/tests/util.py +308 -0
  27. python/user_packages/Python313/site-packages/importlib_resources/tests/zip.py +26 -0
  28. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/__init__.cpython-313.pyc +0 -0
  29. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/_json.cpython-313.pyc +0 -0
  30. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/encoding.cpython-313.pyc +0 -0
  31. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/exc.cpython-313.pyc +0 -0
  32. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/serializer.cpython-313.pyc +0 -0
  33. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/signer.cpython-313.pyc +0 -0
  34. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/timed.cpython-313.pyc +0 -0
  35. python/user_packages/Python313/site-packages/itsdangerous/__pycache__/url_safe.cpython-313.pyc +0 -0
  36. python/user_packages/Python313/site-packages/jinja2-3.1.6.dist-info/licenses/LICENSE.txt +28 -0
  37. python/user_packages/Python313/site-packages/jinja2/__pycache__/__init__.cpython-313.pyc +0 -0
  38. python/user_packages/Python313/site-packages/jinja2/__pycache__/_identifier.cpython-313.pyc +0 -0
  39. python/user_packages/Python313/site-packages/jinja2/__pycache__/async_utils.cpython-313.pyc +0 -0
  40. python/user_packages/Python313/site-packages/jinja2/__pycache__/bccache.cpython-313.pyc +0 -0
  41. python/user_packages/Python313/site-packages/jinja2/__pycache__/constants.cpython-313.pyc +0 -0
  42. python/user_packages/Python313/site-packages/jinja2/__pycache__/debug.cpython-313.pyc +0 -0
  43. python/user_packages/Python313/site-packages/jinja2/__pycache__/defaults.cpython-313.pyc +0 -0
  44. python/user_packages/Python313/site-packages/jinja2/__pycache__/environment.cpython-313.pyc +0 -0
  45. python/user_packages/Python313/site-packages/jinja2/__pycache__/exceptions.cpython-313.pyc +0 -0
  46. python/user_packages/Python313/site-packages/jinja2/__pycache__/ext.cpython-313.pyc +0 -0
  47. python/user_packages/Python313/site-packages/jinja2/__pycache__/filters.cpython-313.pyc +0 -0
  48. python/user_packages/Python313/site-packages/jinja2/__pycache__/idtracking.cpython-313.pyc +0 -0
  49. python/user_packages/Python313/site-packages/jinja2/__pycache__/lexer.cpython-313.pyc +0 -0
  50. python/user_packages/Python313/site-packages/jinja2/__pycache__/loaders.cpython-313.pyc +0 -0
python/user_packages/Python313/site-packages/importlib_resources-7.1.0.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright 2026 [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_adapters.cpython-313.pyc ADDED
Binary file (9.85 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_common.cpython-313.pyc ADDED
Binary file (8.33 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_functional.cpython-313.pyc ADDED
Binary file (3.6 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/_itertools.cpython-313.pyc ADDED
Binary file (1.51 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/abc.cpython-313.pyc ADDED
Binary file (9.31 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/readers.cpython-313.pyc ADDED
Binary file (12.2 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/__pycache__/simple.cpython-313.pyc ADDED
Binary file (5.55 kB). View file
 
python/user_packages/Python313/site-packages/importlib_resources/compat/__init__.py ADDED
File without changes
python/user_packages/Python313/site-packages/importlib_resources/compat/py39.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ __all__ = ['ZipPath']
4
+
5
+
6
+ if sys.version_info >= (3, 10):
7
+ from zipfile import Path as ZipPath
8
+ else:
9
+ from zipp import Path as ZipPath
python/user_packages/Python313/site-packages/importlib_resources/future/__init__.py ADDED
File without changes
python/user_packages/Python313/site-packages/importlib_resources/future/adapters.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import functools
2
+ import pathlib
3
+ from contextlib import suppress
4
+ from types import SimpleNamespace
5
+
6
+ from .. import _adapters, readers
7
+
8
+
9
+ def _block_standard(reader_getter):
10
+ """
11
+ Wrap _adapters.TraversableResourcesLoader.get_resource_reader
12
+ and intercept any standard library readers.
13
+ """
14
+
15
+ @functools.wraps(reader_getter)
16
+ def wrapper(*args, **kwargs):
17
+ """
18
+ If the reader is from the standard library, return None to allow
19
+ allow likely newer implementations in this library to take precedence.
20
+ """
21
+ try:
22
+ reader = reader_getter(*args, **kwargs)
23
+ except NotADirectoryError:
24
+ # MultiplexedPath may fail on zip subdirectory
25
+ return
26
+ except ValueError as exc:
27
+ # NamespaceReader in stdlib may fail for editable installs
28
+ # (python/importlib_resources#311, python/importlib_resources#318)
29
+ # Remove after bugfix applied to Python 3.13.
30
+ if "not enough values to unpack" not in str(exc):
31
+ raise
32
+ return
33
+ # Python 3.10+
34
+ mod_name = reader.__class__.__module__
35
+ if mod_name.startswith('importlib.') and mod_name.endswith('readers'):
36
+ return
37
+ # Python 3.8, 3.9
38
+ if isinstance(reader, _adapters.CompatibilityFiles) and (
39
+ reader.spec.loader.__class__.__module__.startswith('zipimport')
40
+ or reader.spec.loader.__class__.__module__.startswith(
41
+ '_frozen_importlib_external'
42
+ )
43
+ ):
44
+ return
45
+ return reader
46
+
47
+ return wrapper
48
+
49
+
50
+ def _skip_degenerate(reader):
51
+ """
52
+ Mask any degenerate reader. Ref #298.
53
+ """
54
+ is_degenerate = (
55
+ isinstance(reader, _adapters.CompatibilityFiles) and not reader._reader
56
+ )
57
+ return reader if not is_degenerate else None
58
+
59
+
60
+ class TraversableResourcesLoader(_adapters.TraversableResourcesLoader):
61
+ """
62
+ Adapt loaders to provide TraversableResources and other
63
+ compatibility.
64
+
65
+ Ensures the readers from importlib_resources are preferred
66
+ over stdlib readers.
67
+ """
68
+
69
+ def get_resource_reader(self, name):
70
+ return (
71
+ _skip_degenerate(_block_standard(super().get_resource_reader)(name))
72
+ or self._standard_reader()
73
+ or super().get_resource_reader(name)
74
+ )
75
+
76
+ def _standard_reader(self):
77
+ return self._zip_reader() or self._namespace_reader() or self._file_reader()
78
+
79
+ def _zip_reader(self):
80
+ with suppress(AttributeError):
81
+ return readers.ZipReader(self.spec.loader, self.spec.name)
82
+
83
+ def _namespace_reader(self):
84
+ with suppress(AttributeError, ValueError):
85
+ return readers.NamespaceReader(self.spec.submodule_search_locations)
86
+
87
+ def _file_reader(self):
88
+ try:
89
+ path = pathlib.Path(self.spec.origin)
90
+ except TypeError:
91
+ return None
92
+ if path.exists():
93
+ return readers.FileReader(SimpleNamespace(path=path))
94
+
95
+
96
+ def wrap_spec(package):
97
+ """
98
+ Override _adapters.wrap_spec to use TraversableResourcesLoader
99
+ from above. Ensures that future behavior is always available on older
100
+ Pythons.
101
+ """
102
+ return _adapters.SpecLoaderAdapter(package.__spec__, TraversableResourcesLoader)
python/user_packages/Python313/site-packages/importlib_resources/tests/__init__.py ADDED
File without changes
python/user_packages/Python313/site-packages/importlib_resources/tests/_path.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import functools
2
+ import pathlib
3
+ from typing import Protocol, Union, runtime_checkable
4
+
5
+ ####
6
+ # from jaraco.path 3.7.1
7
+
8
+
9
+ class Symlink(str):
10
+ """
11
+ A string indicating the target of a symlink.
12
+ """
13
+
14
+
15
+ FilesSpec = dict[str, Union[str, bytes, Symlink, 'FilesSpec']]
16
+
17
+
18
+ @runtime_checkable
19
+ class TreeMaker(Protocol):
20
+ def __truediv__(self, *args, **kwargs): ... # pragma: no cover
21
+
22
+ def mkdir(self, **kwargs): ... # pragma: no cover
23
+
24
+ def write_text(self, content, **kwargs): ... # pragma: no cover
25
+
26
+ def write_bytes(self, content): ... # pragma: no cover
27
+
28
+ def symlink_to(self, target): ... # pragma: no cover
29
+
30
+
31
+ def _ensure_tree_maker(obj: str | TreeMaker) -> TreeMaker:
32
+ return obj if isinstance(obj, TreeMaker) else pathlib.Path(obj) # type: ignore[return-value]
33
+
34
+
35
+ def build(
36
+ spec: FilesSpec,
37
+ prefix: str | TreeMaker = pathlib.Path(), # type: ignore[assignment]
38
+ ):
39
+ """
40
+ Build a set of files/directories, as described by the spec.
41
+
42
+ Each key represents a pathname, and the value represents
43
+ the content. Content may be a nested directory.
44
+
45
+ >>> spec = {
46
+ ... 'README.txt': "A README file",
47
+ ... "foo": {
48
+ ... "__init__.py": "",
49
+ ... "bar": {
50
+ ... "__init__.py": "",
51
+ ... },
52
+ ... "baz.py": "# Some code",
53
+ ... "bar.py": Symlink("baz.py"),
54
+ ... },
55
+ ... "bing": Symlink("foo"),
56
+ ... }
57
+ >>> target = getfixture('tmp_path')
58
+ >>> build(spec, target)
59
+ >>> target.joinpath('foo/baz.py').read_text(encoding='utf-8')
60
+ '# Some code'
61
+ >>> target.joinpath('bing/bar.py').read_text(encoding='utf-8')
62
+ '# Some code'
63
+ """
64
+ for name, contents in spec.items():
65
+ create(contents, _ensure_tree_maker(prefix) / name)
66
+
67
+
68
+ @functools.singledispatch
69
+ def create(content: str | bytes | FilesSpec, path):
70
+ path.mkdir(exist_ok=True)
71
+ build(content, prefix=path) # type: ignore[arg-type]
72
+
73
+
74
+ @create.register
75
+ def _(content: bytes, path):
76
+ path.write_bytes(content)
77
+
78
+
79
+ @create.register
80
+ def _(content: str, path):
81
+ path.write_text(content, encoding='utf-8')
82
+
83
+
84
+ @create.register
85
+ def _(content: Symlink, path):
86
+ path.symlink_to(content)
87
+
88
+
89
+ # end from jaraco.path
90
+ ####
python/user_packages/Python313/site-packages/importlib_resources/tests/test_compatibilty_files.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ import unittest
3
+
4
+ import importlib_resources as resources
5
+ from importlib_resources._adapters import (
6
+ CompatibilityFiles,
7
+ wrap_spec,
8
+ )
9
+
10
+ from . import util
11
+
12
+
13
+ class CompatibilityFilesTests(unittest.TestCase):
14
+ @property
15
+ def package(self):
16
+ bytes_data = io.BytesIO(b'Hello, world!')
17
+ return util.create_package(
18
+ file=bytes_data,
19
+ path='some_path',
20
+ contents=('a', 'b', 'c'),
21
+ )
22
+
23
+ @property
24
+ def files(self):
25
+ return resources.files(self.package)
26
+
27
+ def test_spec_path_iter(self):
28
+ assert sorted(path.name for path in self.files.iterdir()) == ['a', 'b', 'c']
29
+
30
+ def test_child_path_iter(self):
31
+ assert list((self.files / 'a').iterdir()) == []
32
+
33
+ def test_orphan_path_iter(self):
34
+ assert list((self.files / 'a' / 'a').iterdir()) == []
35
+ assert list((self.files / 'a' / 'a' / 'a').iterdir()) == []
36
+
37
+ def test_spec_path_is(self):
38
+ assert not self.files.is_file()
39
+ assert not self.files.is_dir()
40
+
41
+ def test_child_path_is(self):
42
+ assert (self.files / 'a').is_file()
43
+ assert not (self.files / 'a').is_dir()
44
+
45
+ def test_orphan_path_is(self):
46
+ assert not (self.files / 'a' / 'a').is_file()
47
+ assert not (self.files / 'a' / 'a').is_dir()
48
+ assert not (self.files / 'a' / 'a' / 'a').is_file()
49
+ assert not (self.files / 'a' / 'a' / 'a').is_dir()
50
+
51
+ def test_spec_path_name(self):
52
+ assert self.files.name == 'testingpackage'
53
+
54
+ def test_child_path_name(self):
55
+ assert (self.files / 'a').name == 'a'
56
+
57
+ def test_orphan_path_name(self):
58
+ assert (self.files / 'a' / 'b').name == 'b'
59
+ assert (self.files / 'a' / 'b' / 'c').name == 'c'
60
+
61
+ def test_spec_path_open(self):
62
+ assert self.files.read_bytes() == b'Hello, world!'
63
+ assert self.files.read_text(encoding='utf-8') == 'Hello, world!'
64
+
65
+ def test_child_path_open(self):
66
+ assert (self.files / 'a').read_bytes() == b'Hello, world!'
67
+ assert (self.files / 'a').read_text(encoding='utf-8') == 'Hello, world!'
68
+
69
+ def test_orphan_path_open(self):
70
+ with self.assertRaises(FileNotFoundError):
71
+ (self.files / 'a' / 'b').read_bytes()
72
+ with self.assertRaises(FileNotFoundError):
73
+ (self.files / 'a' / 'b' / 'c').read_bytes()
74
+
75
+ def test_open_invalid_mode(self):
76
+ with self.assertRaises(ValueError):
77
+ self.files.open('0')
78
+
79
+ def test_orphan_path_invalid(self):
80
+ with self.assertRaises(ValueError):
81
+ CompatibilityFiles.OrphanPath()
82
+
83
+ def test_wrap_spec(self):
84
+ spec = wrap_spec(self.package)
85
+ assert isinstance(spec.loader.get_resource_reader(None), CompatibilityFiles)
86
+
87
+
88
+ class CompatibilityFilesNoReaderTests(unittest.TestCase):
89
+ @property
90
+ def package(self):
91
+ return util.create_package_from_loader(None)
92
+
93
+ @property
94
+ def files(self):
95
+ return resources.files(self.package)
96
+
97
+ def test_spec_path_joinpath(self):
98
+ assert isinstance(self.files / 'a', CompatibilityFiles.OrphanPath)
python/user_packages/Python313/site-packages/importlib_resources/tests/test_contents.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+
3
+ import importlib_resources as resources
4
+
5
+ from . import util
6
+
7
+
8
+ class ContentsTests:
9
+ expected = {
10
+ '__init__.py',
11
+ 'binary.file',
12
+ 'subdirectory',
13
+ 'utf-16.file',
14
+ 'utf-8.file',
15
+ }
16
+
17
+ def test_contents(self):
18
+ contents = {path.name for path in resources.files(self.data).iterdir()}
19
+ assert self.expected <= contents
20
+
21
+
22
+ class ContentsDiskTests(ContentsTests, util.DiskSetup, unittest.TestCase):
23
+ pass
24
+
25
+
26
+ class ContentsZipTests(ContentsTests, util.ZipSetup, unittest.TestCase):
27
+ pass
28
+
29
+
30
+ class ContentsNamespaceTests(ContentsTests, util.DiskSetup, unittest.TestCase):
31
+ MODULE = 'namespacedata01'
32
+
33
+ expected = {
34
+ # no __init__ because of namespace design
35
+ 'binary.file',
36
+ 'subdirectory',
37
+ 'utf-16.file',
38
+ 'utf-8.file',
39
+ }
python/user_packages/Python313/site-packages/importlib_resources/tests/test_custom.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import contextlib
2
+ import pathlib
3
+ import unittest
4
+
5
+ import importlib_resources as resources
6
+
7
+ from .. import abc
8
+ from ..abc import ResourceReader, TraversableResources
9
+ from . import util
10
+ from .compat.py39 import os_helper
11
+
12
+
13
+ class SimpleLoader:
14
+ """
15
+ A simple loader that only implements a resource reader.
16
+ """
17
+
18
+ def __init__(self, reader: ResourceReader):
19
+ self.reader = reader
20
+
21
+ def get_resource_reader(self, package):
22
+ return self.reader
23
+
24
+
25
+ class MagicResources(TraversableResources):
26
+ """
27
+ Magically returns the resources at path.
28
+ """
29
+
30
+ def __init__(self, path: pathlib.Path):
31
+ self.path = path
32
+
33
+ def files(self):
34
+ return self.path
35
+
36
+
37
+ class CustomTraversableResourcesTests(unittest.TestCase):
38
+ def setUp(self):
39
+ self.fixtures = contextlib.ExitStack()
40
+ self.addCleanup(self.fixtures.close)
41
+
42
+ def test_custom_loader(self):
43
+ temp_dir = pathlib.Path(self.fixtures.enter_context(os_helper.temp_dir()))
44
+ loader = SimpleLoader(MagicResources(temp_dir))
45
+ pkg = util.create_package_from_loader(loader)
46
+ files = resources.files(pkg)
47
+ assert isinstance(files, abc.Traversable)
48
+ assert list(files.iterdir()) == []
python/user_packages/Python313/site-packages/importlib_resources/tests/test_files.py ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import contextlib
2
+ import importlib
3
+ import pathlib
4
+ import py_compile
5
+ import textwrap
6
+ import unittest
7
+ import warnings
8
+
9
+ import importlib_resources as resources
10
+
11
+ from ..abc import Traversable
12
+ from . import util
13
+ from .compat.py39 import import_helper, os_helper
14
+
15
+
16
+ @contextlib.contextmanager
17
+ def suppress_known_deprecation():
18
+ with warnings.catch_warnings(record=True) as ctx:
19
+ warnings.simplefilter('default', category=DeprecationWarning)
20
+ yield ctx
21
+
22
+
23
+ class FilesTests:
24
+ def test_read_bytes(self):
25
+ files = resources.files(self.data)
26
+ actual = files.joinpath('utf-8.file').read_bytes()
27
+ assert actual == b'Hello, UTF-8 world!\n'
28
+
29
+ def test_read_text(self):
30
+ files = resources.files(self.data)
31
+ actual = files.joinpath('utf-8.file').read_text(encoding='utf-8')
32
+ assert actual == 'Hello, UTF-8 world!\n'
33
+
34
+ def test_traversable(self):
35
+ assert isinstance(resources.files(self.data), Traversable)
36
+
37
+ def test_joinpath_with_multiple_args(self):
38
+ files = resources.files(self.data)
39
+ binfile = files.joinpath('subdirectory', 'binary.file')
40
+ assert binfile.is_file()
41
+
42
+
43
+ class OpenDiskTests(FilesTests, util.DiskSetup, unittest.TestCase):
44
+ pass
45
+
46
+
47
+ class OpenZipTests(FilesTests, util.ZipSetup, unittest.TestCase):
48
+ pass
49
+
50
+
51
+ class OpenNamespaceTests(FilesTests, util.DiskSetup, unittest.TestCase):
52
+ MODULE = 'namespacedata01'
53
+
54
+ def test_non_paths_in_dunder_path(self):
55
+ """
56
+ Non-path items in a namespace package's ``__path__`` are ignored.
57
+
58
+ As reported in python/importlib_resources#311, some tools
59
+ like Setuptools, when creating editable packages, will inject
60
+ non-paths into a namespace package's ``__path__``, a
61
+ sentinel like
62
+ ``__editable__.sample_namespace-1.0.finder.__path_hook__``
63
+ to cause the ``PathEntryFinder`` to be called when searching
64
+ for packages. In that case, resources should still be loadable.
65
+ """
66
+ import namespacedata01 # type: ignore[import-not-found]
67
+
68
+ namespacedata01.__path__.append(
69
+ '__editable__.sample_namespace-1.0.finder.__path_hook__'
70
+ )
71
+
72
+ resources.files(namespacedata01)
73
+
74
+
75
+ class OpenNamespaceZipTests(FilesTests, util.ZipSetup, unittest.TestCase):
76
+ ZIP_MODULE = 'namespacedata01'
77
+
78
+
79
+ class DirectSpec:
80
+ """
81
+ Override behavior of ModuleSetup to write a full spec directly.
82
+ """
83
+
84
+ MODULE = 'unused'
85
+
86
+ def load_fixture(self, name):
87
+ self.tree_on_path(self.spec)
88
+
89
+
90
+ class ModulesFiles:
91
+ spec = {
92
+ 'mod.py': '',
93
+ 'res.txt': 'resources are the best',
94
+ }
95
+
96
+ def test_module_resources(self):
97
+ """
98
+ A module can have resources found adjacent to the module.
99
+ """
100
+ import mod # type: ignore[import-not-found]
101
+
102
+ actual = resources.files(mod).joinpath('res.txt').read_text(encoding='utf-8')
103
+ assert actual == self.spec['res.txt']
104
+
105
+
106
+ class ModuleFilesDiskTests(DirectSpec, util.DiskSetup, ModulesFiles, unittest.TestCase):
107
+ pass
108
+
109
+
110
+ class ModuleFilesZipTests(DirectSpec, util.ZipSetup, ModulesFiles, unittest.TestCase):
111
+ pass
112
+
113
+
114
+ class ImplicitContextFiles:
115
+ set_val = textwrap.dedent(
116
+ f"""
117
+ import {resources.__name__} as res
118
+ val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
119
+ """
120
+ )
121
+ spec = {
122
+ 'somepkg': {
123
+ '__init__.py': set_val,
124
+ 'submod.py': set_val,
125
+ 'res.txt': 'resources are the best',
126
+ },
127
+ 'frozenpkg': {
128
+ '__init__.py': set_val.replace(resources.__name__, 'c_resources'),
129
+ 'res.txt': 'resources are the best',
130
+ },
131
+ }
132
+
133
+ def test_implicit_files_package(self):
134
+ """
135
+ Without any parameter, files() will infer the location as the caller.
136
+ """
137
+ assert importlib.import_module('somepkg').val == 'resources are the best'
138
+
139
+ def test_implicit_files_submodule(self):
140
+ """
141
+ Without any parameter, files() will infer the location as the caller.
142
+ """
143
+ assert importlib.import_module('somepkg.submod').val == 'resources are the best'
144
+
145
+ def _compile_importlib(self):
146
+ """
147
+ Make a compiled-only copy of the importlib resources package.
148
+
149
+ Currently only code is copied, as importlib resources doesn't itself
150
+ have any resources.
151
+ """
152
+ bin_site = self.fixtures.enter_context(os_helper.temp_dir())
153
+ c_resources = pathlib.Path(bin_site, 'c_resources')
154
+ sources = pathlib.Path(resources.__file__).parent
155
+
156
+ for source_path in sources.glob('**/*.py'):
157
+ c_path = c_resources.joinpath(source_path.relative_to(sources)).with_suffix(
158
+ '.pyc'
159
+ )
160
+ py_compile.compile(source_path, c_path)
161
+ self.fixtures.enter_context(import_helper.DirsOnSysPath(bin_site))
162
+
163
+ def test_implicit_files_with_compiled_importlib(self):
164
+ """
165
+ Caller detection works for compiled-only resources module.
166
+
167
+ python/cpython#123085
168
+ """
169
+ self._compile_importlib()
170
+ assert importlib.import_module('frozenpkg').val == 'resources are the best'
171
+
172
+
173
+ class ImplicitContextFilesDiskTests(
174
+ DirectSpec, util.DiskSetup, ImplicitContextFiles, unittest.TestCase
175
+ ):
176
+ pass
177
+
178
+
179
+ class ImplicitContextFilesZipTests(
180
+ DirectSpec, util.ZipSetup, ImplicitContextFiles, unittest.TestCase
181
+ ):
182
+ pass
183
+
184
+
185
+ if __name__ == '__main__':
186
+ unittest.main()
python/user_packages/Python313/site-packages/importlib_resources/tests/test_functional.py ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import importlib
2
+ import os
3
+ import unittest
4
+
5
+ import importlib_resources as resources
6
+
7
+ from . import util
8
+ from .compat.py39 import warnings_helper
9
+
10
+
11
+ class StringAnchorMixin:
12
+ anchor01 = 'data01'
13
+ anchor02 = 'data02'
14
+
15
+
16
+ class ModuleAnchorMixin:
17
+ @property
18
+ def anchor01(self):
19
+ return importlib.import_module('data01')
20
+
21
+ @property
22
+ def anchor02(self):
23
+ return importlib.import_module('data02')
24
+
25
+
26
+ class FunctionalAPIBase:
27
+ def setUp(self):
28
+ super().setUp()
29
+ self.load_fixture('data02')
30
+
31
+ def _gen_resourcetxt_path_parts(self):
32
+ """Yield various names of a text file in anchor02, each in a subTest"""
33
+ for path_parts in (
34
+ ('subdirectory', 'subsubdir', 'resource.txt'),
35
+ ('subdirectory/subsubdir/resource.txt',),
36
+ ('subdirectory/subsubdir', 'resource.txt'),
37
+ ):
38
+ with self.subTest(path_parts=path_parts):
39
+ yield path_parts
40
+
41
+ @staticmethod
42
+ def remove_utf16_bom(string):
43
+ """Remove an architecture-specific UTF-16 BOM prefix when present.
44
+
45
+ Some platforms surface UTF-16 BOM bytes as escaped text when the
46
+ fixture is intentionally decoded as UTF-8 with ``errors='backslashreplace'``.
47
+ Strip that prefix so assertions validate content consistently."""
48
+ for bom in ('\\xff\\xfe', '\\xfe\\xff', '\ufeff'):
49
+ if string.startswith(bom):
50
+ return string[len(bom) :]
51
+ return string
52
+
53
+ def test_read_text(self):
54
+ assert (
55
+ resources.read_text(self.anchor01, 'utf-8.file') == 'Hello, UTF-8 world!\n'
56
+ )
57
+ assert (
58
+ resources.read_text(
59
+ self.anchor02,
60
+ 'subdirectory',
61
+ 'subsubdir',
62
+ 'resource.txt',
63
+ encoding='utf-8',
64
+ )
65
+ == 'a resource'
66
+ )
67
+ for path_parts in self._gen_resourcetxt_path_parts():
68
+ assert (
69
+ resources.read_text(
70
+ self.anchor02,
71
+ *path_parts,
72
+ encoding='utf-8',
73
+ )
74
+ == 'a resource'
75
+ )
76
+ # Use generic OSError, since e.g. attempting to read a directory can
77
+ # fail with PermissionError rather than IsADirectoryError
78
+ with self.assertRaises(OSError):
79
+ resources.read_text(self.anchor01)
80
+ with self.assertRaises((OSError, resources.abc.TraversalError)):
81
+ resources.read_text(self.anchor01, 'no-such-file')
82
+ with self.assertRaises(UnicodeDecodeError):
83
+ resources.read_text(self.anchor01, 'utf-16.file')
84
+ assert (
85
+ resources.read_text(
86
+ self.anchor01,
87
+ 'binary.file',
88
+ encoding='latin1',
89
+ )
90
+ == '\x00\x01\x02\x03'
91
+ )
92
+ assert self.remove_utf16_bom(
93
+ resources.read_text(
94
+ self.anchor01,
95
+ 'utf-16.file',
96
+ errors='backslashreplace',
97
+ ),
98
+ ) == 'Hello, UTF-16 world!\n'.encode('utf-16-le').decode(
99
+ errors='backslashreplace',
100
+ )
101
+
102
+ def test_read_binary(self):
103
+ assert (
104
+ resources.read_binary(self.anchor01, 'utf-8.file')
105
+ == b'Hello, UTF-8 world!\n'
106
+ )
107
+ for path_parts in self._gen_resourcetxt_path_parts():
108
+ assert resources.read_binary(self.anchor02, *path_parts) == b'a resource'
109
+
110
+ def test_open_text(self):
111
+ with resources.open_text(self.anchor01, 'utf-8.file') as f:
112
+ assert f.read() == 'Hello, UTF-8 world!\n'
113
+ for path_parts in self._gen_resourcetxt_path_parts():
114
+ with resources.open_text(
115
+ self.anchor02,
116
+ *path_parts,
117
+ encoding='utf-8',
118
+ ) as f:
119
+ assert f.read() == 'a resource'
120
+ # Use generic OSError, since e.g. attempting to read a directory can
121
+ # fail with PermissionError rather than IsADirectoryError
122
+ with self.assertRaises(OSError):
123
+ resources.open_text(self.anchor01)
124
+ with self.assertRaises((OSError, resources.abc.TraversalError)):
125
+ resources.open_text(self.anchor01, 'no-such-file')
126
+ with resources.open_text(self.anchor01, 'utf-16.file') as f:
127
+ with self.assertRaises(UnicodeDecodeError):
128
+ f.read()
129
+ with resources.open_text(
130
+ self.anchor01,
131
+ 'binary.file',
132
+ encoding='latin1',
133
+ ) as f:
134
+ assert f.read() == '\x00\x01\x02\x03'
135
+ with resources.open_text(
136
+ self.anchor01,
137
+ 'utf-16.file',
138
+ errors='backslashreplace',
139
+ ) as f:
140
+ assert self.remove_utf16_bom(f.read()) == 'Hello, UTF-16 world!\n'.encode(
141
+ 'utf-16-le'
142
+ ).decode(
143
+ errors='backslashreplace',
144
+ )
145
+
146
+ def test_open_binary(self):
147
+ with resources.open_binary(self.anchor01, 'utf-8.file') as f:
148
+ assert f.read() == b'Hello, UTF-8 world!\n'
149
+ for path_parts in self._gen_resourcetxt_path_parts():
150
+ with resources.open_binary(
151
+ self.anchor02,
152
+ *path_parts,
153
+ ) as f:
154
+ assert f.read() == b'a resource'
155
+
156
+ def test_path(self):
157
+ with resources.path(self.anchor01, 'utf-8.file') as path:
158
+ with open(str(path), encoding='utf-8') as f:
159
+ assert f.read() == 'Hello, UTF-8 world!\n'
160
+ with resources.path(self.anchor01) as path:
161
+ with open(os.path.join(path, 'utf-8.file'), encoding='utf-8') as f:
162
+ assert f.read() == 'Hello, UTF-8 world!\n'
163
+
164
+ def test_is_resource(self):
165
+ is_resource = resources.is_resource
166
+ assert is_resource(self.anchor01, 'utf-8.file')
167
+ assert not is_resource(self.anchor01, 'no_such_file')
168
+ assert not is_resource(self.anchor01)
169
+ assert not is_resource(self.anchor01, 'subdirectory')
170
+ for path_parts in self._gen_resourcetxt_path_parts():
171
+ assert is_resource(self.anchor02, *path_parts)
172
+
173
+ def test_contents(self):
174
+ with warnings_helper.check_warnings((".*contents.*", DeprecationWarning)):
175
+ c = resources.contents(self.anchor01)
176
+ assert set(c) >= {'utf-8.file', 'utf-16.file', 'binary.file', 'subdirectory'}
177
+ with (
178
+ self.assertRaises(OSError),
179
+ warnings_helper.check_warnings((
180
+ ".*contents.*",
181
+ DeprecationWarning,
182
+ )),
183
+ ):
184
+ list(resources.contents(self.anchor01, 'utf-8.file'))
185
+
186
+ for path_parts in self._gen_resourcetxt_path_parts():
187
+ with (
188
+ self.assertRaises((OSError, resources.abc.TraversalError)),
189
+ warnings_helper.check_warnings((
190
+ ".*contents.*",
191
+ DeprecationWarning,
192
+ )),
193
+ ):
194
+ list(resources.contents(self.anchor01, *path_parts))
195
+ with warnings_helper.check_warnings((".*contents.*", DeprecationWarning)):
196
+ c = resources.contents(self.anchor01, 'subdirectory')
197
+ assert set(c) >= {'binary.file'}
198
+
199
+ @warnings_helper.ignore_warnings(category=DeprecationWarning)
200
+ def test_common_errors(self):
201
+ for func in (
202
+ resources.read_text,
203
+ resources.read_binary,
204
+ resources.open_text,
205
+ resources.open_binary,
206
+ resources.path,
207
+ resources.is_resource,
208
+ resources.contents,
209
+ ):
210
+ with self.subTest(func=func):
211
+ # Rejecting None anchor
212
+ with self.assertRaises(TypeError):
213
+ func(None)
214
+ # Rejecting invalid anchor type
215
+ with self.assertRaises((TypeError, AttributeError)):
216
+ func(1234)
217
+ # Unknown module
218
+ with self.assertRaises(ModuleNotFoundError):
219
+ func('$missing module$')
220
+
221
+ def test_text_errors(self):
222
+ for func in (
223
+ resources.read_text,
224
+ resources.open_text,
225
+ ):
226
+ with self.subTest(func=func):
227
+ # Multiple path arguments need explicit encoding argument.
228
+ with self.assertRaises(TypeError):
229
+ func(
230
+ self.anchor02,
231
+ 'subdirectory',
232
+ 'subsubdir',
233
+ 'resource.txt',
234
+ )
235
+
236
+
237
+ class FunctionalAPITest_StringAnchor_Disk(
238
+ StringAnchorMixin,
239
+ FunctionalAPIBase,
240
+ util.DiskSetup,
241
+ unittest.TestCase,
242
+ ):
243
+ pass
244
+
245
+
246
+ class FunctionalAPITest_ModuleAnchor_Disk(
247
+ ModuleAnchorMixin,
248
+ FunctionalAPIBase,
249
+ util.DiskSetup,
250
+ unittest.TestCase,
251
+ ):
252
+ pass
253
+
254
+
255
+ class FunctionalAPITest_StringAnchor_Memory(
256
+ StringAnchorMixin,
257
+ FunctionalAPIBase,
258
+ util.MemorySetup,
259
+ unittest.TestCase,
260
+ ):
261
+ pass
python/user_packages/Python313/site-packages/importlib_resources/tests/test_open.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+
3
+ import importlib_resources as resources
4
+
5
+ from . import util
6
+
7
+
8
+ class CommonBinaryTests(util.CommonTests, unittest.TestCase):
9
+ def execute(self, package, path):
10
+ target = resources.files(package).joinpath(path)
11
+ with target.open('rb'):
12
+ pass
13
+
14
+
15
+ class CommonTextTests(util.CommonTests, unittest.TestCase):
16
+ def execute(self, package, path):
17
+ target = resources.files(package).joinpath(path)
18
+ with target.open(encoding='utf-8'):
19
+ pass
20
+
21
+
22
+ class OpenTests:
23
+ def test_open_binary(self):
24
+ target = resources.files(self.data) / 'binary.file'
25
+ with target.open('rb') as fp:
26
+ result = fp.read()
27
+ assert result == bytes(range(4))
28
+
29
+ def test_open_text_default_encoding(self):
30
+ target = resources.files(self.data) / 'utf-8.file'
31
+ with target.open(encoding='utf-8') as fp:
32
+ result = fp.read()
33
+ assert result == 'Hello, UTF-8 world!\n'
34
+
35
+ def test_open_text_given_encoding(self):
36
+ target = resources.files(self.data) / 'utf-16.file'
37
+ with target.open(encoding='utf-16', errors='strict') as fp:
38
+ result = fp.read()
39
+ assert result == 'Hello, UTF-16 world!\n'
40
+
41
+ def test_open_text_with_errors(self):
42
+ """
43
+ Raises UnicodeError without the 'errors' argument.
44
+ """
45
+ target = resources.files(self.data) / 'utf-16.file'
46
+ with target.open(encoding='utf-8', errors='strict') as fp:
47
+ self.assertRaises(UnicodeError, fp.read)
48
+ with target.open(encoding='utf-8', errors='ignore') as fp:
49
+ result = fp.read()
50
+ assert result == (
51
+ 'H\x00e\x00l\x00l\x00o\x00,\x00 '
52
+ '\x00U\x00T\x00F\x00-\x001\x006\x00 '
53
+ '\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00'
54
+ )
55
+
56
+ def test_open_binary_FileNotFoundError(self):
57
+ target = resources.files(self.data) / 'does-not-exist'
58
+ with self.assertRaises(FileNotFoundError):
59
+ target.open('rb')
60
+
61
+ def test_open_text_FileNotFoundError(self):
62
+ target = resources.files(self.data) / 'does-not-exist'
63
+ with self.assertRaises(FileNotFoundError):
64
+ target.open(encoding='utf-8')
65
+
66
+
67
+ class OpenDiskTests(OpenTests, util.DiskSetup, unittest.TestCase):
68
+ pass
69
+
70
+
71
+ class OpenDiskNamespaceTests(OpenTests, util.DiskSetup, unittest.TestCase):
72
+ MODULE = 'namespacedata01'
73
+
74
+
75
+ class OpenZipTests(OpenTests, util.ZipSetup, unittest.TestCase):
76
+ pass
77
+
78
+
79
+ class OpenNamespaceZipTests(OpenTests, util.ZipSetup, unittest.TestCase):
80
+ MODULE = 'namespacedata01'
81
+
82
+
83
+ if __name__ == '__main__':
84
+ unittest.main()
python/user_packages/Python313/site-packages/importlib_resources/tests/test_path.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ import pathlib
3
+ import unittest
4
+
5
+ import importlib_resources as resources
6
+
7
+ from . import util
8
+
9
+
10
+ class CommonTests(util.CommonTests, unittest.TestCase):
11
+ def execute(self, package, path):
12
+ with resources.as_file(resources.files(package).joinpath(path)):
13
+ pass
14
+
15
+
16
+ class PathTests:
17
+ def test_reading(self):
18
+ """
19
+ Path should be readable and a pathlib.Path instance.
20
+ """
21
+ target = resources.files(self.data) / 'utf-8.file'
22
+ with resources.as_file(target) as path:
23
+ assert isinstance(path, pathlib.Path)
24
+ assert path.name.endswith("utf-8.file"), repr(path)
25
+ assert 'Hello, UTF-8 world!\n' == path.read_text(encoding='utf-8')
26
+
27
+
28
+ class PathDiskTests(PathTests, util.DiskSetup, unittest.TestCase):
29
+ def test_natural_path(self):
30
+ """
31
+ Guarantee the internal implementation detail that
32
+ file-system-backed resources do not get the tempdir
33
+ treatment.
34
+ """
35
+ target = resources.files(self.data) / 'utf-8.file'
36
+ with resources.as_file(target) as path:
37
+ assert 'data' in str(path)
38
+
39
+
40
+ class PathMemoryTests(PathTests, unittest.TestCase):
41
+ def setUp(self):
42
+ file = io.BytesIO(b'Hello, UTF-8 world!\n')
43
+ self.addCleanup(file.close)
44
+ self.data = util.create_package(
45
+ file=file, path=FileNotFoundError("package exists only in memory")
46
+ )
47
+ self.data.__spec__.origin = None
48
+ self.data.__spec__.has_location = False
49
+
50
+
51
+ class PathZipTests(PathTests, util.ZipSetup, unittest.TestCase):
52
+ def test_remove_in_context_manager(self):
53
+ """
54
+ It is not an error if the file that was temporarily stashed on the
55
+ file system is removed inside the `with` stanza.
56
+ """
57
+ target = resources.files(self.data) / 'utf-8.file'
58
+ with resources.as_file(target) as path:
59
+ path.unlink()
60
+
61
+
62
+ if __name__ == '__main__':
63
+ unittest.main()
python/user_packages/Python313/site-packages/importlib_resources/tests/test_read.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+ from importlib import import_module
3
+
4
+ import importlib_resources as resources
5
+
6
+ from . import util
7
+
8
+
9
+ class CommonBinaryTests(util.CommonTests, unittest.TestCase):
10
+ def execute(self, package, path):
11
+ resources.files(package).joinpath(path).read_bytes()
12
+
13
+
14
+ class CommonTextTests(util.CommonTests, unittest.TestCase):
15
+ def execute(self, package, path):
16
+ resources.files(package).joinpath(path).read_text(encoding='utf-8')
17
+
18
+
19
+ class ReadTests:
20
+ def test_read_bytes(self):
21
+ result = resources.files(self.data).joinpath('binary.file').read_bytes()
22
+ assert result == bytes(range(4))
23
+
24
+ def test_read_text_default_encoding(self):
25
+ result = (
26
+ resources
27
+ .files(self.data)
28
+ .joinpath('utf-8.file')
29
+ .read_text(encoding='utf-8')
30
+ )
31
+ assert result == 'Hello, UTF-8 world!\n'
32
+
33
+ def test_read_text_given_encoding(self):
34
+ result = (
35
+ resources
36
+ .files(self.data)
37
+ .joinpath('utf-16.file')
38
+ .read_text(encoding='utf-16')
39
+ )
40
+ assert result == 'Hello, UTF-16 world!\n'
41
+
42
+ def test_read_text_with_errors(self):
43
+ """
44
+ Raises UnicodeError without the 'errors' argument.
45
+ """
46
+ target = resources.files(self.data) / 'utf-16.file'
47
+ self.assertRaises(UnicodeError, target.read_text, encoding='utf-8')
48
+ result = target.read_text(encoding='utf-8', errors='ignore')
49
+ assert result == (
50
+ 'H\x00e\x00l\x00l\x00o\x00,\x00 '
51
+ '\x00U\x00T\x00F\x00-\x001\x006\x00 '
52
+ '\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00'
53
+ )
54
+
55
+
56
+ class ReadDiskTests(ReadTests, util.DiskSetup, unittest.TestCase):
57
+ pass
58
+
59
+
60
+ class ReadZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
61
+ def test_read_submodule_resource(self):
62
+ submodule = import_module('data01.subdirectory')
63
+ result = resources.files(submodule).joinpath('binary.file').read_bytes()
64
+ assert result == bytes(range(4, 8))
65
+
66
+ def test_read_submodule_resource_by_name(self):
67
+ result = (
68
+ resources.files('data01.subdirectory').joinpath('binary.file').read_bytes()
69
+ )
70
+ assert result == bytes(range(4, 8))
71
+
72
+
73
+ class ReadNamespaceTests(ReadTests, util.DiskSetup, unittest.TestCase):
74
+ MODULE = 'namespacedata01'
75
+
76
+
77
+ class ReadNamespaceZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
78
+ MODULE = 'namespacedata01'
79
+
80
+ def test_read_submodule_resource(self):
81
+ submodule = import_module('namespacedata01.subdirectory')
82
+ result = resources.files(submodule).joinpath('binary.file').read_bytes()
83
+ assert result == bytes(range(12, 16))
84
+
85
+ def test_read_submodule_resource_by_name(self):
86
+ result = (
87
+ resources
88
+ .files('namespacedata01.subdirectory')
89
+ .joinpath('binary.file')
90
+ .read_bytes()
91
+ )
92
+ assert result == bytes(range(12, 16))
93
+
94
+
95
+ if __name__ == '__main__':
96
+ unittest.main()
python/user_packages/Python313/site-packages/importlib_resources/tests/test_reader.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os.path
2
+ import pathlib
3
+ import unittest
4
+ from importlib import import_module
5
+
6
+ from importlib_resources.readers import MultiplexedPath, NamespaceReader
7
+
8
+ from . import util
9
+
10
+
11
+ class MultiplexedPathTest(util.DiskSetup, unittest.TestCase):
12
+ MODULE = 'namespacedata01'
13
+
14
+ def setUp(self):
15
+ super().setUp()
16
+ self.folder = pathlib.Path(self.data.__path__[0])
17
+ self.data01 = pathlib.Path(self.load_fixture('data01').__file__).parent
18
+ self.data02 = pathlib.Path(self.load_fixture('data02').__file__).parent
19
+
20
+ def test_init_no_paths(self):
21
+ with self.assertRaises(FileNotFoundError):
22
+ MultiplexedPath()
23
+
24
+ def test_init_file(self):
25
+ with self.assertRaises(NotADirectoryError):
26
+ MultiplexedPath(self.folder / 'binary.file')
27
+
28
+ def test_iterdir(self):
29
+ contents = {path.name for path in MultiplexedPath(self.folder).iterdir()}
30
+ try:
31
+ contents.remove('__pycache__')
32
+ except (KeyError, ValueError):
33
+ pass
34
+ assert contents == {'subdirectory', 'binary.file', 'utf-16.file', 'utf-8.file'}
35
+
36
+ def test_iterdir_duplicate(self):
37
+ contents = {
38
+ path.name for path in MultiplexedPath(self.folder, self.data01).iterdir()
39
+ }
40
+ for remove in ('__pycache__', '__init__.pyc'):
41
+ try:
42
+ contents.remove(remove)
43
+ except (KeyError, ValueError):
44
+ pass
45
+ assert contents == {
46
+ '__init__.py',
47
+ 'binary.file',
48
+ 'subdirectory',
49
+ 'utf-16.file',
50
+ 'utf-8.file',
51
+ }
52
+
53
+ def test_is_dir(self):
54
+ assert MultiplexedPath(self.folder).is_dir()
55
+
56
+ def test_is_file(self):
57
+ assert not MultiplexedPath(self.folder).is_file()
58
+
59
+ def test_open_file(self):
60
+ path = MultiplexedPath(self.folder)
61
+ with self.assertRaises(FileNotFoundError):
62
+ path.read_bytes()
63
+ with self.assertRaises(FileNotFoundError):
64
+ path.read_text()
65
+ with self.assertRaises(FileNotFoundError):
66
+ path.open()
67
+
68
+ def test_join_path(self):
69
+ prefix = str(self.folder.parent)
70
+ path = MultiplexedPath(self.folder, self.data01)
71
+ assert str(path.joinpath('binary.file'))[len(prefix) + 1 :] == os.path.join(
72
+ 'namespacedata01', 'binary.file'
73
+ )
74
+ sub = path.joinpath('subdirectory')
75
+ assert isinstance(sub, MultiplexedPath)
76
+ assert 'namespacedata01' in str(sub)
77
+ assert 'data01' in str(sub)
78
+ assert str(path.joinpath('imaginary'))[len(prefix) + 1 :] == os.path.join(
79
+ 'namespacedata01', 'imaginary'
80
+ )
81
+ assert path.joinpath() == path
82
+
83
+ def test_join_path_compound(self):
84
+ path = MultiplexedPath(self.folder)
85
+ assert not path.joinpath('imaginary/foo.py').exists()
86
+
87
+ def test_join_path_common_subdir(self):
88
+ prefix = str(self.data02.parent)
89
+ path = MultiplexedPath(self.data01, self.data02)
90
+ assert isinstance(path.joinpath('subdirectory'), MultiplexedPath)
91
+ assert str(path.joinpath('subdirectory', 'subsubdir'))[len(prefix) + 1 :] == (
92
+ os.path.join('data02', 'subdirectory', 'subsubdir')
93
+ )
94
+
95
+ def test_repr(self):
96
+ assert repr(MultiplexedPath(self.folder)) == f"MultiplexedPath('{self.folder}')"
97
+
98
+ def test_name(self):
99
+ assert MultiplexedPath(self.folder).name == os.path.basename(self.folder)
100
+
101
+
102
+ class NamespaceReaderTest(util.DiskSetup, unittest.TestCase):
103
+ MODULE = 'namespacedata01'
104
+
105
+ def test_init_error(self):
106
+ with self.assertRaises(ValueError):
107
+ NamespaceReader(['path1', 'path2'])
108
+
109
+ def test_resource_path(self):
110
+ namespacedata01 = import_module('namespacedata01')
111
+ reader = NamespaceReader(namespacedata01.__spec__.submodule_search_locations)
112
+
113
+ root = self.data.__path__[0]
114
+ assert reader.resource_path('binary.file') == os.path.join(root, 'binary.file')
115
+ assert reader.resource_path('imaginary') == os.path.join(root, 'imaginary')
116
+
117
+ def test_files(self):
118
+ reader = NamespaceReader(self.data.__spec__.submodule_search_locations)
119
+ root = self.data.__path__[0]
120
+ assert isinstance(reader.files(), MultiplexedPath)
121
+ assert repr(reader.files()) == f"MultiplexedPath('{root}')"
122
+
123
+
124
+ if __name__ == '__main__':
125
+ unittest.main()
python/user_packages/Python313/site-packages/importlib_resources/tests/test_resource.py ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import types
2
+ import unittest
3
+ from importlib import import_module
4
+
5
+ import importlib_resources as resources
6
+
7
+ from . import util
8
+
9
+
10
+ class ResourceTests:
11
+ # Subclasses are expected to set the `data` attribute.
12
+
13
+ def test_is_file_exists(self):
14
+ target = resources.files(self.data) / 'binary.file'
15
+ assert target.is_file()
16
+
17
+ def test_is_file_missing(self):
18
+ target = resources.files(self.data) / 'not-a-file'
19
+ assert not target.is_file()
20
+
21
+ def test_is_dir(self):
22
+ target = resources.files(self.data) / 'subdirectory'
23
+ assert not target.is_file()
24
+ assert target.is_dir()
25
+
26
+
27
+ class ResourceDiskTests(ResourceTests, util.DiskSetup, unittest.TestCase):
28
+ pass
29
+
30
+
31
+ class ResourceZipTests(ResourceTests, util.ZipSetup, unittest.TestCase):
32
+ pass
33
+
34
+
35
+ def names(traversable):
36
+ return {item.name for item in traversable.iterdir()}
37
+
38
+
39
+ class ResourceLoaderTests(util.DiskSetup, unittest.TestCase):
40
+ def test_resource_contents(self):
41
+ package = util.create_package(
42
+ file=self.data, path=self.data.__file__, contents=['A', 'B', 'C']
43
+ )
44
+ assert names(resources.files(package)) == {'A', 'B', 'C'}
45
+
46
+ def test_is_file(self):
47
+ package = util.create_package(
48
+ file=self.data,
49
+ path=self.data.__file__,
50
+ contents=['A', 'B', 'C', 'D/E', 'D/F'],
51
+ )
52
+ assert resources.files(package).joinpath('B').is_file()
53
+
54
+ def test_is_dir(self):
55
+ package = util.create_package(
56
+ file=self.data,
57
+ path=self.data.__file__,
58
+ contents=['A', 'B', 'C', 'D/E', 'D/F'],
59
+ )
60
+ assert resources.files(package).joinpath('D').is_dir()
61
+
62
+ def test_resource_missing(self):
63
+ package = util.create_package(
64
+ file=self.data,
65
+ path=self.data.__file__,
66
+ contents=['A', 'B', 'C', 'D/E', 'D/F'],
67
+ )
68
+ assert not resources.files(package).joinpath('Z').is_file()
69
+
70
+
71
+ class ResourceCornerCaseTests(util.DiskSetup, unittest.TestCase):
72
+ def test_package_has_no_reader_fallback(self):
73
+ """
74
+ Test odd ball packages which:
75
+ # 1. Do not have a ResourceReader as a loader
76
+ # 2. Are not on the file system
77
+ # 3. Are not in a zip file
78
+ """
79
+ module = util.create_package(
80
+ file=self.data, path=self.data.__file__, contents=['A', 'B', 'C']
81
+ )
82
+ # Give the module a dummy loader.
83
+ module.__loader__ = object()
84
+ # Give the module a dummy origin.
85
+ module.__file__ = '/path/which/shall/not/be/named'
86
+ module.__spec__.loader = module.__loader__
87
+ module.__spec__.origin = module.__file__
88
+ assert not resources.files(module).joinpath('A').is_file()
89
+
90
+
91
+ class ResourceFromZipsTest01(util.ZipSetup, unittest.TestCase):
92
+ def test_is_submodule_resource(self):
93
+ submodule = import_module('data01.subdirectory')
94
+ assert resources.files(submodule).joinpath('binary.file').is_file()
95
+
96
+ def test_read_submodule_resource_by_name(self):
97
+ assert resources.files('data01.subdirectory').joinpath('binary.file').is_file()
98
+
99
+ def test_submodule_contents(self):
100
+ submodule = import_module('data01.subdirectory')
101
+ assert names(resources.files(submodule)) == {'__init__.py', 'binary.file'}
102
+
103
+ def test_submodule_contents_by_name(self):
104
+ assert names(resources.files('data01.subdirectory')) == {
105
+ '__init__.py',
106
+ 'binary.file',
107
+ }
108
+
109
+ def test_as_file_directory(self):
110
+ with resources.as_file(resources.files('data01')) as data:
111
+ assert data.name == 'data01'
112
+ assert data.is_dir()
113
+ assert data.joinpath('subdirectory').is_dir()
114
+ assert len(list(data.iterdir()))
115
+ assert not data.parent.exists()
116
+
117
+
118
+ class ResourceFromZipsTest02(util.ZipSetup, unittest.TestCase):
119
+ MODULE = 'data02'
120
+
121
+ def test_unrelated_contents(self):
122
+ """
123
+ Test thata zip with two unrelated subpackages return
124
+ distinct resources. Ref python/importlib_resources#44.
125
+ """
126
+ assert names(resources.files('data02.one')) == {'__init__.py', 'resource1.txt'}
127
+ assert names(resources.files('data02.two')) == {'__init__.py', 'resource2.txt'}
128
+
129
+
130
+ class DeletingZipsTest(util.ZipSetup, unittest.TestCase):
131
+ """Having accessed resources in a zip file should not keep an open
132
+ reference to the zip.
133
+ """
134
+
135
+ def test_iterdir_does_not_keep_open(self):
136
+ [item.name for item in resources.files('data01').iterdir()]
137
+
138
+ def test_is_file_does_not_keep_open(self):
139
+ resources.files('data01').joinpath('binary.file').is_file()
140
+
141
+ def test_is_file_failure_does_not_keep_open(self):
142
+ resources.files('data01').joinpath('not-present').is_file()
143
+
144
+ @unittest.skip("Desired but not supported.")
145
+ def test_as_file_does_not_keep_open(self): # pragma: no cover
146
+ resources.as_file(resources.files('data01') / 'binary.file')
147
+
148
+ def test_entered_path_does_not_keep_open(self):
149
+ """
150
+ Mimic what certifi does on import to make its bundle
151
+ available for the process duration.
152
+ """
153
+ resources.as_file(resources.files('data01') / 'binary.file').__enter__()
154
+
155
+ def test_read_binary_does_not_keep_open(self):
156
+ resources.files('data01').joinpath('binary.file').read_bytes()
157
+
158
+ def test_read_text_does_not_keep_open(self):
159
+ resources.files('data01').joinpath('utf-8.file').read_text(encoding='utf-8')
160
+
161
+
162
+ class ResourceFromNamespaceTests:
163
+ def test_is_submodule_resource(self):
164
+ assert (
165
+ resources
166
+ .files(import_module('namespacedata01'))
167
+ .joinpath('binary.file')
168
+ .is_file()
169
+ )
170
+
171
+ def test_read_submodule_resource_by_name(self):
172
+ assert resources.files('namespacedata01').joinpath('binary.file').is_file()
173
+
174
+ def test_submodule_contents(self):
175
+ contents = names(resources.files(import_module('namespacedata01')))
176
+ try:
177
+ contents.remove('__pycache__')
178
+ except KeyError:
179
+ pass
180
+ assert contents == {'subdirectory', 'binary.file', 'utf-8.file', 'utf-16.file'}
181
+
182
+ def test_submodule_contents_by_name(self):
183
+ contents = names(resources.files('namespacedata01'))
184
+ try:
185
+ contents.remove('__pycache__')
186
+ except KeyError:
187
+ pass
188
+ assert contents == {'subdirectory', 'binary.file', 'utf-8.file', 'utf-16.file'}
189
+
190
+ def test_submodule_sub_contents(self):
191
+ contents = names(resources.files(import_module('namespacedata01.subdirectory')))
192
+ try:
193
+ contents.remove('__pycache__')
194
+ except KeyError:
195
+ pass
196
+ assert contents == {'binary.file'}
197
+
198
+ def test_submodule_sub_contents_by_name(self):
199
+ contents = names(resources.files('namespacedata01.subdirectory'))
200
+ try:
201
+ contents.remove('__pycache__')
202
+ except KeyError:
203
+ pass
204
+ assert contents == {'binary.file'}
205
+
206
+
207
+ class ResourceFromNamespaceDiskTests(
208
+ util.DiskSetup,
209
+ ResourceFromNamespaceTests,
210
+ unittest.TestCase,
211
+ ):
212
+ MODULE = 'namespacedata01'
213
+
214
+
215
+ class ResourceFromNamespaceZipTests(
216
+ util.ZipSetup,
217
+ ResourceFromNamespaceTests,
218
+ unittest.TestCase,
219
+ ):
220
+ MODULE = 'namespacedata01'
221
+
222
+
223
+ class MainModuleTests(unittest.TestCase):
224
+ def test_main_module_with_none_spec(self):
225
+ """
226
+ __main__ module with no spec should raise TypeError (for clarity).
227
+
228
+ See python/cpython#138531 for details.
229
+ """
230
+ # construct a __main__ module with no __spec__.
231
+ mainmodule = types.ModuleType("__main__")
232
+
233
+ assert mainmodule.__spec__ is None
234
+
235
+ with self.assertRaises(
236
+ TypeError,
237
+ msg="Cannot access resources for '__main__' as it does not appear to correspond to an importable module (its __spec__ is None).",
238
+ ):
239
+ resources.files(mainmodule)
240
+
241
+
242
+ if __name__ == '__main__':
243
+ unittest.main()
python/user_packages/Python313/site-packages/importlib_resources/tests/test_util.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+
3
+ from .util import MemorySetup, Traversable
4
+
5
+
6
+ class TestMemoryTraversableImplementation(unittest.TestCase):
7
+ def test_concrete_methods_are_not_overridden(self):
8
+ """`MemoryTraversable` must not override `Traversable` concrete methods.
9
+
10
+ This test is not an attempt to enforce a particular `Traversable` protocol;
11
+ it merely catches changes in the `Traversable` abstract/concrete methods
12
+ that have not been mirrored in the `MemoryTraversable` subclass.
13
+ """
14
+
15
+ traversable_concrete_methods = {
16
+ method
17
+ for method, value in Traversable.__dict__.items()
18
+ if callable(value) and method not in Traversable.__abstractmethods__
19
+ }
20
+ memory_traversable_concrete_methods = {
21
+ method
22
+ for method, value in MemorySetup.MemoryTraversable.__dict__.items()
23
+ if callable(value) and not method.startswith("__")
24
+ }
25
+ overridden_methods = (
26
+ memory_traversable_concrete_methods & traversable_concrete_methods
27
+ )
28
+
29
+ assert not overridden_methods
python/user_packages/Python313/site-packages/importlib_resources/tests/util.py ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import abc
2
+ import contextlib
3
+ import functools
4
+ import importlib
5
+ import io
6
+ import pathlib
7
+ import sys
8
+ import types
9
+ from importlib.machinery import ModuleSpec
10
+
11
+ from ..abc import ResourceReader, Traversable, TraversableResources
12
+ from . import _path
13
+ from . import zip as zip_
14
+ from .compat.py39 import import_helper, os_helper
15
+
16
+
17
+ class Reader(ResourceReader):
18
+ def __init__(self, **kwargs):
19
+ vars(self).update(kwargs)
20
+
21
+ def get_resource_reader(self, package):
22
+ return self
23
+
24
+ def open_resource(self, path):
25
+ self._path = path
26
+ if isinstance(self.file, Exception):
27
+ raise self.file
28
+ return self.file
29
+
30
+ def resource_path(self, path_):
31
+ self._path = path_
32
+ if isinstance(self.path, Exception):
33
+ raise self.path
34
+ return self.path
35
+
36
+ def is_resource(self, path_):
37
+ self._path = path_
38
+ if isinstance(self.path, Exception):
39
+ raise self.path
40
+
41
+ def part(entry):
42
+ return entry.split('/')
43
+
44
+ return any(
45
+ len(parts) == 1 and parts[0] == path_ for parts in map(part, self._contents)
46
+ )
47
+
48
+ def contents(self):
49
+ if isinstance(self.path, Exception):
50
+ raise self.path
51
+ yield from self._contents
52
+
53
+
54
+ def create_package_from_loader(loader, is_package=True):
55
+ name = 'testingpackage'
56
+ module = types.ModuleType(name)
57
+ spec = ModuleSpec(name, loader, origin='does-not-exist', is_package=is_package)
58
+ module.__spec__ = spec
59
+ module.__loader__ = loader
60
+ return module
61
+
62
+
63
+ def create_package(file=None, path=None, is_package=True, contents=()):
64
+ return create_package_from_loader(
65
+ Reader(file=file, path=path, _contents=contents),
66
+ is_package,
67
+ )
68
+
69
+
70
+ class CommonTestsBase(metaclass=abc.ABCMeta):
71
+ """
72
+ Tests shared by test_open, test_path, and test_read.
73
+ """
74
+
75
+ @abc.abstractmethod
76
+ def execute(self, package, path):
77
+ """
78
+ Call the pertinent legacy API function (e.g. open_text, path)
79
+ on package and path.
80
+ """
81
+
82
+ def test_package_name(self):
83
+ """
84
+ Passing in the package name should succeed.
85
+ """
86
+ self.execute(self.data.__name__, 'utf-8.file')
87
+
88
+ def test_package_object(self):
89
+ """
90
+ Passing in the package itself should succeed.
91
+ """
92
+ self.execute(self.data, 'utf-8.file')
93
+
94
+ def test_string_path(self):
95
+ """
96
+ Passing in a string for the path should succeed.
97
+ """
98
+ path = 'utf-8.file'
99
+ self.execute(self.data, path)
100
+
101
+ def test_pathlib_path(self):
102
+ """
103
+ Passing in a pathlib.PurePath object for the path should succeed.
104
+ """
105
+ path = pathlib.PurePath('utf-8.file')
106
+ self.execute(self.data, path)
107
+
108
+ def test_importing_module_as_side_effect(self):
109
+ """
110
+ The anchor package can already be imported.
111
+ """
112
+ del sys.modules[self.data.__name__]
113
+ self.execute(self.data.__name__, 'utf-8.file')
114
+
115
+ def test_missing_path(self):
116
+ """
117
+ Attempting to open or read or request the path for a
118
+ non-existent path should succeed if open_resource
119
+ can return a viable data stream.
120
+ """
121
+ bytes_data = io.BytesIO(b'Hello, world!')
122
+ package = create_package(file=bytes_data, path=FileNotFoundError())
123
+ self.execute(package, 'utf-8.file')
124
+ assert package.__loader__._path == 'utf-8.file'
125
+
126
+ def test_extant_path(self):
127
+ # Attempting to open or read or request the path when the
128
+ # path does exist should still succeed. Does not assert
129
+ # anything about the result.
130
+ bytes_data = io.BytesIO(b'Hello, world!')
131
+ # any path that exists
132
+ path = __file__
133
+ package = create_package(file=bytes_data, path=path)
134
+ self.execute(package, 'utf-8.file')
135
+ assert package.__loader__._path == 'utf-8.file'
136
+
137
+ def test_useless_loader(self):
138
+ package = create_package(file=FileNotFoundError(), path=FileNotFoundError())
139
+ with self.assertRaises(FileNotFoundError):
140
+ self.execute(package, 'utf-8.file')
141
+
142
+
143
+ fixtures = dict(
144
+ data01={
145
+ '__init__.py': '',
146
+ 'binary.file': bytes(range(4)),
147
+ 'utf-16.file': '\ufeffHello, UTF-16 world!\n'.encode('utf-16-le'),
148
+ 'utf-8.file': 'Hello, UTF-8 world!\n'.encode('utf-8'),
149
+ 'subdirectory': {
150
+ '__init__.py': '',
151
+ 'binary.file': bytes(range(4, 8)),
152
+ },
153
+ },
154
+ data02={
155
+ '__init__.py': '',
156
+ 'one': {'__init__.py': '', 'resource1.txt': 'one resource'},
157
+ 'two': {'__init__.py': '', 'resource2.txt': 'two resource'},
158
+ 'subdirectory': {'subsubdir': {'resource.txt': 'a resource'}},
159
+ },
160
+ namespacedata01={
161
+ 'binary.file': bytes(range(4)),
162
+ 'utf-16.file': '\ufeffHello, UTF-16 world!\n'.encode('utf-16-le'),
163
+ 'utf-8.file': 'Hello, UTF-8 world!\n'.encode('utf-8'),
164
+ 'subdirectory': {
165
+ 'binary.file': bytes(range(12, 16)),
166
+ },
167
+ },
168
+ )
169
+
170
+
171
+ class ModuleSetup:
172
+ def setUp(self):
173
+ self.fixtures = contextlib.ExitStack()
174
+ self.addCleanup(self.fixtures.close)
175
+
176
+ self.fixtures.enter_context(import_helper.isolated_modules())
177
+ self.data = self.load_fixture(self.MODULE)
178
+
179
+ def load_fixture(self, module):
180
+ self.tree_on_path({module: fixtures[module]})
181
+ return importlib.import_module(module)
182
+
183
+
184
+ class ZipSetup(ModuleSetup):
185
+ MODULE = 'data01'
186
+
187
+ def tree_on_path(self, spec):
188
+ temp_dir = self.fixtures.enter_context(os_helper.temp_dir())
189
+ modules = pathlib.Path(temp_dir) / 'zipped modules.zip'
190
+ self.fixtures.enter_context(
191
+ import_helper.DirsOnSysPath(str(zip_.make_zip_file(spec, modules)))
192
+ )
193
+
194
+
195
+ class DiskSetup(ModuleSetup):
196
+ MODULE = 'data01'
197
+
198
+ def tree_on_path(self, spec):
199
+ temp_dir = self.fixtures.enter_context(os_helper.temp_dir())
200
+ _path.build(spec, pathlib.Path(temp_dir))
201
+ self.fixtures.enter_context(import_helper.DirsOnSysPath(temp_dir))
202
+
203
+
204
+ class MemorySetup(ModuleSetup):
205
+ """Support loading a module in memory."""
206
+
207
+ MODULE = 'data01'
208
+
209
+ def load_fixture(self, module):
210
+ self.fixtures.enter_context(self.augment_sys_metapath(module))
211
+ return importlib.import_module(module)
212
+
213
+ @contextlib.contextmanager
214
+ def augment_sys_metapath(self, module):
215
+ finder_instance = self.MemoryFinder(module)
216
+ sys.meta_path.append(finder_instance)
217
+ yield
218
+ sys.meta_path.remove(finder_instance)
219
+
220
+ class MemoryFinder(importlib.abc.MetaPathFinder):
221
+ def __init__(self, module):
222
+ self._module = module
223
+
224
+ def find_spec(self, fullname, path, target=None):
225
+ if fullname != self._module:
226
+ return None
227
+
228
+ return importlib.machinery.ModuleSpec(
229
+ name=fullname,
230
+ loader=MemorySetup.MemoryLoader(self._module),
231
+ is_package=True,
232
+ )
233
+
234
+ class MemoryLoader(importlib.abc.Loader):
235
+ def __init__(self, module):
236
+ self._module = module
237
+
238
+ def exec_module(self, module):
239
+ pass
240
+
241
+ def get_resource_reader(self, fullname):
242
+ return MemorySetup.MemoryTraversableResources(self._module, fullname)
243
+
244
+ class MemoryTraversableResources(TraversableResources):
245
+ def __init__(self, module, fullname):
246
+ self._module = module
247
+ self._fullname = fullname
248
+
249
+ def files(self):
250
+ return MemorySetup.MemoryTraversable(self._module, self._fullname)
251
+
252
+ class MemoryTraversable(Traversable):
253
+ """Implement only the abstract methods of `Traversable`.
254
+
255
+ Besides `.__init__()`, no other methods may be implemented or overridden.
256
+ This is critical for validating the concrete `Traversable` implementations.
257
+ """
258
+
259
+ def __init__(self, module, fullname):
260
+ self._module = module
261
+ self._fullname = fullname
262
+
263
+ def _resolve(self):
264
+ """
265
+ Fully traverse the `fixtures` dictionary.
266
+
267
+ This should be wrapped in a `try/except KeyError`
268
+ but it is not currently needed and lowers the code coverage numbers.
269
+ """
270
+ path = pathlib.PurePosixPath(self._fullname)
271
+ return functools.reduce(lambda d, p: d[p], path.parts, fixtures)
272
+
273
+ def iterdir(self):
274
+ directory = self._resolve()
275
+ if not isinstance(directory, dict):
276
+ # Filesystem openers raise OSError, and that exception is mirrored here.
277
+ raise OSError(f"{self._fullname} is not a directory")
278
+ for path in directory:
279
+ yield MemorySetup.MemoryTraversable(
280
+ self._module, f"{self._fullname}/{path}"
281
+ )
282
+
283
+ def is_dir(self) -> bool:
284
+ return isinstance(self._resolve(), dict)
285
+
286
+ def is_file(self) -> bool:
287
+ return not self.is_dir()
288
+
289
+ def open(self, mode='r', encoding=None, errors=None, *_, **__):
290
+ contents = self._resolve()
291
+ if isinstance(contents, dict):
292
+ # Filesystem openers raise OSError when attempting to open a directory,
293
+ # and that exception is mirrored here.
294
+ raise OSError(f"{self._fullname} is a directory")
295
+ if isinstance(contents, str):
296
+ contents = contents.encode("utf-8")
297
+ result = io.BytesIO(contents)
298
+ if "b" in mode:
299
+ return result
300
+ return io.TextIOWrapper(result, encoding=encoding, errors=errors)
301
+
302
+ @property
303
+ def name(self):
304
+ return pathlib.PurePosixPath(self._fullname).name
305
+
306
+
307
+ class CommonTests(DiskSetup, CommonTestsBase):
308
+ pass
python/user_packages/Python313/site-packages/importlib_resources/tests/zip.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Generate zip test data files.
3
+ """
4
+
5
+ import zipfile
6
+
7
+ import zipp
8
+
9
+
10
+ def make_zip_file(tree, dst):
11
+ """
12
+ Zip the files in tree into a new zipfile at dst.
13
+ """
14
+ with zipfile.ZipFile(dst, 'w') as zf:
15
+ for name, contents in walk(tree):
16
+ zf.writestr(name, contents)
17
+ zipp.CompleteDirs.inject(zf)
18
+ return dst
19
+
20
+
21
+ def walk(tree, prefix=''):
22
+ for name, contents in tree.items():
23
+ if isinstance(contents, dict):
24
+ yield from walk(contents, prefix=f'{prefix}{name}/')
25
+ else:
26
+ yield f'{prefix}{name}', contents
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (1.62 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/_json.cpython-313.pyc ADDED
Binary file (1.25 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/encoding.cpython-313.pyc ADDED
Binary file (2.68 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/exc.cpython-313.pyc ADDED
Binary file (4.06 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/serializer.cpython-313.pyc ADDED
Binary file (15.1 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/signer.cpython-313.pyc ADDED
Binary file (11.3 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/timed.cpython-313.pyc ADDED
Binary file (8.6 kB). View file
 
python/user_packages/Python313/site-packages/itsdangerous/__pycache__/url_safe.cpython-313.pyc ADDED
Binary file (3.65 kB). View file
 
python/user_packages/Python313/site-packages/jinja2-3.1.6.dist-info/licenses/LICENSE.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2007 Pallets
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
python/user_packages/Python313/site-packages/jinja2/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (1.65 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/_identifier.cpython-313.pyc ADDED
Binary file (2.13 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/async_utils.cpython-313.pyc ADDED
Binary file (5.06 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/bccache.cpython-313.pyc ADDED
Binary file (19.4 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/constants.cpython-313.pyc ADDED
Binary file (1.55 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/debug.cpython-313.pyc ADDED
Binary file (6.58 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/defaults.cpython-313.pyc ADDED
Binary file (1.61 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/environment.cpython-313.pyc ADDED
Binary file (74.8 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/exceptions.cpython-313.pyc ADDED
Binary file (8.02 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/ext.cpython-313.pyc ADDED
Binary file (42.2 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/filters.cpython-313.pyc ADDED
Binary file (71.4 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/idtracking.cpython-313.pyc ADDED
Binary file (19.4 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/lexer.cpython-313.pyc ADDED
Binary file (32.5 kB). View file
 
python/user_packages/Python313/site-packages/jinja2/__pycache__/loaders.cpython-313.pyc ADDED
Binary file (32.4 kB). View file