assassinlike commited on
Commit
37001c0
·
verified ·
1 Parent(s): a6c9bd9

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/operations/install/__pycache__/wheel.cpython-311.pyc +0 -0
  2. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/__init__.cpython-311.pyc +0 -0
  3. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/_jaraco_text.cpython-311.pyc +0 -0
  4. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/_log.cpython-311.pyc +0 -0
  5. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/appdirs.cpython-311.pyc +0 -0
  6. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/compat.cpython-311.pyc +0 -0
  7. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/compatibility_tags.cpython-311.pyc +0 -0
  8. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/datetime.cpython-311.pyc +0 -0
  9. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/deprecation.cpython-311.pyc +0 -0
  10. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/direct_url_helpers.cpython-311.pyc +0 -0
  11. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/egg_link.cpython-311.pyc +0 -0
  12. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/entrypoints.cpython-311.pyc +0 -0
  13. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/filesystem.cpython-311.pyc +0 -0
  14. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/filetypes.cpython-311.pyc +0 -0
  15. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/glibc.cpython-311.pyc +0 -0
  16. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/hashes.cpython-311.pyc +0 -0
  17. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/logging.cpython-311.pyc +0 -0
  18. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/misc.cpython-311.pyc +0 -0
  19. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/packaging.cpython-311.pyc +0 -0
  20. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/pylock.cpython-311.pyc +0 -0
  21. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/retry.cpython-311.pyc +0 -0
  22. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/subprocess.cpython-311.pyc +0 -0
  23. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/temp_dir.cpython-311.pyc +0 -0
  24. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-311.pyc +0 -0
  25. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/urls.cpython-311.pyc +0 -0
  26. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/virtualenv.cpython-311.pyc +0 -0
  27. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/wheel.cpython-311.pyc +0 -0
  28. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/__pycache__/__init__.cpython-311.pyc +0 -0
  29. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  30. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/__init__.py +32 -0
  31. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  32. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/adapter.py +167 -0
  33. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/cache.py +75 -0
  34. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/controller.py +511 -0
  35. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/filewrapper.py +121 -0
  36. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/heuristics.py +157 -0
  37. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  38. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  39. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  40. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/LICENSE +21 -0
  41. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/__init__.py +631 -0
  42. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/__main__.py +55 -0
  43. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/android.py +249 -0
  44. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/api.py +299 -0
  45. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/macos.py +146 -0
  46. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
  47. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/unix.py +272 -0
  48. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/version.py +34 -0
  49. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/windows.py +278 -0
  50. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/rich/__init__.py +177 -0
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/operations/install/__pycache__/wheel.cpython-311.pyc ADDED
Binary file (40.1 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (169 Bytes). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/_jaraco_text.cpython-311.pyc ADDED
Binary file (4.73 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/_log.cpython-311.pyc ADDED
Binary file (1.99 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/appdirs.cpython-311.pyc ADDED
Binary file (2.56 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/compat.cpython-311.pyc ADDED
Binary file (3.1 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/compatibility_tags.cpython-311.pyc ADDED
Binary file (8.03 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/datetime.cpython-311.pyc ADDED
Binary file (1.57 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/deprecation.cpython-311.pyc ADDED
Binary file (4.54 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/direct_url_helpers.cpython-311.pyc ADDED
Binary file (3.66 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/egg_link.cpython-311.pyc ADDED
Binary file (3.46 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/entrypoints.cpython-311.pyc ADDED
Binary file (4.28 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/filesystem.cpython-311.pyc ADDED
Binary file (11.2 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/filetypes.cpython-311.pyc ADDED
Binary file (1.23 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/glibc.cpython-311.pyc ADDED
Binary file (2.6 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/hashes.cpython-311.pyc ADDED
Binary file (8.87 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/logging.cpython-311.pyc ADDED
Binary file (17.3 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/misc.cpython-311.pyc ADDED
Binary file (36.4 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/packaging.cpython-311.pyc ADDED
Binary file (2 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/pylock.cpython-311.pyc ADDED
Binary file (4.64 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/retry.cpython-311.pyc ADDED
Binary file (2.24 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/subprocess.cpython-311.pyc ADDED
Binary file (9.45 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/temp_dir.cpython-311.pyc ADDED
Binary file (13.3 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-311.pyc ADDED
Binary file (16.4 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/urls.cpython-311.pyc ADDED
Binary file (2.27 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/virtualenv.cpython-311.pyc ADDED
Binary file (4.82 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_internal/utils/__pycache__/wheel.cpython-311.pyc ADDED
Binary file (6.91 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (5.45 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2012-2021 Eric Larson
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/__init__.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """CacheControl import Interface.
6
+
7
+ Make it easy to import from cachecontrol without long namespaces.
8
+ """
9
+
10
+ import importlib.metadata
11
+
12
+ from pip._vendor.cachecontrol.adapter import CacheControlAdapter
13
+ from pip._vendor.cachecontrol.controller import CacheController
14
+ from pip._vendor.cachecontrol.wrapper import CacheControl
15
+
16
+ __author__ = "Eric Larson"
17
+ __email__ = "eric@ionrock.org"
18
+ # pip patch: this won't work when vendored, so just patch it out as it's unused
19
+ # __version__ = importlib.metadata.version("cachecontrol")
20
+
21
+ __all__ = [
22
+ "__author__",
23
+ "__email__",
24
+ "__version__",
25
+ "CacheControlAdapter",
26
+ "CacheController",
27
+ "CacheControl",
28
+ ]
29
+
30
+ import logging
31
+
32
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/_cmd.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import logging
7
+ from argparse import ArgumentParser
8
+ from typing import TYPE_CHECKING
9
+
10
+ from pip._vendor import requests
11
+
12
+ from pip._vendor.cachecontrol.adapter import CacheControlAdapter
13
+ from pip._vendor.cachecontrol.cache import DictCache
14
+ from pip._vendor.cachecontrol.controller import logger
15
+
16
+ if TYPE_CHECKING:
17
+ from argparse import Namespace
18
+
19
+ from pip._vendor.cachecontrol.controller import CacheController
20
+
21
+
22
+ def setup_logging() -> None:
23
+ logger.setLevel(logging.DEBUG)
24
+ handler = logging.StreamHandler()
25
+ logger.addHandler(handler)
26
+
27
+
28
+ def get_session() -> requests.Session:
29
+ adapter = CacheControlAdapter(
30
+ DictCache(), cache_etags=True, serializer=None, heuristic=None
31
+ )
32
+ sess = requests.Session()
33
+ sess.mount("http://", adapter)
34
+ sess.mount("https://", adapter)
35
+
36
+ sess.cache_controller = adapter.controller # type: ignore[attr-defined]
37
+ return sess
38
+
39
+
40
+ def get_args() -> Namespace:
41
+ parser = ArgumentParser()
42
+ parser.add_argument("url", help="The URL to try and cache")
43
+ return parser.parse_args()
44
+
45
+
46
+ def main() -> None:
47
+ args = get_args()
48
+ sess = get_session()
49
+
50
+ # Make a request to get a response
51
+ resp = sess.get(args.url)
52
+
53
+ # Turn on logging
54
+ setup_logging()
55
+
56
+ # try setting the cache
57
+ cache_controller: CacheController = (
58
+ sess.cache_controller # type: ignore[attr-defined]
59
+ )
60
+ cache_controller.cache_response(resp.request, resp.raw)
61
+
62
+ # Now try to get it
63
+ if cache_controller.cached_request(resp.request):
64
+ print("Cached!")
65
+ else:
66
+ print("Not cached :(")
67
+
68
+
69
+ if __name__ == "__main__":
70
+ main()
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/adapter.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import functools
7
+ import weakref
8
+ import zlib
9
+ from typing import TYPE_CHECKING, Any, Collection, Mapping
10
+
11
+ from pip._vendor.requests.adapters import HTTPAdapter
12
+
13
+ from pip._vendor.cachecontrol.cache import DictCache
14
+ from pip._vendor.cachecontrol.controller import PERMANENT_REDIRECT_STATUSES, CacheController
15
+ from pip._vendor.cachecontrol.filewrapper import CallbackFileWrapper
16
+
17
+ if TYPE_CHECKING:
18
+ from pip._vendor.requests import PreparedRequest, Response
19
+ from pip._vendor.urllib3 import HTTPResponse
20
+
21
+ from pip._vendor.cachecontrol.cache import BaseCache
22
+ from pip._vendor.cachecontrol.heuristics import BaseHeuristic
23
+ from pip._vendor.cachecontrol.serialize import Serializer
24
+
25
+
26
+ class CacheControlAdapter(HTTPAdapter):
27
+ invalidating_methods = {"PUT", "PATCH", "DELETE"}
28
+
29
+ def __init__(
30
+ self,
31
+ cache: BaseCache | None = None,
32
+ cache_etags: bool = True,
33
+ controller_class: type[CacheController] | None = None,
34
+ serializer: Serializer | None = None,
35
+ heuristic: BaseHeuristic | None = None,
36
+ cacheable_methods: Collection[str] | None = None,
37
+ *args: Any,
38
+ **kw: Any,
39
+ ) -> None:
40
+ super().__init__(*args, **kw)
41
+ self.cache = DictCache() if cache is None else cache
42
+ self.heuristic = heuristic
43
+ self.cacheable_methods = cacheable_methods or ("GET",)
44
+
45
+ controller_factory = controller_class or CacheController
46
+ self.controller = controller_factory(
47
+ self.cache, cache_etags=cache_etags, serializer=serializer
48
+ )
49
+
50
+ def send(
51
+ self,
52
+ request: PreparedRequest,
53
+ stream: bool = False,
54
+ timeout: None | float | tuple[float, float] | tuple[float, None] = None,
55
+ verify: bool | str = True,
56
+ cert: (None | bytes | str | tuple[bytes | str, bytes | str]) = None,
57
+ proxies: Mapping[str, str] | None = None,
58
+ cacheable_methods: Collection[str] | None = None,
59
+ ) -> Response:
60
+ """
61
+ Send a request. Use the request information to see if it
62
+ exists in the cache and cache the response if we need to and can.
63
+ """
64
+ cacheable = cacheable_methods or self.cacheable_methods
65
+ if request.method in cacheable:
66
+ try:
67
+ cached_response = self.controller.cached_request(request)
68
+ except zlib.error:
69
+ cached_response = None
70
+ if cached_response:
71
+ return self.build_response(request, cached_response, from_cache=True)
72
+
73
+ # check for etags and add headers if appropriate
74
+ request.headers.update(self.controller.conditional_headers(request))
75
+
76
+ resp = super().send(request, stream, timeout, verify, cert, proxies)
77
+
78
+ return resp
79
+
80
+ def build_response( # type: ignore[override]
81
+ self,
82
+ request: PreparedRequest,
83
+ response: HTTPResponse,
84
+ from_cache: bool = False,
85
+ cacheable_methods: Collection[str] | None = None,
86
+ ) -> Response:
87
+ """
88
+ Build a response by making a request or using the cache.
89
+
90
+ This will end up calling send and returning a potentially
91
+ cached response
92
+ """
93
+ cacheable = cacheable_methods or self.cacheable_methods
94
+ if not from_cache and request.method in cacheable:
95
+ # Check for any heuristics that might update headers
96
+ # before trying to cache.
97
+ if self.heuristic:
98
+ response = self.heuristic.apply(response)
99
+
100
+ # apply any expiration heuristics
101
+ if response.status == 304:
102
+ # We must have sent an ETag request. This could mean
103
+ # that we've been expired already or that we simply
104
+ # have an etag. In either case, we want to try and
105
+ # update the cache if that is the case.
106
+ cached_response = self.controller.update_cached_response(
107
+ request, response
108
+ )
109
+
110
+ if cached_response is not response:
111
+ from_cache = True
112
+
113
+ # We are done with the server response, read a
114
+ # possible response body (compliant servers will
115
+ # not return one, but we cannot be 100% sure) and
116
+ # release the connection back to the pool.
117
+ response.read(decode_content=False)
118
+ response.release_conn()
119
+
120
+ response = cached_response
121
+
122
+ # We always cache the 301 responses
123
+ elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
124
+ self.controller.cache_response(request, response)
125
+ else:
126
+ # Wrap the response file with a wrapper that will cache the
127
+ # response when the stream has been consumed.
128
+ response._fp = CallbackFileWrapper( # type: ignore[assignment]
129
+ response._fp, # type: ignore[arg-type]
130
+ functools.partial(
131
+ self.controller.cache_response, request, weakref.ref(response)
132
+ ),
133
+ )
134
+ if response.chunked:
135
+ super_update_chunk_length = response.__class__._update_chunk_length
136
+
137
+ def _update_chunk_length(
138
+ weak_self: weakref.ReferenceType[HTTPResponse],
139
+ ) -> None:
140
+ self = weak_self()
141
+ if self is None:
142
+ return
143
+
144
+ super_update_chunk_length(self)
145
+ if self.chunk_left == 0:
146
+ self._fp._close() # type: ignore[union-attr]
147
+
148
+ response._update_chunk_length = functools.partial( # type: ignore[method-assign]
149
+ _update_chunk_length, weakref.ref(response)
150
+ )
151
+
152
+ resp: Response = super().build_response(request, response)
153
+
154
+ # See if we should invalidate the cache.
155
+ if request.method in self.invalidating_methods and resp.ok:
156
+ assert request.url is not None
157
+ cache_url = self.controller.cache_url(request.url)
158
+ self.cache.delete(cache_url)
159
+
160
+ # Give the request a from_cache attr to let people use it
161
+ resp.from_cache = from_cache # type: ignore[attr-defined]
162
+
163
+ return resp
164
+
165
+ def close(self) -> None:
166
+ self.cache.close()
167
+ super().close() # type: ignore[no-untyped-call]
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/cache.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ The cache object API for implementing caches. The default is a thread
7
+ safe in-memory dictionary.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from threading import Lock
13
+ from typing import IO, TYPE_CHECKING, MutableMapping
14
+
15
+ if TYPE_CHECKING:
16
+ from datetime import datetime
17
+
18
+
19
+ class BaseCache:
20
+ def get(self, key: str) -> bytes | None:
21
+ raise NotImplementedError()
22
+
23
+ def set(
24
+ self, key: str, value: bytes, expires: int | datetime | None = None
25
+ ) -> None:
26
+ raise NotImplementedError()
27
+
28
+ def delete(self, key: str) -> None:
29
+ raise NotImplementedError()
30
+
31
+ def close(self) -> None:
32
+ pass
33
+
34
+
35
+ class DictCache(BaseCache):
36
+ def __init__(self, init_dict: MutableMapping[str, bytes] | None = None) -> None:
37
+ self.lock = Lock()
38
+ self.data = init_dict or {}
39
+
40
+ def get(self, key: str) -> bytes | None:
41
+ return self.data.get(key, None)
42
+
43
+ def set(
44
+ self, key: str, value: bytes, expires: int | datetime | None = None
45
+ ) -> None:
46
+ with self.lock:
47
+ self.data.update({key: value})
48
+
49
+ def delete(self, key: str) -> None:
50
+ with self.lock:
51
+ if key in self.data:
52
+ self.data.pop(key)
53
+
54
+
55
+ class SeparateBodyBaseCache(BaseCache):
56
+ """
57
+ In this variant, the body is not stored mixed in with the metadata, but is
58
+ passed in (as a bytes-like object) in a separate call to ``set_body()``.
59
+
60
+ That is, the expected interaction pattern is::
61
+
62
+ cache.set(key, serialized_metadata)
63
+ cache.set_body(key)
64
+
65
+ Similarly, the body should be loaded separately via ``get_body()``.
66
+ """
67
+
68
+ def set_body(self, key: str, body: bytes) -> None:
69
+ raise NotImplementedError()
70
+
71
+ def get_body(self, key: str) -> IO[bytes] | None:
72
+ """
73
+ Return the body as file-like object.
74
+ """
75
+ raise NotImplementedError()
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/controller.py ADDED
@@ -0,0 +1,511 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ The httplib2 algorithms ported for use with requests.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import calendar
12
+ import logging
13
+ import re
14
+ import time
15
+ import weakref
16
+ from email.utils import parsedate_tz
17
+ from typing import TYPE_CHECKING, Collection, Mapping
18
+
19
+ from pip._vendor.requests.structures import CaseInsensitiveDict
20
+
21
+ from pip._vendor.cachecontrol.cache import DictCache, SeparateBodyBaseCache
22
+ from pip._vendor.cachecontrol.serialize import Serializer
23
+
24
+ if TYPE_CHECKING:
25
+ from typing import Literal
26
+
27
+ from pip._vendor.requests import PreparedRequest
28
+ from pip._vendor.urllib3 import HTTPResponse
29
+
30
+ from pip._vendor.cachecontrol.cache import BaseCache
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+ URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
35
+
36
+ PERMANENT_REDIRECT_STATUSES = (301, 308)
37
+
38
+
39
+ def parse_uri(uri: str) -> tuple[str, str, str, str, str]:
40
+ """Parses a URI using the regex given in Appendix B of RFC 3986.
41
+
42
+ (scheme, authority, path, query, fragment) = parse_uri(uri)
43
+ """
44
+ match = URI.match(uri)
45
+ assert match is not None
46
+ groups = match.groups()
47
+ return (groups[1], groups[3], groups[4], groups[6], groups[8])
48
+
49
+
50
+ class CacheController:
51
+ """An interface to see if request should cached or not."""
52
+
53
+ def __init__(
54
+ self,
55
+ cache: BaseCache | None = None,
56
+ cache_etags: bool = True,
57
+ serializer: Serializer | None = None,
58
+ status_codes: Collection[int] | None = None,
59
+ ):
60
+ self.cache = DictCache() if cache is None else cache
61
+ self.cache_etags = cache_etags
62
+ self.serializer = serializer or Serializer()
63
+ self.cacheable_status_codes = status_codes or (200, 203, 300, 301, 308)
64
+
65
+ @classmethod
66
+ def _urlnorm(cls, uri: str) -> str:
67
+ """Normalize the URL to create a safe key for the cache"""
68
+ (scheme, authority, path, query, fragment) = parse_uri(uri)
69
+ if not scheme or not authority:
70
+ raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
71
+
72
+ scheme = scheme.lower()
73
+ authority = authority.lower()
74
+
75
+ if not path:
76
+ path = "/"
77
+
78
+ # Could do syntax based normalization of the URI before
79
+ # computing the digest. See Section 6.2.2 of Std 66.
80
+ request_uri = query and "?".join([path, query]) or path
81
+ defrag_uri = scheme + "://" + authority + request_uri
82
+
83
+ return defrag_uri
84
+
85
+ @classmethod
86
+ def cache_url(cls, uri: str) -> str:
87
+ return cls._urlnorm(uri)
88
+
89
+ def parse_cache_control(self, headers: Mapping[str, str]) -> dict[str, int | None]:
90
+ known_directives = {
91
+ # https://tools.ietf.org/html/rfc7234#section-5.2
92
+ "max-age": (int, True),
93
+ "max-stale": (int, False),
94
+ "min-fresh": (int, True),
95
+ "no-cache": (None, False),
96
+ "no-store": (None, False),
97
+ "no-transform": (None, False),
98
+ "only-if-cached": (None, False),
99
+ "must-revalidate": (None, False),
100
+ "public": (None, False),
101
+ "private": (None, False),
102
+ "proxy-revalidate": (None, False),
103
+ "s-maxage": (int, True),
104
+ }
105
+
106
+ cc_headers = headers.get("cache-control", headers.get("Cache-Control", ""))
107
+
108
+ retval: dict[str, int | None] = {}
109
+
110
+ for cc_directive in cc_headers.split(","):
111
+ if not cc_directive.strip():
112
+ continue
113
+
114
+ parts = cc_directive.split("=", 1)
115
+ directive = parts[0].strip()
116
+
117
+ try:
118
+ typ, required = known_directives[directive]
119
+ except KeyError:
120
+ logger.debug("Ignoring unknown cache-control directive: %s", directive)
121
+ continue
122
+
123
+ if not typ or not required:
124
+ retval[directive] = None
125
+ if typ:
126
+ try:
127
+ retval[directive] = typ(parts[1].strip())
128
+ except IndexError:
129
+ if required:
130
+ logger.debug(
131
+ "Missing value for cache-control " "directive: %s",
132
+ directive,
133
+ )
134
+ except ValueError:
135
+ logger.debug(
136
+ "Invalid value for cache-control directive " "%s, must be %s",
137
+ directive,
138
+ typ.__name__,
139
+ )
140
+
141
+ return retval
142
+
143
+ def _load_from_cache(self, request: PreparedRequest) -> HTTPResponse | None:
144
+ """
145
+ Load a cached response, or return None if it's not available.
146
+ """
147
+ # We do not support caching of partial content: so if the request contains a
148
+ # Range header then we don't want to load anything from the cache.
149
+ if "Range" in request.headers:
150
+ return None
151
+
152
+ cache_url = request.url
153
+ assert cache_url is not None
154
+ cache_data = self.cache.get(cache_url)
155
+ if cache_data is None:
156
+ logger.debug("No cache entry available")
157
+ return None
158
+
159
+ if isinstance(self.cache, SeparateBodyBaseCache):
160
+ body_file = self.cache.get_body(cache_url)
161
+ else:
162
+ body_file = None
163
+
164
+ result = self.serializer.loads(request, cache_data, body_file)
165
+ if result is None:
166
+ logger.warning("Cache entry deserialization failed, entry ignored")
167
+ return result
168
+
169
+ def cached_request(self, request: PreparedRequest) -> HTTPResponse | Literal[False]:
170
+ """
171
+ Return a cached response if it exists in the cache, otherwise
172
+ return False.
173
+ """
174
+ assert request.url is not None
175
+ cache_url = self.cache_url(request.url)
176
+ logger.debug('Looking up "%s" in the cache', cache_url)
177
+ cc = self.parse_cache_control(request.headers)
178
+
179
+ # Bail out if the request insists on fresh data
180
+ if "no-cache" in cc:
181
+ logger.debug('Request header has "no-cache", cache bypassed')
182
+ return False
183
+
184
+ if "max-age" in cc and cc["max-age"] == 0:
185
+ logger.debug('Request header has "max_age" as 0, cache bypassed')
186
+ return False
187
+
188
+ # Check whether we can load the response from the cache:
189
+ resp = self._load_from_cache(request)
190
+ if not resp:
191
+ return False
192
+
193
+ # If we have a cached permanent redirect, return it immediately. We
194
+ # don't need to test our response for other headers b/c it is
195
+ # intrinsically "cacheable" as it is Permanent.
196
+ #
197
+ # See:
198
+ # https://tools.ietf.org/html/rfc7231#section-6.4.2
199
+ #
200
+ # Client can try to refresh the value by repeating the request
201
+ # with cache busting headers as usual (ie no-cache).
202
+ if int(resp.status) in PERMANENT_REDIRECT_STATUSES:
203
+ msg = (
204
+ "Returning cached permanent redirect response "
205
+ "(ignoring date and etag information)"
206
+ )
207
+ logger.debug(msg)
208
+ return resp
209
+
210
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(resp.headers)
211
+ if not headers or "date" not in headers:
212
+ if "etag" not in headers:
213
+ # Without date or etag, the cached response can never be used
214
+ # and should be deleted.
215
+ logger.debug("Purging cached response: no date or etag")
216
+ self.cache.delete(cache_url)
217
+ logger.debug("Ignoring cached response: no date")
218
+ return False
219
+
220
+ now = time.time()
221
+ time_tuple = parsedate_tz(headers["date"])
222
+ assert time_tuple is not None
223
+ date = calendar.timegm(time_tuple[:6])
224
+ current_age = max(0, now - date)
225
+ logger.debug("Current age based on date: %i", current_age)
226
+
227
+ # TODO: There is an assumption that the result will be a
228
+ # urllib3 response object. This may not be best since we
229
+ # could probably avoid instantiating or constructing the
230
+ # response until we know we need it.
231
+ resp_cc = self.parse_cache_control(headers)
232
+
233
+ # determine freshness
234
+ freshness_lifetime = 0
235
+
236
+ # Check the max-age pragma in the cache control header
237
+ max_age = resp_cc.get("max-age")
238
+ if max_age is not None:
239
+ freshness_lifetime = max_age
240
+ logger.debug("Freshness lifetime from max-age: %i", freshness_lifetime)
241
+
242
+ # If there isn't a max-age, check for an expires header
243
+ elif "expires" in headers:
244
+ expires = parsedate_tz(headers["expires"])
245
+ if expires is not None:
246
+ expire_time = calendar.timegm(expires[:6]) - date
247
+ freshness_lifetime = max(0, expire_time)
248
+ logger.debug("Freshness lifetime from expires: %i", freshness_lifetime)
249
+
250
+ # Determine if we are setting freshness limit in the
251
+ # request. Note, this overrides what was in the response.
252
+ max_age = cc.get("max-age")
253
+ if max_age is not None:
254
+ freshness_lifetime = max_age
255
+ logger.debug(
256
+ "Freshness lifetime from request max-age: %i", freshness_lifetime
257
+ )
258
+
259
+ min_fresh = cc.get("min-fresh")
260
+ if min_fresh is not None:
261
+ # adjust our current age by our min fresh
262
+ current_age += min_fresh
263
+ logger.debug("Adjusted current age from min-fresh: %i", current_age)
264
+
265
+ # Return entry if it is fresh enough
266
+ if freshness_lifetime > current_age:
267
+ logger.debug('The response is "fresh", returning cached response')
268
+ logger.debug("%i > %i", freshness_lifetime, current_age)
269
+ return resp
270
+
271
+ # we're not fresh. If we don't have an Etag, clear it out
272
+ if "etag" not in headers:
273
+ logger.debug('The cached response is "stale" with no etag, purging')
274
+ self.cache.delete(cache_url)
275
+
276
+ # return the original handler
277
+ return False
278
+
279
+ def conditional_headers(self, request: PreparedRequest) -> dict[str, str]:
280
+ resp = self._load_from_cache(request)
281
+ new_headers = {}
282
+
283
+ if resp:
284
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(resp.headers)
285
+
286
+ if "etag" in headers:
287
+ new_headers["If-None-Match"] = headers["ETag"]
288
+
289
+ if "last-modified" in headers:
290
+ new_headers["If-Modified-Since"] = headers["Last-Modified"]
291
+
292
+ return new_headers
293
+
294
+ def _cache_set(
295
+ self,
296
+ cache_url: str,
297
+ request: PreparedRequest,
298
+ response: HTTPResponse,
299
+ body: bytes | None = None,
300
+ expires_time: int | None = None,
301
+ ) -> None:
302
+ """
303
+ Store the data in the cache.
304
+ """
305
+ if isinstance(self.cache, SeparateBodyBaseCache):
306
+ # We pass in the body separately; just put a placeholder empty
307
+ # string in the metadata.
308
+ self.cache.set(
309
+ cache_url,
310
+ self.serializer.dumps(request, response, b""),
311
+ expires=expires_time,
312
+ )
313
+ # body is None can happen when, for example, we're only updating
314
+ # headers, as is the case in update_cached_response().
315
+ if body is not None:
316
+ self.cache.set_body(cache_url, body)
317
+ else:
318
+ self.cache.set(
319
+ cache_url,
320
+ self.serializer.dumps(request, response, body),
321
+ expires=expires_time,
322
+ )
323
+
324
+ def cache_response(
325
+ self,
326
+ request: PreparedRequest,
327
+ response_or_ref: HTTPResponse | weakref.ReferenceType[HTTPResponse],
328
+ body: bytes | None = None,
329
+ status_codes: Collection[int] | None = None,
330
+ ) -> None:
331
+ """
332
+ Algorithm for caching requests.
333
+
334
+ This assumes a requests Response object.
335
+ """
336
+ if isinstance(response_or_ref, weakref.ReferenceType):
337
+ response = response_or_ref()
338
+ if response is None:
339
+ # The weakref can be None only in case the user used streamed request
340
+ # and did not consume or close it, and holds no reference to requests.Response.
341
+ # In such case, we don't want to cache the response.
342
+ return
343
+ else:
344
+ response = response_or_ref
345
+
346
+ # From httplib2: Don't cache 206's since we aren't going to
347
+ # handle byte range requests
348
+ cacheable_status_codes = status_codes or self.cacheable_status_codes
349
+ if response.status not in cacheable_status_codes:
350
+ logger.debug(
351
+ "Status code %s not in %s", response.status, cacheable_status_codes
352
+ )
353
+ return
354
+
355
+ response_headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
356
+ response.headers
357
+ )
358
+
359
+ if "date" in response_headers:
360
+ time_tuple = parsedate_tz(response_headers["date"])
361
+ assert time_tuple is not None
362
+ date = calendar.timegm(time_tuple[:6])
363
+ else:
364
+ date = 0
365
+
366
+ # If we've been given a body, our response has a Content-Length, that
367
+ # Content-Length is valid then we can check to see if the body we've
368
+ # been given matches the expected size, and if it doesn't we'll just
369
+ # skip trying to cache it.
370
+ if (
371
+ body is not None
372
+ and "content-length" in response_headers
373
+ and response_headers["content-length"].isdigit()
374
+ and int(response_headers["content-length"]) != len(body)
375
+ ):
376
+ return
377
+
378
+ cc_req = self.parse_cache_control(request.headers)
379
+ cc = self.parse_cache_control(response_headers)
380
+
381
+ assert request.url is not None
382
+ cache_url = self.cache_url(request.url)
383
+ logger.debug('Updating cache with response from "%s"', cache_url)
384
+
385
+ # Delete it from the cache if we happen to have it stored there
386
+ no_store = False
387
+ if "no-store" in cc:
388
+ no_store = True
389
+ logger.debug('Response header has "no-store"')
390
+ if "no-store" in cc_req:
391
+ no_store = True
392
+ logger.debug('Request header has "no-store"')
393
+ if no_store and self.cache.get(cache_url):
394
+ logger.debug('Purging existing cache entry to honor "no-store"')
395
+ self.cache.delete(cache_url)
396
+ if no_store:
397
+ return
398
+
399
+ # https://tools.ietf.org/html/rfc7234#section-4.1:
400
+ # A Vary header field-value of "*" always fails to match.
401
+ # Storing such a response leads to a deserialization warning
402
+ # during cache lookup and is not allowed to ever be served,
403
+ # so storing it can be avoided.
404
+ if "*" in response_headers.get("vary", ""):
405
+ logger.debug('Response header has "Vary: *"')
406
+ return
407
+
408
+ # If we've been given an etag, then keep the response
409
+ if self.cache_etags and "etag" in response_headers:
410
+ expires_time = 0
411
+ if response_headers.get("expires"):
412
+ expires = parsedate_tz(response_headers["expires"])
413
+ if expires is not None:
414
+ expires_time = calendar.timegm(expires[:6]) - date
415
+
416
+ expires_time = max(expires_time, 14 * 86400)
417
+
418
+ logger.debug(f"etag object cached for {expires_time} seconds")
419
+ logger.debug("Caching due to etag")
420
+ self._cache_set(cache_url, request, response, body, expires_time)
421
+
422
+ # Add to the cache any permanent redirects. We do this before looking
423
+ # that the Date headers.
424
+ elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
425
+ logger.debug("Caching permanent redirect")
426
+ self._cache_set(cache_url, request, response, b"")
427
+
428
+ # Add to the cache if the response headers demand it. If there
429
+ # is no date header then we can't do anything about expiring
430
+ # the cache.
431
+ elif "date" in response_headers:
432
+ time_tuple = parsedate_tz(response_headers["date"])
433
+ assert time_tuple is not None
434
+ date = calendar.timegm(time_tuple[:6])
435
+ # cache when there is a max-age > 0
436
+ max_age = cc.get("max-age")
437
+ if max_age is not None and max_age > 0:
438
+ logger.debug("Caching b/c date exists and max-age > 0")
439
+ expires_time = max_age
440
+ self._cache_set(
441
+ cache_url,
442
+ request,
443
+ response,
444
+ body,
445
+ expires_time,
446
+ )
447
+
448
+ # If the request can expire, it means we should cache it
449
+ # in the meantime.
450
+ elif "expires" in response_headers:
451
+ if response_headers["expires"]:
452
+ expires = parsedate_tz(response_headers["expires"])
453
+ if expires is not None:
454
+ expires_time = calendar.timegm(expires[:6]) - date
455
+ else:
456
+ expires_time = None
457
+
458
+ logger.debug(
459
+ "Caching b/c of expires header. expires in {} seconds".format(
460
+ expires_time
461
+ )
462
+ )
463
+ self._cache_set(
464
+ cache_url,
465
+ request,
466
+ response,
467
+ body,
468
+ expires_time,
469
+ )
470
+
471
+ def update_cached_response(
472
+ self, request: PreparedRequest, response: HTTPResponse
473
+ ) -> HTTPResponse:
474
+ """On a 304 we will get a new set of headers that we want to
475
+ update our cached value with, assuming we have one.
476
+
477
+ This should only ever be called when we've sent an ETag and
478
+ gotten a 304 as the response.
479
+ """
480
+ assert request.url is not None
481
+ cache_url = self.cache_url(request.url)
482
+ cached_response = self._load_from_cache(request)
483
+
484
+ if not cached_response:
485
+ # we didn't have a cached response
486
+ return response
487
+
488
+ # Lets update our headers with the headers from the new request:
489
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-26#section-4.1
490
+ #
491
+ # The server isn't supposed to send headers that would make
492
+ # the cached body invalid. But... just in case, we'll be sure
493
+ # to strip out ones we know that might be problematic due to
494
+ # typical assumptions.
495
+ excluded_headers = ["content-length"]
496
+
497
+ cached_response.headers.update(
498
+ {
499
+ k: v
500
+ for k, v in response.headers.items()
501
+ if k.lower() not in excluded_headers
502
+ }
503
+ )
504
+
505
+ # we want a 200 b/c we have content via the cache
506
+ cached_response.status = 200
507
+
508
+ # update our cache
509
+ self._cache_set(cache_url, request, cached_response)
510
+
511
+ return cached_response
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/filewrapper.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import mmap
7
+ from tempfile import NamedTemporaryFile
8
+ from typing import TYPE_CHECKING, Any, Callable
9
+
10
+ if TYPE_CHECKING:
11
+ from collections.abc import Buffer
12
+ from http.client import HTTPResponse
13
+
14
+
15
+ class CallbackFileWrapper:
16
+ """
17
+ Small wrapper around a fp object which will tee everything read into a
18
+ buffer, and when that file is closed it will execute a callback with the
19
+ contents of that buffer.
20
+
21
+ All attributes are proxied to the underlying file object.
22
+
23
+ This class uses members with a double underscore (__) leading prefix so as
24
+ not to accidentally shadow an attribute.
25
+
26
+ The data is stored in a temporary file until it is all available. As long
27
+ as the temporary files directory is disk-based (sometimes it's a
28
+ memory-backed-``tmpfs`` on Linux), data will be unloaded to disk if memory
29
+ pressure is high. For small files the disk usually won't be used at all,
30
+ it'll all be in the filesystem memory cache, so there should be no
31
+ performance impact.
32
+ """
33
+
34
+ def __init__(
35
+ self, fp: HTTPResponse, callback: Callable[[Buffer], None] | None
36
+ ) -> None:
37
+ self.__buf = NamedTemporaryFile("rb+", delete=True)
38
+ self.__fp = fp
39
+ self.__callback = callback
40
+
41
+ def __getattr__(self, name: str) -> Any:
42
+ # The vagaries of garbage collection means that self.__fp is
43
+ # not always set. By using __getattribute__ and the private
44
+ # name[0] allows looking up the attribute value and raising an
45
+ # AttributeError when it doesn't exist. This stop things from
46
+ # infinitely recursing calls to getattr in the case where
47
+ # self.__fp hasn't been set.
48
+ #
49
+ # [0] https://docs.python.org/2/reference/expressions.html#atom-identifiers
50
+ fp = self.__getattribute__("_CallbackFileWrapper__fp")
51
+ return getattr(fp, name)
52
+
53
+ def __is_fp_closed(self) -> bool:
54
+ try:
55
+ return self.__fp.fp is None
56
+
57
+ except AttributeError:
58
+ pass
59
+
60
+ try:
61
+ closed: bool = self.__fp.closed
62
+ return closed
63
+
64
+ except AttributeError:
65
+ pass
66
+
67
+ # We just don't cache it then.
68
+ # TODO: Add some logging here...
69
+ return False
70
+
71
+ def _close(self) -> None:
72
+ result: Buffer
73
+ if self.__callback:
74
+ if self.__buf.tell() == 0:
75
+ # Empty file:
76
+ result = b""
77
+ else:
78
+ # Return the data without actually loading it into memory,
79
+ # relying on Python's buffer API and mmap(). mmap() just gives
80
+ # a view directly into the filesystem's memory cache, so it
81
+ # doesn't result in duplicate memory use.
82
+ self.__buf.seek(0, 0)
83
+ result = memoryview(
84
+ mmap.mmap(self.__buf.fileno(), 0, access=mmap.ACCESS_READ)
85
+ )
86
+ self.__callback(result)
87
+
88
+ # We assign this to None here, because otherwise we can get into
89
+ # really tricky problems where the CPython interpreter dead locks
90
+ # because the callback is holding a reference to something which
91
+ # has a __del__ method. Setting this to None breaks the cycle
92
+ # and allows the garbage collector to do it's thing normally.
93
+ self.__callback = None
94
+
95
+ # Closing the temporary file releases memory and frees disk space.
96
+ # Important when caching big files.
97
+ self.__buf.close()
98
+
99
+ def read(self, amt: int | None = None) -> bytes:
100
+ data: bytes = self.__fp.read(amt)
101
+ if data:
102
+ # We may be dealing with b'', a sign that things are over:
103
+ # it's passed e.g. after we've already closed self.__buf.
104
+ self.__buf.write(data)
105
+ if self.__is_fp_closed():
106
+ self._close()
107
+
108
+ return data
109
+
110
+ def _safe_read(self, amt: int) -> bytes:
111
+ data: bytes = self.__fp._safe_read(amt) # type: ignore[attr-defined]
112
+ if amt == 2 and data == b"\r\n":
113
+ # urllib executes this read to toss the CRLF at the end
114
+ # of the chunk.
115
+ return data
116
+
117
+ self.__buf.write(data)
118
+ if self.__is_fp_closed():
119
+ self._close()
120
+
121
+ return data
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/heuristics.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import calendar
7
+ import time
8
+ from datetime import datetime, timedelta, timezone
9
+ from email.utils import formatdate, parsedate, parsedate_tz
10
+ from typing import TYPE_CHECKING, Any, Mapping
11
+
12
+ if TYPE_CHECKING:
13
+ from pip._vendor.urllib3 import HTTPResponse
14
+
15
+ TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT"
16
+
17
+
18
+ def expire_after(delta: timedelta, date: datetime | None = None) -> datetime:
19
+ date = date or datetime.now(timezone.utc)
20
+ return date + delta
21
+
22
+
23
+ def datetime_to_header(dt: datetime) -> str:
24
+ return formatdate(calendar.timegm(dt.timetuple()))
25
+
26
+
27
+ class BaseHeuristic:
28
+ def warning(self, response: HTTPResponse) -> str | None:
29
+ """
30
+ Return a valid 1xx warning header value describing the cache
31
+ adjustments.
32
+
33
+ The response is provided too allow warnings like 113
34
+ http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need
35
+ to explicitly say response is over 24 hours old.
36
+ """
37
+ return '110 - "Response is Stale"'
38
+
39
+ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
40
+ """Update the response headers with any new headers.
41
+
42
+ NOTE: This SHOULD always include some Warning header to
43
+ signify that the response was cached by the client, not
44
+ by way of the provided headers.
45
+ """
46
+ return {}
47
+
48
+ def apply(self, response: HTTPResponse) -> HTTPResponse:
49
+ updated_headers = self.update_headers(response)
50
+
51
+ if updated_headers:
52
+ response.headers.update(updated_headers)
53
+ warning_header_value = self.warning(response)
54
+ if warning_header_value is not None:
55
+ response.headers.update({"Warning": warning_header_value})
56
+
57
+ return response
58
+
59
+
60
+ class OneDayCache(BaseHeuristic):
61
+ """
62
+ Cache the response by providing an expires 1 day in the
63
+ future.
64
+ """
65
+
66
+ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
67
+ headers = {}
68
+
69
+ if "expires" not in response.headers:
70
+ date = parsedate(response.headers["date"])
71
+ expires = expire_after(
72
+ timedelta(days=1),
73
+ date=datetime(*date[:6], tzinfo=timezone.utc), # type: ignore[index,misc]
74
+ )
75
+ headers["expires"] = datetime_to_header(expires)
76
+ headers["cache-control"] = "public"
77
+ return headers
78
+
79
+
80
+ class ExpiresAfter(BaseHeuristic):
81
+ """
82
+ Cache **all** requests for a defined time period.
83
+ """
84
+
85
+ def __init__(self, **kw: Any) -> None:
86
+ self.delta = timedelta(**kw)
87
+
88
+ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
89
+ expires = expire_after(self.delta)
90
+ return {"expires": datetime_to_header(expires), "cache-control": "public"}
91
+
92
+ def warning(self, response: HTTPResponse) -> str | None:
93
+ tmpl = "110 - Automatically cached for %s. Response might be stale"
94
+ return tmpl % self.delta
95
+
96
+
97
+ class LastModified(BaseHeuristic):
98
+ """
99
+ If there is no Expires header already, fall back on Last-Modified
100
+ using the heuristic from
101
+ http://tools.ietf.org/html/rfc7234#section-4.2.2
102
+ to calculate a reasonable value.
103
+
104
+ Firefox also does something like this per
105
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ
106
+ http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
107
+ Unlike mozilla we limit this to 24-hr.
108
+ """
109
+
110
+ cacheable_by_default_statuses = {
111
+ 200,
112
+ 203,
113
+ 204,
114
+ 206,
115
+ 300,
116
+ 301,
117
+ 404,
118
+ 405,
119
+ 410,
120
+ 414,
121
+ 501,
122
+ }
123
+
124
+ def update_headers(self, resp: HTTPResponse) -> dict[str, str]:
125
+ headers: Mapping[str, str] = resp.headers
126
+
127
+ if "expires" in headers:
128
+ return {}
129
+
130
+ if "cache-control" in headers and headers["cache-control"] != "public":
131
+ return {}
132
+
133
+ if resp.status not in self.cacheable_by_default_statuses:
134
+ return {}
135
+
136
+ if "date" not in headers or "last-modified" not in headers:
137
+ return {}
138
+
139
+ time_tuple = parsedate_tz(headers["date"])
140
+ assert time_tuple is not None
141
+ date = calendar.timegm(time_tuple[:6])
142
+ last_modified = parsedate(headers["last-modified"])
143
+ if last_modified is None:
144
+ return {}
145
+
146
+ now = time.time()
147
+ current_age = max(0, now - date)
148
+ delta = date - calendar.timegm(last_modified)
149
+ freshness_lifetime = max(0, min(delta / 10, 24 * 3600))
150
+ if freshness_lifetime <= current_age:
151
+ return {}
152
+
153
+ expires = date + freshness_lifetime
154
+ return {"expires": time.strftime(TIME_FMT, time.gmtime(expires))}
155
+
156
+ def warning(self, resp: HTTPResponse) -> str | None:
157
+ return None
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/py.typed ADDED
File without changes
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/serialize.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import io
7
+ from typing import IO, TYPE_CHECKING, Any, Mapping, cast
8
+
9
+ from pip._vendor import msgpack
10
+ from pip._vendor.requests.structures import CaseInsensitiveDict
11
+ from pip._vendor.urllib3 import HTTPResponse
12
+
13
+ if TYPE_CHECKING:
14
+ from pip._vendor.requests import PreparedRequest
15
+
16
+
17
+ class Serializer:
18
+ serde_version = "4"
19
+
20
+ def dumps(
21
+ self,
22
+ request: PreparedRequest,
23
+ response: HTTPResponse,
24
+ body: bytes | None = None,
25
+ ) -> bytes:
26
+ response_headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
27
+ response.headers
28
+ )
29
+
30
+ if body is None:
31
+ # When a body isn't passed in, we'll read the response. We
32
+ # also update the response with a new file handler to be
33
+ # sure it acts as though it was never read.
34
+ body = response.read(decode_content=False)
35
+ response._fp = io.BytesIO(body) # type: ignore[assignment]
36
+ response.length_remaining = len(body)
37
+
38
+ data = {
39
+ "response": {
40
+ "body": body, # Empty bytestring if body is stored separately
41
+ "headers": {str(k): str(v) for k, v in response.headers.items()},
42
+ "status": response.status,
43
+ "version": response.version,
44
+ "reason": str(response.reason),
45
+ "decode_content": response.decode_content,
46
+ }
47
+ }
48
+
49
+ # Construct our vary headers
50
+ data["vary"] = {}
51
+ if "vary" in response_headers:
52
+ varied_headers = response_headers["vary"].split(",")
53
+ for header in varied_headers:
54
+ header = str(header).strip()
55
+ header_value = request.headers.get(header, None)
56
+ if header_value is not None:
57
+ header_value = str(header_value)
58
+ data["vary"][header] = header_value
59
+
60
+ return b",".join([f"cc={self.serde_version}".encode(), self.serialize(data)])
61
+
62
+ def serialize(self, data: dict[str, Any]) -> bytes:
63
+ return cast(bytes, msgpack.dumps(data, use_bin_type=True))
64
+
65
+ def loads(
66
+ self,
67
+ request: PreparedRequest,
68
+ data: bytes,
69
+ body_file: IO[bytes] | None = None,
70
+ ) -> HTTPResponse | None:
71
+ # Short circuit if we've been given an empty set of data
72
+ if not data:
73
+ return None
74
+
75
+ # Previous versions of this library supported other serialization
76
+ # formats, but these have all been removed.
77
+ if not data.startswith(f"cc={self.serde_version},".encode()):
78
+ return None
79
+
80
+ data = data[5:]
81
+ return self._loads_v4(request, data, body_file)
82
+
83
+ def prepare_response(
84
+ self,
85
+ request: PreparedRequest,
86
+ cached: Mapping[str, Any],
87
+ body_file: IO[bytes] | None = None,
88
+ ) -> HTTPResponse | None:
89
+ """Verify our vary headers match and construct a real urllib3
90
+ HTTPResponse object.
91
+ """
92
+ # Special case the '*' Vary value as it means we cannot actually
93
+ # determine if the cached response is suitable for this request.
94
+ # This case is also handled in the controller code when creating
95
+ # a cache entry, but is left here for backwards compatibility.
96
+ if "*" in cached.get("vary", {}):
97
+ return None
98
+
99
+ # Ensure that the Vary headers for the cached response match our
100
+ # request
101
+ for header, value in cached.get("vary", {}).items():
102
+ if request.headers.get(header, None) != value:
103
+ return None
104
+
105
+ body_raw = cached["response"].pop("body")
106
+
107
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
108
+ data=cached["response"]["headers"]
109
+ )
110
+ if headers.get("transfer-encoding", "") == "chunked":
111
+ headers.pop("transfer-encoding")
112
+
113
+ cached["response"]["headers"] = headers
114
+
115
+ try:
116
+ body: IO[bytes]
117
+ if body_file is None:
118
+ body = io.BytesIO(body_raw)
119
+ else:
120
+ body = body_file
121
+ except TypeError:
122
+ # This can happen if cachecontrol serialized to v1 format (pickle)
123
+ # using Python 2. A Python 2 str(byte string) will be unpickled as
124
+ # a Python 3 str (unicode string), which will cause the above to
125
+ # fail with:
126
+ #
127
+ # TypeError: 'str' does not support the buffer interface
128
+ body = io.BytesIO(body_raw.encode("utf8"))
129
+
130
+ # Discard any `strict` parameter serialized by older version of cachecontrol.
131
+ cached["response"].pop("strict", None)
132
+
133
+ return HTTPResponse(body=body, preload_content=False, **cached["response"])
134
+
135
+ def _loads_v4(
136
+ self,
137
+ request: PreparedRequest,
138
+ data: bytes,
139
+ body_file: IO[bytes] | None = None,
140
+ ) -> HTTPResponse | None:
141
+ try:
142
+ cached = msgpack.loads(data, raw=False)
143
+ except ValueError:
144
+ return None
145
+
146
+ return self.prepare_response(request, cached, body_file)
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/cachecontrol/wrapper.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ from typing import TYPE_CHECKING, Collection
7
+
8
+ from pip._vendor.cachecontrol.adapter import CacheControlAdapter
9
+ from pip._vendor.cachecontrol.cache import DictCache
10
+
11
+ if TYPE_CHECKING:
12
+ from pip._vendor import requests
13
+
14
+ from pip._vendor.cachecontrol.cache import BaseCache
15
+ from pip._vendor.cachecontrol.controller import CacheController
16
+ from pip._vendor.cachecontrol.heuristics import BaseHeuristic
17
+ from pip._vendor.cachecontrol.serialize import Serializer
18
+
19
+
20
+ def CacheControl(
21
+ sess: requests.Session,
22
+ cache: BaseCache | None = None,
23
+ cache_etags: bool = True,
24
+ serializer: Serializer | None = None,
25
+ heuristic: BaseHeuristic | None = None,
26
+ controller_class: type[CacheController] | None = None,
27
+ adapter_class: type[CacheControlAdapter] | None = None,
28
+ cacheable_methods: Collection[str] | None = None,
29
+ ) -> requests.Session:
30
+ cache = DictCache() if cache is None else cache
31
+ adapter_class = adapter_class or CacheControlAdapter
32
+ adapter = adapter_class(
33
+ cache,
34
+ cache_etags=cache_etags,
35
+ serializer=serializer,
36
+ heuristic=heuristic,
37
+ controller_class=controller_class,
38
+ cacheable_methods=cacheable_methods,
39
+ )
40
+ sess.mount("http://", adapter)
41
+ sess.mount("https://", adapter)
42
+
43
+ return sess
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/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.
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/__init__.py ADDED
@@ -0,0 +1,631 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Utilities for determining application-specific dirs.
3
+
4
+ See <https://github.com/platformdirs/platformdirs> for details and usage.
5
+
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import os
11
+ import sys
12
+ from typing import TYPE_CHECKING
13
+
14
+ from .api import PlatformDirsABC
15
+ from .version import __version__
16
+ from .version import __version_tuple__ as __version_info__
17
+
18
+ if TYPE_CHECKING:
19
+ from pathlib import Path
20
+ from typing import Literal
21
+
22
+ if sys.platform == "win32":
23
+ from pip._vendor.platformdirs.windows import Windows as _Result
24
+ elif sys.platform == "darwin":
25
+ from pip._vendor.platformdirs.macos import MacOS as _Result
26
+ else:
27
+ from pip._vendor.platformdirs.unix import Unix as _Result
28
+
29
+
30
+ def _set_platform_dir_class() -> type[PlatformDirsABC]:
31
+ if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system":
32
+ if os.getenv("SHELL") or os.getenv("PREFIX"):
33
+ return _Result
34
+
35
+ from pip._vendor.platformdirs.android import _android_folder # noqa: PLC0415
36
+
37
+ if _android_folder() is not None:
38
+ from pip._vendor.platformdirs.android import Android # noqa: PLC0415
39
+
40
+ return Android # return to avoid redefinition of a result
41
+
42
+ return _Result
43
+
44
+
45
+ if TYPE_CHECKING:
46
+ # Work around mypy issue: https://github.com/python/mypy/issues/10962
47
+ PlatformDirs = _Result
48
+ else:
49
+ PlatformDirs = _set_platform_dir_class() #: Currently active platform
50
+ AppDirs = PlatformDirs #: Backwards compatibility with appdirs
51
+
52
+
53
+ def user_data_dir(
54
+ appname: str | None = None,
55
+ appauthor: str | Literal[False] | None = None,
56
+ version: str | None = None,
57
+ roaming: bool = False, # noqa: FBT001, FBT002
58
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
59
+ ) -> str:
60
+ """
61
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
62
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
63
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
64
+ :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
65
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
66
+ :returns: data directory tied to the user
67
+ """
68
+ return PlatformDirs(
69
+ appname=appname,
70
+ appauthor=appauthor,
71
+ version=version,
72
+ roaming=roaming,
73
+ ensure_exists=ensure_exists,
74
+ ).user_data_dir
75
+
76
+
77
+ def site_data_dir(
78
+ appname: str | None = None,
79
+ appauthor: str | Literal[False] | None = None,
80
+ version: str | None = None,
81
+ multipath: bool = False, # noqa: FBT001, FBT002
82
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
83
+ ) -> str:
84
+ """
85
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
86
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
87
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
88
+ :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
89
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
90
+ :returns: data directory shared by users
91
+ """
92
+ return PlatformDirs(
93
+ appname=appname,
94
+ appauthor=appauthor,
95
+ version=version,
96
+ multipath=multipath,
97
+ ensure_exists=ensure_exists,
98
+ ).site_data_dir
99
+
100
+
101
+ def user_config_dir(
102
+ appname: str | None = None,
103
+ appauthor: str | Literal[False] | None = None,
104
+ version: str | None = None,
105
+ roaming: bool = False, # noqa: FBT001, FBT002
106
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
107
+ ) -> str:
108
+ """
109
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
110
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
111
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
112
+ :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
113
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
114
+ :returns: config directory tied to the user
115
+ """
116
+ return PlatformDirs(
117
+ appname=appname,
118
+ appauthor=appauthor,
119
+ version=version,
120
+ roaming=roaming,
121
+ ensure_exists=ensure_exists,
122
+ ).user_config_dir
123
+
124
+
125
+ def site_config_dir(
126
+ appname: str | None = None,
127
+ appauthor: str | Literal[False] | None = None,
128
+ version: str | None = None,
129
+ multipath: bool = False, # noqa: FBT001, FBT002
130
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
131
+ ) -> str:
132
+ """
133
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
134
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
135
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
136
+ :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
137
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
138
+ :returns: config directory shared by the users
139
+ """
140
+ return PlatformDirs(
141
+ appname=appname,
142
+ appauthor=appauthor,
143
+ version=version,
144
+ multipath=multipath,
145
+ ensure_exists=ensure_exists,
146
+ ).site_config_dir
147
+
148
+
149
+ def user_cache_dir(
150
+ appname: str | None = None,
151
+ appauthor: str | Literal[False] | None = None,
152
+ version: str | None = None,
153
+ opinion: bool = True, # noqa: FBT001, FBT002
154
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
155
+ ) -> str:
156
+ """
157
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
158
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
159
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
160
+ :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
161
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
162
+ :returns: cache directory tied to the user
163
+ """
164
+ return PlatformDirs(
165
+ appname=appname,
166
+ appauthor=appauthor,
167
+ version=version,
168
+ opinion=opinion,
169
+ ensure_exists=ensure_exists,
170
+ ).user_cache_dir
171
+
172
+
173
+ def site_cache_dir(
174
+ appname: str | None = None,
175
+ appauthor: str | Literal[False] | None = None,
176
+ version: str | None = None,
177
+ opinion: bool = True, # noqa: FBT001, FBT002
178
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
179
+ ) -> str:
180
+ """
181
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
182
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
183
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
184
+ :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
185
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
186
+ :returns: cache directory tied to the user
187
+ """
188
+ return PlatformDirs(
189
+ appname=appname,
190
+ appauthor=appauthor,
191
+ version=version,
192
+ opinion=opinion,
193
+ ensure_exists=ensure_exists,
194
+ ).site_cache_dir
195
+
196
+
197
+ def user_state_dir(
198
+ appname: str | None = None,
199
+ appauthor: str | Literal[False] | None = None,
200
+ version: str | None = None,
201
+ roaming: bool = False, # noqa: FBT001, FBT002
202
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
203
+ ) -> str:
204
+ """
205
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
206
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
207
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
208
+ :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
209
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
210
+ :returns: state directory tied to the user
211
+ """
212
+ return PlatformDirs(
213
+ appname=appname,
214
+ appauthor=appauthor,
215
+ version=version,
216
+ roaming=roaming,
217
+ ensure_exists=ensure_exists,
218
+ ).user_state_dir
219
+
220
+
221
+ def user_log_dir(
222
+ appname: str | None = None,
223
+ appauthor: str | Literal[False] | None = None,
224
+ version: str | None = None,
225
+ opinion: bool = True, # noqa: FBT001, FBT002
226
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
227
+ ) -> str:
228
+ """
229
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
230
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
231
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
232
+ :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
233
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
234
+ :returns: log directory tied to the user
235
+ """
236
+ return PlatformDirs(
237
+ appname=appname,
238
+ appauthor=appauthor,
239
+ version=version,
240
+ opinion=opinion,
241
+ ensure_exists=ensure_exists,
242
+ ).user_log_dir
243
+
244
+
245
+ def user_documents_dir() -> str:
246
+ """:returns: documents directory tied to the user"""
247
+ return PlatformDirs().user_documents_dir
248
+
249
+
250
+ def user_downloads_dir() -> str:
251
+ """:returns: downloads directory tied to the user"""
252
+ return PlatformDirs().user_downloads_dir
253
+
254
+
255
+ def user_pictures_dir() -> str:
256
+ """:returns: pictures directory tied to the user"""
257
+ return PlatformDirs().user_pictures_dir
258
+
259
+
260
+ def user_videos_dir() -> str:
261
+ """:returns: videos directory tied to the user"""
262
+ return PlatformDirs().user_videos_dir
263
+
264
+
265
+ def user_music_dir() -> str:
266
+ """:returns: music directory tied to the user"""
267
+ return PlatformDirs().user_music_dir
268
+
269
+
270
+ def user_desktop_dir() -> str:
271
+ """:returns: desktop directory tied to the user"""
272
+ return PlatformDirs().user_desktop_dir
273
+
274
+
275
+ def user_runtime_dir(
276
+ appname: str | None = None,
277
+ appauthor: str | Literal[False] | None = None,
278
+ version: str | None = None,
279
+ opinion: bool = True, # noqa: FBT001, FBT002
280
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
281
+ ) -> str:
282
+ """
283
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
284
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
285
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
286
+ :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
287
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
288
+ :returns: runtime directory tied to the user
289
+ """
290
+ return PlatformDirs(
291
+ appname=appname,
292
+ appauthor=appauthor,
293
+ version=version,
294
+ opinion=opinion,
295
+ ensure_exists=ensure_exists,
296
+ ).user_runtime_dir
297
+
298
+
299
+ def site_runtime_dir(
300
+ appname: str | None = None,
301
+ appauthor: str | Literal[False] | None = None,
302
+ version: str | None = None,
303
+ opinion: bool = True, # noqa: FBT001, FBT002
304
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
305
+ ) -> str:
306
+ """
307
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
308
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
309
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
310
+ :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
311
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
312
+ :returns: runtime directory shared by users
313
+ """
314
+ return PlatformDirs(
315
+ appname=appname,
316
+ appauthor=appauthor,
317
+ version=version,
318
+ opinion=opinion,
319
+ ensure_exists=ensure_exists,
320
+ ).site_runtime_dir
321
+
322
+
323
+ def user_data_path(
324
+ appname: str | None = None,
325
+ appauthor: str | Literal[False] | None = None,
326
+ version: str | None = None,
327
+ roaming: bool = False, # noqa: FBT001, FBT002
328
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
329
+ ) -> Path:
330
+ """
331
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
332
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
333
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
334
+ :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
335
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
336
+ :returns: data path tied to the user
337
+ """
338
+ return PlatformDirs(
339
+ appname=appname,
340
+ appauthor=appauthor,
341
+ version=version,
342
+ roaming=roaming,
343
+ ensure_exists=ensure_exists,
344
+ ).user_data_path
345
+
346
+
347
+ def site_data_path(
348
+ appname: str | None = None,
349
+ appauthor: str | Literal[False] | None = None,
350
+ version: str | None = None,
351
+ multipath: bool = False, # noqa: FBT001, FBT002
352
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
353
+ ) -> Path:
354
+ """
355
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
356
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
357
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
358
+ :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
359
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
360
+ :returns: data path shared by users
361
+ """
362
+ return PlatformDirs(
363
+ appname=appname,
364
+ appauthor=appauthor,
365
+ version=version,
366
+ multipath=multipath,
367
+ ensure_exists=ensure_exists,
368
+ ).site_data_path
369
+
370
+
371
+ def user_config_path(
372
+ appname: str | None = None,
373
+ appauthor: str | Literal[False] | None = None,
374
+ version: str | None = None,
375
+ roaming: bool = False, # noqa: FBT001, FBT002
376
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
377
+ ) -> Path:
378
+ """
379
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
380
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
381
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
382
+ :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
383
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
384
+ :returns: config path tied to the user
385
+ """
386
+ return PlatformDirs(
387
+ appname=appname,
388
+ appauthor=appauthor,
389
+ version=version,
390
+ roaming=roaming,
391
+ ensure_exists=ensure_exists,
392
+ ).user_config_path
393
+
394
+
395
+ def site_config_path(
396
+ appname: str | None = None,
397
+ appauthor: str | Literal[False] | None = None,
398
+ version: str | None = None,
399
+ multipath: bool = False, # noqa: FBT001, FBT002
400
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
401
+ ) -> Path:
402
+ """
403
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
404
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
405
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
406
+ :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
407
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
408
+ :returns: config path shared by the users
409
+ """
410
+ return PlatformDirs(
411
+ appname=appname,
412
+ appauthor=appauthor,
413
+ version=version,
414
+ multipath=multipath,
415
+ ensure_exists=ensure_exists,
416
+ ).site_config_path
417
+
418
+
419
+ def site_cache_path(
420
+ appname: str | None = None,
421
+ appauthor: str | Literal[False] | None = None,
422
+ version: str | None = None,
423
+ opinion: bool = True, # noqa: FBT001, FBT002
424
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
425
+ ) -> Path:
426
+ """
427
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
428
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
429
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
430
+ :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
431
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
432
+ :returns: cache directory tied to the user
433
+ """
434
+ return PlatformDirs(
435
+ appname=appname,
436
+ appauthor=appauthor,
437
+ version=version,
438
+ opinion=opinion,
439
+ ensure_exists=ensure_exists,
440
+ ).site_cache_path
441
+
442
+
443
+ def user_cache_path(
444
+ appname: str | None = None,
445
+ appauthor: str | Literal[False] | None = None,
446
+ version: str | None = None,
447
+ opinion: bool = True, # noqa: FBT001, FBT002
448
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
449
+ ) -> Path:
450
+ """
451
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
452
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
453
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
454
+ :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
455
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
456
+ :returns: cache path tied to the user
457
+ """
458
+ return PlatformDirs(
459
+ appname=appname,
460
+ appauthor=appauthor,
461
+ version=version,
462
+ opinion=opinion,
463
+ ensure_exists=ensure_exists,
464
+ ).user_cache_path
465
+
466
+
467
+ def user_state_path(
468
+ appname: str | None = None,
469
+ appauthor: str | Literal[False] | None = None,
470
+ version: str | None = None,
471
+ roaming: bool = False, # noqa: FBT001, FBT002
472
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
473
+ ) -> Path:
474
+ """
475
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
476
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
477
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
478
+ :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
479
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
480
+ :returns: state path tied to the user
481
+ """
482
+ return PlatformDirs(
483
+ appname=appname,
484
+ appauthor=appauthor,
485
+ version=version,
486
+ roaming=roaming,
487
+ ensure_exists=ensure_exists,
488
+ ).user_state_path
489
+
490
+
491
+ def user_log_path(
492
+ appname: str | None = None,
493
+ appauthor: str | Literal[False] | None = None,
494
+ version: str | None = None,
495
+ opinion: bool = True, # noqa: FBT001, FBT002
496
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
497
+ ) -> Path:
498
+ """
499
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
500
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
501
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
502
+ :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
503
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
504
+ :returns: log path tied to the user
505
+ """
506
+ return PlatformDirs(
507
+ appname=appname,
508
+ appauthor=appauthor,
509
+ version=version,
510
+ opinion=opinion,
511
+ ensure_exists=ensure_exists,
512
+ ).user_log_path
513
+
514
+
515
+ def user_documents_path() -> Path:
516
+ """:returns: documents a path tied to the user"""
517
+ return PlatformDirs().user_documents_path
518
+
519
+
520
+ def user_downloads_path() -> Path:
521
+ """:returns: downloads path tied to the user"""
522
+ return PlatformDirs().user_downloads_path
523
+
524
+
525
+ def user_pictures_path() -> Path:
526
+ """:returns: pictures path tied to the user"""
527
+ return PlatformDirs().user_pictures_path
528
+
529
+
530
+ def user_videos_path() -> Path:
531
+ """:returns: videos path tied to the user"""
532
+ return PlatformDirs().user_videos_path
533
+
534
+
535
+ def user_music_path() -> Path:
536
+ """:returns: music path tied to the user"""
537
+ return PlatformDirs().user_music_path
538
+
539
+
540
+ def user_desktop_path() -> Path:
541
+ """:returns: desktop path tied to the user"""
542
+ return PlatformDirs().user_desktop_path
543
+
544
+
545
+ def user_runtime_path(
546
+ appname: str | None = None,
547
+ appauthor: str | Literal[False] | None = None,
548
+ version: str | None = None,
549
+ opinion: bool = True, # noqa: FBT001, FBT002
550
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
551
+ ) -> Path:
552
+ """
553
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
554
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
555
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
556
+ :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
557
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
558
+ :returns: runtime path tied to the user
559
+ """
560
+ return PlatformDirs(
561
+ appname=appname,
562
+ appauthor=appauthor,
563
+ version=version,
564
+ opinion=opinion,
565
+ ensure_exists=ensure_exists,
566
+ ).user_runtime_path
567
+
568
+
569
+ def site_runtime_path(
570
+ appname: str | None = None,
571
+ appauthor: str | Literal[False] | None = None,
572
+ version: str | None = None,
573
+ opinion: bool = True, # noqa: FBT001, FBT002
574
+ ensure_exists: bool = False, # noqa: FBT001, FBT002
575
+ ) -> Path:
576
+ """
577
+ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
578
+ :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
579
+ :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
580
+ :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
581
+ :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
582
+ :returns: runtime path shared by users
583
+ """
584
+ return PlatformDirs(
585
+ appname=appname,
586
+ appauthor=appauthor,
587
+ version=version,
588
+ opinion=opinion,
589
+ ensure_exists=ensure_exists,
590
+ ).site_runtime_path
591
+
592
+
593
+ __all__ = [
594
+ "AppDirs",
595
+ "PlatformDirs",
596
+ "PlatformDirsABC",
597
+ "__version__",
598
+ "__version_info__",
599
+ "site_cache_dir",
600
+ "site_cache_path",
601
+ "site_config_dir",
602
+ "site_config_path",
603
+ "site_data_dir",
604
+ "site_data_path",
605
+ "site_runtime_dir",
606
+ "site_runtime_path",
607
+ "user_cache_dir",
608
+ "user_cache_path",
609
+ "user_config_dir",
610
+ "user_config_path",
611
+ "user_data_dir",
612
+ "user_data_path",
613
+ "user_desktop_dir",
614
+ "user_desktop_path",
615
+ "user_documents_dir",
616
+ "user_documents_path",
617
+ "user_downloads_dir",
618
+ "user_downloads_path",
619
+ "user_log_dir",
620
+ "user_log_path",
621
+ "user_music_dir",
622
+ "user_music_path",
623
+ "user_pictures_dir",
624
+ "user_pictures_path",
625
+ "user_runtime_dir",
626
+ "user_runtime_path",
627
+ "user_state_dir",
628
+ "user_state_path",
629
+ "user_videos_dir",
630
+ "user_videos_path",
631
+ ]
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/__main__.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Main entry point."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pip._vendor.platformdirs import PlatformDirs, __version__
6
+
7
+ PROPS = (
8
+ "user_data_dir",
9
+ "user_config_dir",
10
+ "user_cache_dir",
11
+ "user_state_dir",
12
+ "user_log_dir",
13
+ "user_documents_dir",
14
+ "user_downloads_dir",
15
+ "user_pictures_dir",
16
+ "user_videos_dir",
17
+ "user_music_dir",
18
+ "user_runtime_dir",
19
+ "site_data_dir",
20
+ "site_config_dir",
21
+ "site_cache_dir",
22
+ "site_runtime_dir",
23
+ )
24
+
25
+
26
+ def main() -> None:
27
+ """Run the main entry point."""
28
+ app_name = "MyApp"
29
+ app_author = "MyCompany"
30
+
31
+ print(f"-- platformdirs {__version__} --") # noqa: T201
32
+
33
+ print("-- app dirs (with optional 'version')") # noqa: T201
34
+ dirs = PlatformDirs(app_name, app_author, version="1.0")
35
+ for prop in PROPS:
36
+ print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
37
+
38
+ print("\n-- app dirs (without optional 'version')") # noqa: T201
39
+ dirs = PlatformDirs(app_name, app_author)
40
+ for prop in PROPS:
41
+ print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
42
+
43
+ print("\n-- app dirs (without optional 'appauthor')") # noqa: T201
44
+ dirs = PlatformDirs(app_name)
45
+ for prop in PROPS:
46
+ print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
47
+
48
+ print("\n-- app dirs (with disabled 'appauthor')") # noqa: T201
49
+ dirs = PlatformDirs(app_name, appauthor=False)
50
+ for prop in PROPS:
51
+ print(f"{prop}: {getattr(dirs, prop)}") # noqa: T201
52
+
53
+
54
+ if __name__ == "__main__":
55
+ main()
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/android.py ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Android."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import re
7
+ import sys
8
+ from functools import lru_cache
9
+ from typing import TYPE_CHECKING, cast
10
+
11
+ from .api import PlatformDirsABC
12
+
13
+
14
+ class Android(PlatformDirsABC):
15
+ """
16
+ Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_.
17
+
18
+ Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version
19
+ <platformdirs.api.PlatformDirsABC.version>`, `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
20
+
21
+ """
22
+
23
+ @property
24
+ def user_data_dir(self) -> str:
25
+ """:return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``"""
26
+ return self._append_app_name_and_version(cast("str", _android_folder()), "files")
27
+
28
+ @property
29
+ def site_data_dir(self) -> str:
30
+ """:return: data directory shared by users, same as `user_data_dir`"""
31
+ return self.user_data_dir
32
+
33
+ @property
34
+ def user_config_dir(self) -> str:
35
+ """
36
+ :return: config directory tied to the user, e.g. \
37
+ ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>``
38
+ """
39
+ return self._append_app_name_and_version(cast("str", _android_folder()), "shared_prefs")
40
+
41
+ @property
42
+ def site_config_dir(self) -> str:
43
+ """:return: config directory shared by the users, same as `user_config_dir`"""
44
+ return self.user_config_dir
45
+
46
+ @property
47
+ def user_cache_dir(self) -> str:
48
+ """:return: cache directory tied to the user, e.g.,``/data/user/<userid>/<packagename>/cache/<AppName>``"""
49
+ return self._append_app_name_and_version(cast("str", _android_folder()), "cache")
50
+
51
+ @property
52
+ def site_cache_dir(self) -> str:
53
+ """:return: cache directory shared by users, same as `user_cache_dir`"""
54
+ return self.user_cache_dir
55
+
56
+ @property
57
+ def user_state_dir(self) -> str:
58
+ """:return: state directory tied to the user, same as `user_data_dir`"""
59
+ return self.user_data_dir
60
+
61
+ @property
62
+ def user_log_dir(self) -> str:
63
+ """
64
+ :return: log directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it,
65
+ e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log``
66
+ """
67
+ path = self.user_cache_dir
68
+ if self.opinion:
69
+ path = os.path.join(path, "log") # noqa: PTH118
70
+ return path
71
+
72
+ @property
73
+ def user_documents_dir(self) -> str:
74
+ """:return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``"""
75
+ return _android_documents_folder()
76
+
77
+ @property
78
+ def user_downloads_dir(self) -> str:
79
+ """:return: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``"""
80
+ return _android_downloads_folder()
81
+
82
+ @property
83
+ def user_pictures_dir(self) -> str:
84
+ """:return: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``"""
85
+ return _android_pictures_folder()
86
+
87
+ @property
88
+ def user_videos_dir(self) -> str:
89
+ """:return: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``"""
90
+ return _android_videos_folder()
91
+
92
+ @property
93
+ def user_music_dir(self) -> str:
94
+ """:return: music directory tied to the user e.g. ``/storage/emulated/0/Music``"""
95
+ return _android_music_folder()
96
+
97
+ @property
98
+ def user_desktop_dir(self) -> str:
99
+ """:return: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``"""
100
+ return "/storage/emulated/0/Desktop"
101
+
102
+ @property
103
+ def user_runtime_dir(self) -> str:
104
+ """
105
+ :return: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it,
106
+ e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp``
107
+ """
108
+ path = self.user_cache_dir
109
+ if self.opinion:
110
+ path = os.path.join(path, "tmp") # noqa: PTH118
111
+ return path
112
+
113
+ @property
114
+ def site_runtime_dir(self) -> str:
115
+ """:return: runtime directory shared by users, same as `user_runtime_dir`"""
116
+ return self.user_runtime_dir
117
+
118
+
119
+ @lru_cache(maxsize=1)
120
+ def _android_folder() -> str | None: # noqa: C901
121
+ """:return: base folder for the Android OS or None if it cannot be found"""
122
+ result: str | None = None
123
+ # type checker isn't happy with our "import android", just don't do this when type checking see
124
+ # https://stackoverflow.com/a/61394121
125
+ if not TYPE_CHECKING:
126
+ try:
127
+ # First try to get a path to android app using python4android (if available)...
128
+ from android import mActivity # noqa: PLC0415
129
+
130
+ context = cast("android.content.Context", mActivity.getApplicationContext()) # noqa: F821
131
+ result = context.getFilesDir().getParentFile().getAbsolutePath()
132
+ except Exception: # noqa: BLE001
133
+ result = None
134
+ if result is None:
135
+ try:
136
+ # ...and fall back to using plain pyjnius, if python4android isn't available or doesn't deliver any useful
137
+ # result...
138
+ from jnius import autoclass # noqa: PLC0415
139
+
140
+ context = autoclass("android.content.Context")
141
+ result = context.getFilesDir().getParentFile().getAbsolutePath()
142
+ except Exception: # noqa: BLE001
143
+ result = None
144
+ if result is None:
145
+ # and if that fails, too, find an android folder looking at path on the sys.path
146
+ # warning: only works for apps installed under /data, not adopted storage etc.
147
+ pattern = re.compile(r"/data/(data|user/\d+)/(.+)/files")
148
+ for path in sys.path:
149
+ if pattern.match(path):
150
+ result = path.split("/files")[0]
151
+ break
152
+ else:
153
+ result = None
154
+ if result is None:
155
+ # one last try: find an android folder looking at path on the sys.path taking adopted storage paths into
156
+ # account
157
+ pattern = re.compile(r"/mnt/expand/[a-fA-F0-9-]{36}/(data|user/\d+)/(.+)/files")
158
+ for path in sys.path:
159
+ if pattern.match(path):
160
+ result = path.split("/files")[0]
161
+ break
162
+ else:
163
+ result = None
164
+ return result
165
+
166
+
167
+ @lru_cache(maxsize=1)
168
+ def _android_documents_folder() -> str:
169
+ """:return: documents folder for the Android OS"""
170
+ # Get directories with pyjnius
171
+ try:
172
+ from jnius import autoclass # noqa: PLC0415
173
+
174
+ context = autoclass("android.content.Context")
175
+ environment = autoclass("android.os.Environment")
176
+ documents_dir: str = context.getExternalFilesDir(environment.DIRECTORY_DOCUMENTS).getAbsolutePath()
177
+ except Exception: # noqa: BLE001
178
+ documents_dir = "/storage/emulated/0/Documents"
179
+
180
+ return documents_dir
181
+
182
+
183
+ @lru_cache(maxsize=1)
184
+ def _android_downloads_folder() -> str:
185
+ """:return: downloads folder for the Android OS"""
186
+ # Get directories with pyjnius
187
+ try:
188
+ from jnius import autoclass # noqa: PLC0415
189
+
190
+ context = autoclass("android.content.Context")
191
+ environment = autoclass("android.os.Environment")
192
+ downloads_dir: str = context.getExternalFilesDir(environment.DIRECTORY_DOWNLOADS).getAbsolutePath()
193
+ except Exception: # noqa: BLE001
194
+ downloads_dir = "/storage/emulated/0/Downloads"
195
+
196
+ return downloads_dir
197
+
198
+
199
+ @lru_cache(maxsize=1)
200
+ def _android_pictures_folder() -> str:
201
+ """:return: pictures folder for the Android OS"""
202
+ # Get directories with pyjnius
203
+ try:
204
+ from jnius import autoclass # noqa: PLC0415
205
+
206
+ context = autoclass("android.content.Context")
207
+ environment = autoclass("android.os.Environment")
208
+ pictures_dir: str = context.getExternalFilesDir(environment.DIRECTORY_PICTURES).getAbsolutePath()
209
+ except Exception: # noqa: BLE001
210
+ pictures_dir = "/storage/emulated/0/Pictures"
211
+
212
+ return pictures_dir
213
+
214
+
215
+ @lru_cache(maxsize=1)
216
+ def _android_videos_folder() -> str:
217
+ """:return: videos folder for the Android OS"""
218
+ # Get directories with pyjnius
219
+ try:
220
+ from jnius import autoclass # noqa: PLC0415
221
+
222
+ context = autoclass("android.content.Context")
223
+ environment = autoclass("android.os.Environment")
224
+ videos_dir: str = context.getExternalFilesDir(environment.DIRECTORY_DCIM).getAbsolutePath()
225
+ except Exception: # noqa: BLE001
226
+ videos_dir = "/storage/emulated/0/DCIM/Camera"
227
+
228
+ return videos_dir
229
+
230
+
231
+ @lru_cache(maxsize=1)
232
+ def _android_music_folder() -> str:
233
+ """:return: music folder for the Android OS"""
234
+ # Get directories with pyjnius
235
+ try:
236
+ from jnius import autoclass # noqa: PLC0415
237
+
238
+ context = autoclass("android.content.Context")
239
+ environment = autoclass("android.os.Environment")
240
+ music_dir: str = context.getExternalFilesDir(environment.DIRECTORY_MUSIC).getAbsolutePath()
241
+ except Exception: # noqa: BLE001
242
+ music_dir = "/storage/emulated/0/Music"
243
+
244
+ return music_dir
245
+
246
+
247
+ __all__ = [
248
+ "Android",
249
+ ]
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/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)
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/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
+ ]
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/py.typed ADDED
File without changes
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/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
+ ]
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/version.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '4.5.1'
32
+ __version_tuple__ = version_tuple = (4, 5, 1)
33
+
34
+ __commit_id__ = commit_id = None
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/platformdirs/windows.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ machine_names = {
192
+ "CSIDL_COMMON_APPDATA",
193
+ }
194
+ shell_folder_name = {
195
+ "CSIDL_APPDATA": "AppData",
196
+ "CSIDL_COMMON_APPDATA": "Common AppData",
197
+ "CSIDL_LOCAL_APPDATA": "Local AppData",
198
+ "CSIDL_PERSONAL": "Personal",
199
+ "CSIDL_DOWNLOADS": "{374DE290-123F-4565-9164-39C4925E467B}",
200
+ "CSIDL_MYPICTURES": "My Pictures",
201
+ "CSIDL_MYVIDEO": "My Video",
202
+ "CSIDL_MYMUSIC": "My Music",
203
+ }.get(csidl_name)
204
+ if shell_folder_name is None:
205
+ msg = f"Unknown CSIDL name: {csidl_name}"
206
+ raise ValueError(msg)
207
+ if sys.platform != "win32": # only needed for mypy type checker to know that this code runs only on Windows
208
+ raise NotImplementedError
209
+ import winreg # noqa: PLC0415
210
+
211
+ # Use HKEY_LOCAL_MACHINE for system-wide folders, HKEY_CURRENT_USER for user-specific folders
212
+ hkey = winreg.HKEY_LOCAL_MACHINE if csidl_name in machine_names else winreg.HKEY_CURRENT_USER
213
+
214
+ key = winreg.OpenKey(hkey, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
215
+ directory, _ = winreg.QueryValueEx(key, shell_folder_name)
216
+ return str(directory)
217
+
218
+
219
+ def get_win_folder_via_ctypes(csidl_name: str) -> str:
220
+ """Get folder with ctypes."""
221
+ # There is no 'CSIDL_DOWNLOADS'.
222
+ # Use 'CSIDL_PROFILE' (40) and append the default folder 'Downloads' instead.
223
+ # https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid
224
+
225
+ import ctypes # noqa: PLC0415
226
+
227
+ csidl_const = {
228
+ "CSIDL_APPDATA": 26,
229
+ "CSIDL_COMMON_APPDATA": 35,
230
+ "CSIDL_LOCAL_APPDATA": 28,
231
+ "CSIDL_PERSONAL": 5,
232
+ "CSIDL_MYPICTURES": 39,
233
+ "CSIDL_MYVIDEO": 14,
234
+ "CSIDL_MYMUSIC": 13,
235
+ "CSIDL_DOWNLOADS": 40,
236
+ "CSIDL_DESKTOPDIRECTORY": 16,
237
+ }.get(csidl_name)
238
+ if csidl_const is None:
239
+ msg = f"Unknown CSIDL name: {csidl_name}"
240
+ raise ValueError(msg)
241
+
242
+ buf = ctypes.create_unicode_buffer(1024)
243
+ windll = getattr(ctypes, "windll") # noqa: B009 # using getattr to avoid false positive with mypy type checker
244
+ windll.shell32.SHGetFolderPathW(None, csidl_const, None, 0, buf)
245
+
246
+ # Downgrade to short path name if it has high-bit chars.
247
+ if any(ord(c) > 255 for c in buf): # noqa: PLR2004
248
+ buf2 = ctypes.create_unicode_buffer(1024)
249
+ if windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
250
+ buf = buf2
251
+
252
+ if csidl_name == "CSIDL_DOWNLOADS":
253
+ return os.path.join(buf.value, "Downloads") # noqa: PTH118
254
+
255
+ return buf.value
256
+
257
+
258
+ def _pick_get_win_folder() -> Callable[[str], str]:
259
+ try:
260
+ import ctypes # noqa: PLC0415
261
+ except ImportError:
262
+ pass
263
+ else:
264
+ if hasattr(ctypes, "windll"):
265
+ return get_win_folder_via_ctypes
266
+ try:
267
+ import winreg # noqa: PLC0415, F401
268
+ except ImportError:
269
+ return get_win_folder_from_env_vars
270
+ else:
271
+ return get_win_folder_from_registry
272
+
273
+
274
+ get_win_folder = lru_cache(maxsize=None)(_pick_get_win_folder())
275
+
276
+ __all__ = [
277
+ "Windows",
278
+ ]
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/pip/_vendor/rich/__init__.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Rich text and beautiful formatting in the terminal."""
2
+
3
+ import os
4
+ from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union
5
+
6
+ from ._extension import load_ipython_extension # noqa: F401
7
+
8
+ __all__ = ["get_console", "reconfigure", "print", "inspect", "print_json"]
9
+
10
+ if TYPE_CHECKING:
11
+ from .console import Console
12
+
13
+ # Global console used by alternative print
14
+ _console: Optional["Console"] = None
15
+
16
+ try:
17
+ _IMPORT_CWD = os.path.abspath(os.getcwd())
18
+ except FileNotFoundError:
19
+ # Can happen if the cwd has been deleted
20
+ _IMPORT_CWD = ""
21
+
22
+
23
+ def get_console() -> "Console":
24
+ """Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,
25
+ and hasn't been explicitly given one.
26
+
27
+ Returns:
28
+ Console: A console instance.
29
+ """
30
+ global _console
31
+ if _console is None:
32
+ from .console import Console
33
+
34
+ _console = Console()
35
+
36
+ return _console
37
+
38
+
39
+ def reconfigure(*args: Any, **kwargs: Any) -> None:
40
+ """Reconfigures the global console by replacing it with another.
41
+
42
+ Args:
43
+ *args (Any): Positional arguments for the replacement :class:`~rich.console.Console`.
44
+ **kwargs (Any): Keyword arguments for the replacement :class:`~rich.console.Console`.
45
+ """
46
+ from pip._vendor.rich.console import Console
47
+
48
+ new_console = Console(*args, **kwargs)
49
+ _console = get_console()
50
+ _console.__dict__ = new_console.__dict__
51
+
52
+
53
+ def print(
54
+ *objects: Any,
55
+ sep: str = " ",
56
+ end: str = "\n",
57
+ file: Optional[IO[str]] = None,
58
+ flush: bool = False,
59
+ ) -> None:
60
+ r"""Print object(s) supplied via positional arguments.
61
+ This function has an identical signature to the built-in print.
62
+ For more advanced features, see the :class:`~rich.console.Console` class.
63
+
64
+ Args:
65
+ sep (str, optional): Separator between printed objects. Defaults to " ".
66
+ end (str, optional): Character to write at end of output. Defaults to "\\n".
67
+ file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
68
+ flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
69
+
70
+ """
71
+ from .console import Console
72
+
73
+ write_console = get_console() if file is None else Console(file=file)
74
+ return write_console.print(*objects, sep=sep, end=end)
75
+
76
+
77
+ def print_json(
78
+ json: Optional[str] = None,
79
+ *,
80
+ data: Any = None,
81
+ indent: Union[None, int, str] = 2,
82
+ highlight: bool = True,
83
+ skip_keys: bool = False,
84
+ ensure_ascii: bool = False,
85
+ check_circular: bool = True,
86
+ allow_nan: bool = True,
87
+ default: Optional[Callable[[Any], Any]] = None,
88
+ sort_keys: bool = False,
89
+ ) -> None:
90
+ """Pretty prints JSON. Output will be valid JSON.
91
+
92
+ Args:
93
+ json (str): A string containing JSON.
94
+ data (Any): If json is not supplied, then encode this data.
95
+ indent (int, optional): Number of spaces to indent. Defaults to 2.
96
+ highlight (bool, optional): Enable highlighting of output: Defaults to True.
97
+ skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
98
+ ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
99
+ check_circular (bool, optional): Check for circular references. Defaults to True.
100
+ allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
101
+ default (Callable, optional): A callable that converts values that can not be encoded
102
+ in to something that can be JSON encoded. Defaults to None.
103
+ sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
104
+ """
105
+
106
+ get_console().print_json(
107
+ json,
108
+ data=data,
109
+ indent=indent,
110
+ highlight=highlight,
111
+ skip_keys=skip_keys,
112
+ ensure_ascii=ensure_ascii,
113
+ check_circular=check_circular,
114
+ allow_nan=allow_nan,
115
+ default=default,
116
+ sort_keys=sort_keys,
117
+ )
118
+
119
+
120
+ def inspect(
121
+ obj: Any,
122
+ *,
123
+ console: Optional["Console"] = None,
124
+ title: Optional[str] = None,
125
+ help: bool = False,
126
+ methods: bool = False,
127
+ docs: bool = True,
128
+ private: bool = False,
129
+ dunder: bool = False,
130
+ sort: bool = True,
131
+ all: bool = False,
132
+ value: bool = True,
133
+ ) -> None:
134
+ """Inspect any Python object.
135
+
136
+ * inspect(<OBJECT>) to see summarized info.
137
+ * inspect(<OBJECT>, methods=True) to see methods.
138
+ * inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.
139
+ * inspect(<OBJECT>, private=True) to see private attributes (single underscore).
140
+ * inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.
141
+ * inspect(<OBJECT>, all=True) to see all attributes.
142
+
143
+ Args:
144
+ obj (Any): An object to inspect.
145
+ title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
146
+ help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
147
+ methods (bool, optional): Enable inspection of callables. Defaults to False.
148
+ docs (bool, optional): Also render doc strings. Defaults to True.
149
+ private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
150
+ dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
151
+ sort (bool, optional): Sort attributes alphabetically. Defaults to True.
152
+ all (bool, optional): Show all attributes. Defaults to False.
153
+ value (bool, optional): Pretty print value. Defaults to True.
154
+ """
155
+ _console = console or get_console()
156
+ from pip._vendor.rich._inspect import Inspect
157
+
158
+ # Special case for inspect(inspect)
159
+ is_inspect = obj is inspect
160
+
161
+ _inspect = Inspect(
162
+ obj,
163
+ title=title,
164
+ help=is_inspect or help,
165
+ methods=is_inspect or methods,
166
+ docs=is_inspect or docs,
167
+ private=private,
168
+ dunder=dunder,
169
+ sort=sort,
170
+ all=all,
171
+ value=value,
172
+ )
173
+ _console.print(_inspect)
174
+
175
+
176
+ if __name__ == "__main__": # pragma: no cover
177
+ print("Hello, **World**")