ZTWHHH commited on
Commit
3505a35
·
verified ·
1 Parent(s): d90a292

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. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__pycache__/controller.cpython-310.pyc +0 -0
  2. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__pycache__/serialize.cpython-310.pyc +0 -0
  3. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__pycache__/wrapper.cpython-310.pyc +0 -0
  4. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  5. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.py +161 -0
  6. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/cache.py +75 -0
  7. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +8 -0
  8. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/__init__.cpython-310.pyc +0 -0
  9. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/file_cache.cpython-310.pyc +0 -0
  10. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/redis_cache.cpython-310.pyc +0 -0
  11. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +182 -0
  12. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +48 -0
  13. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/controller.py +500 -0
  14. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/filewrapper.py +119 -0
  15. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/heuristics.py +157 -0
  16. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  17. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  18. llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  19. llava/lib/python3.10/site-packages/pip/_vendor/rich/__init__.py +177 -0
  20. llava/lib/python3.10/site-packages/pip/_vendor/rich/_cell_widths.py +454 -0
  21. llava/lib/python3.10/site-packages/pip/_vendor/rich/_emoji_codes.py +0 -0
  22. llava/lib/python3.10/site-packages/pip/_vendor/rich/_inspect.py +268 -0
  23. llava/lib/python3.10/site-packages/pip/_vendor/rich/_ratio.py +159 -0
  24. llava/lib/python3.10/site-packages/pip/_vendor/rich/_wrap.py +93 -0
  25. llava/lib/python3.10/site-packages/pip/_vendor/rich/default_styles.py +191 -0
  26. llava/lib/python3.10/site-packages/pip/_vendor/rich/status.py +131 -0
  27. llava/lib/python3.10/site-packages/pip/_vendor/rich/style.py +796 -0
  28. llava/lib/python3.10/site-packages/pip/_vendor/rich/table.py +1007 -0
  29. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Cipher/test_CAST.py +101 -0
  30. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/__init__.cpython-310.pyc +0 -0
  31. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/common.cpython-310.pyc +0 -0
  32. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_CMAC.cpython-310.pyc +0 -0
  33. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_HMAC.cpython-310.pyc +0 -0
  34. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_KMAC.cpython-310.pyc +0 -0
  35. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_KangarooTwelve.cpython-310.pyc +0 -0
  36. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_MD2.cpython-310.pyc +0 -0
  37. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_MD4.cpython-310.pyc +0 -0
  38. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_MD5.cpython-310.pyc +0 -0
  39. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_Poly1305.cpython-310.pyc +0 -0
  40. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_RIPEMD160.cpython-310.pyc +0 -0
  41. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA1.cpython-310.pyc +0 -0
  42. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA224.cpython-310.pyc +0 -0
  43. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA256.cpython-310.pyc +0 -0
  44. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA384.cpython-310.pyc +0 -0
  45. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_224.cpython-310.pyc +0 -0
  46. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_256.cpython-310.pyc +0 -0
  47. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_384.cpython-310.pyc +0 -0
  48. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_512.cpython-310.pyc +0 -0
  49. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_TupleHash.cpython-310.pyc +0 -0
  50. minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_TurboSHAKE.cpython-310.pyc +0 -0
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__pycache__/controller.cpython-310.pyc ADDED
Binary file (10.1 kB). View file
 
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__pycache__/serialize.cpython-310.pyc ADDED
Binary file (3.33 kB). View file
 
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/__pycache__/wrapper.cpython-310.pyc ADDED
Binary file (1.45 kB). View file
 
llava/lib/python3.10/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()
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 types
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, response
132
+ ),
133
+ )
134
+ if response.chunked:
135
+ super_update_chunk_length = response._update_chunk_length
136
+
137
+ def _update_chunk_length(self: HTTPResponse) -> None:
138
+ super_update_chunk_length()
139
+ if self.chunk_left == 0:
140
+ self._fp._close() # type: ignore[union-attr]
141
+
142
+ response._update_chunk_length = types.MethodType( # type: ignore[method-assign]
143
+ _update_chunk_length, response
144
+ )
145
+
146
+ resp: Response = super().build_response(request, response)
147
+
148
+ # See if we should invalidate the cache.
149
+ if request.method in self.invalidating_methods and resp.ok:
150
+ assert request.url is not None
151
+ cache_url = self.controller.cache_url(request.url)
152
+ self.cache.delete(cache_url)
153
+
154
+ # Give the request a from_cache attr to let people use it
155
+ resp.from_cache = from_cache # type: ignore[attr-defined]
156
+
157
+ return resp
158
+
159
+ def close(self) -> None:
160
+ self.cache.close()
161
+ super().close() # type: ignore[no-untyped-call]
llava/lib/python3.10/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()
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__init__.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from pip._vendor.cachecontrol.caches.file_cache import FileCache, SeparateBodyFileCache
6
+ from pip._vendor.cachecontrol.caches.redis_cache import RedisCache
7
+
8
+ __all__ = ["FileCache", "SeparateBodyFileCache", "RedisCache"]
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (404 Bytes). View file
 
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/file_cache.cpython-310.pyc ADDED
Binary file (5.62 kB). View file
 
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/redis_cache.cpython-310.pyc ADDED
Binary file (2.02 kB). View file
 
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import hashlib
7
+ import os
8
+ from textwrap import dedent
9
+ from typing import IO, TYPE_CHECKING
10
+ from pathlib import Path
11
+
12
+ from pip._vendor.cachecontrol.cache import BaseCache, SeparateBodyBaseCache
13
+ from pip._vendor.cachecontrol.controller import CacheController
14
+
15
+ if TYPE_CHECKING:
16
+ from datetime import datetime
17
+
18
+ from filelock import BaseFileLock
19
+
20
+
21
+ def _secure_open_write(filename: str, fmode: int) -> IO[bytes]:
22
+ # We only want to write to this file, so open it in write only mode
23
+ flags = os.O_WRONLY
24
+
25
+ # os.O_CREAT | os.O_EXCL will fail if the file already exists, so we only
26
+ # will open *new* files.
27
+ # We specify this because we want to ensure that the mode we pass is the
28
+ # mode of the file.
29
+ flags |= os.O_CREAT | os.O_EXCL
30
+
31
+ # Do not follow symlinks to prevent someone from making a symlink that
32
+ # we follow and insecurely open a cache file.
33
+ if hasattr(os, "O_NOFOLLOW"):
34
+ flags |= os.O_NOFOLLOW
35
+
36
+ # On Windows we'll mark this file as binary
37
+ if hasattr(os, "O_BINARY"):
38
+ flags |= os.O_BINARY
39
+
40
+ # Before we open our file, we want to delete any existing file that is
41
+ # there
42
+ try:
43
+ os.remove(filename)
44
+ except OSError:
45
+ # The file must not exist already, so we can just skip ahead to opening
46
+ pass
47
+
48
+ # Open our file, the use of os.O_CREAT | os.O_EXCL will ensure that if a
49
+ # race condition happens between the os.remove and this line, that an
50
+ # error will be raised. Because we utilize a lockfile this should only
51
+ # happen if someone is attempting to attack us.
52
+ fd = os.open(filename, flags, fmode)
53
+ try:
54
+ return os.fdopen(fd, "wb")
55
+
56
+ except:
57
+ # An error occurred wrapping our FD in a file object
58
+ os.close(fd)
59
+ raise
60
+
61
+
62
+ class _FileCacheMixin:
63
+ """Shared implementation for both FileCache variants."""
64
+
65
+ def __init__(
66
+ self,
67
+ directory: str | Path,
68
+ forever: bool = False,
69
+ filemode: int = 0o0600,
70
+ dirmode: int = 0o0700,
71
+ lock_class: type[BaseFileLock] | None = None,
72
+ ) -> None:
73
+ try:
74
+ if lock_class is None:
75
+ from filelock import FileLock
76
+
77
+ lock_class = FileLock
78
+ except ImportError:
79
+ notice = dedent(
80
+ """
81
+ NOTE: In order to use the FileCache you must have
82
+ filelock installed. You can install it via pip:
83
+ pip install cachecontrol[filecache]
84
+ """
85
+ )
86
+ raise ImportError(notice)
87
+
88
+ self.directory = directory
89
+ self.forever = forever
90
+ self.filemode = filemode
91
+ self.dirmode = dirmode
92
+ self.lock_class = lock_class
93
+
94
+ @staticmethod
95
+ def encode(x: str) -> str:
96
+ return hashlib.sha224(x.encode()).hexdigest()
97
+
98
+ def _fn(self, name: str) -> str:
99
+ # NOTE: This method should not change as some may depend on it.
100
+ # See: https://github.com/ionrock/cachecontrol/issues/63
101
+ hashed = self.encode(name)
102
+ parts = list(hashed[:5]) + [hashed]
103
+ return os.path.join(self.directory, *parts)
104
+
105
+ def get(self, key: str) -> bytes | None:
106
+ name = self._fn(key)
107
+ try:
108
+ with open(name, "rb") as fh:
109
+ return fh.read()
110
+
111
+ except FileNotFoundError:
112
+ return None
113
+
114
+ def set(
115
+ self, key: str, value: bytes, expires: int | datetime | None = None
116
+ ) -> None:
117
+ name = self._fn(key)
118
+ self._write(name, value)
119
+
120
+ def _write(self, path: str, data: bytes) -> None:
121
+ """
122
+ Safely write the data to the given path.
123
+ """
124
+ # Make sure the directory exists
125
+ try:
126
+ os.makedirs(os.path.dirname(path), self.dirmode)
127
+ except OSError:
128
+ pass
129
+
130
+ with self.lock_class(path + ".lock"):
131
+ # Write our actual file
132
+ with _secure_open_write(path, self.filemode) as fh:
133
+ fh.write(data)
134
+
135
+ def _delete(self, key: str, suffix: str) -> None:
136
+ name = self._fn(key) + suffix
137
+ if not self.forever:
138
+ try:
139
+ os.remove(name)
140
+ except FileNotFoundError:
141
+ pass
142
+
143
+
144
+ class FileCache(_FileCacheMixin, BaseCache):
145
+ """
146
+ Traditional FileCache: body is stored in memory, so not suitable for large
147
+ downloads.
148
+ """
149
+
150
+ def delete(self, key: str) -> None:
151
+ self._delete(key, "")
152
+
153
+
154
+ class SeparateBodyFileCache(_FileCacheMixin, SeparateBodyBaseCache):
155
+ """
156
+ Memory-efficient FileCache: body is stored in a separate file, reducing
157
+ peak memory usage.
158
+ """
159
+
160
+ def get_body(self, key: str) -> IO[bytes] | None:
161
+ name = self._fn(key) + ".body"
162
+ try:
163
+ return open(name, "rb")
164
+ except FileNotFoundError:
165
+ return None
166
+
167
+ def set_body(self, key: str, body: bytes) -> None:
168
+ name = self._fn(key) + ".body"
169
+ self._write(name, body)
170
+
171
+ def delete(self, key: str) -> None:
172
+ self._delete(key, "")
173
+ self._delete(key, ".body")
174
+
175
+
176
+ def url_to_file_path(url: str, filecache: FileCache) -> str:
177
+ """Return the file cache path based on the URL.
178
+
179
+ This does not ensure the file exists!
180
+ """
181
+ key = CacheController.cache_url(url)
182
+ return filecache._fn(key)
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+
7
+ from datetime import datetime, timezone
8
+ from typing import TYPE_CHECKING
9
+
10
+ from pip._vendor.cachecontrol.cache import BaseCache
11
+
12
+ if TYPE_CHECKING:
13
+ from redis import Redis
14
+
15
+
16
+ class RedisCache(BaseCache):
17
+ def __init__(self, conn: Redis[bytes]) -> None:
18
+ self.conn = conn
19
+
20
+ def get(self, key: str) -> bytes | None:
21
+ return self.conn.get(key)
22
+
23
+ def set(
24
+ self, key: str, value: bytes, expires: int | datetime | None = None
25
+ ) -> None:
26
+ if not expires:
27
+ self.conn.set(key, value)
28
+ elif isinstance(expires, datetime):
29
+ now_utc = datetime.now(timezone.utc)
30
+ if expires.tzinfo is None:
31
+ now_utc = now_utc.replace(tzinfo=None)
32
+ delta = expires - now_utc
33
+ self.conn.setex(key, int(delta.total_seconds()), value)
34
+ else:
35
+ self.conn.setex(key, expires, value)
36
+
37
+ def delete(self, key: str) -> None:
38
+ self.conn.delete(key)
39
+
40
+ def clear(self) -> None:
41
+ """Helper for clearing all the keys in a database. Use with
42
+ caution!"""
43
+ for key in self.conn.keys():
44
+ self.conn.delete(key)
45
+
46
+ def close(self) -> None:
47
+ """Redis uses connection pooling, no need to close the connection."""
48
+ pass
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/controller.py ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from email.utils import parsedate_tz
16
+ from typing import TYPE_CHECKING, Collection, Mapping
17
+
18
+ from pip._vendor.requests.structures import CaseInsensitiveDict
19
+
20
+ from pip._vendor.cachecontrol.cache import DictCache, SeparateBodyBaseCache
21
+ from pip._vendor.cachecontrol.serialize import Serializer
22
+
23
+ if TYPE_CHECKING:
24
+ from typing import Literal
25
+
26
+ from pip._vendor.requests import PreparedRequest
27
+ from pip._vendor.urllib3 import HTTPResponse
28
+
29
+ from pip._vendor.cachecontrol.cache import BaseCache
30
+
31
+ logger = logging.getLogger(__name__)
32
+
33
+ URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
34
+
35
+ PERMANENT_REDIRECT_STATUSES = (301, 308)
36
+
37
+
38
+ def parse_uri(uri: str) -> tuple[str, str, str, str, str]:
39
+ """Parses a URI using the regex given in Appendix B of RFC 3986.
40
+
41
+ (scheme, authority, path, query, fragment) = parse_uri(uri)
42
+ """
43
+ match = URI.match(uri)
44
+ assert match is not None
45
+ groups = match.groups()
46
+ return (groups[1], groups[3], groups[4], groups[6], groups[8])
47
+
48
+
49
+ class CacheController:
50
+ """An interface to see if request should cached or not."""
51
+
52
+ def __init__(
53
+ self,
54
+ cache: BaseCache | None = None,
55
+ cache_etags: bool = True,
56
+ serializer: Serializer | None = None,
57
+ status_codes: Collection[int] | None = None,
58
+ ):
59
+ self.cache = DictCache() if cache is None else cache
60
+ self.cache_etags = cache_etags
61
+ self.serializer = serializer or Serializer()
62
+ self.cacheable_status_codes = status_codes or (200, 203, 300, 301, 308)
63
+
64
+ @classmethod
65
+ def _urlnorm(cls, uri: str) -> str:
66
+ """Normalize the URL to create a safe key for the cache"""
67
+ (scheme, authority, path, query, fragment) = parse_uri(uri)
68
+ if not scheme or not authority:
69
+ raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
70
+
71
+ scheme = scheme.lower()
72
+ authority = authority.lower()
73
+
74
+ if not path:
75
+ path = "/"
76
+
77
+ # Could do syntax based normalization of the URI before
78
+ # computing the digest. See Section 6.2.2 of Std 66.
79
+ request_uri = query and "?".join([path, query]) or path
80
+ defrag_uri = scheme + "://" + authority + request_uri
81
+
82
+ return defrag_uri
83
+
84
+ @classmethod
85
+ def cache_url(cls, uri: str) -> str:
86
+ return cls._urlnorm(uri)
87
+
88
+ def parse_cache_control(self, headers: Mapping[str, str]) -> dict[str, int | None]:
89
+ known_directives = {
90
+ # https://tools.ietf.org/html/rfc7234#section-5.2
91
+ "max-age": (int, True),
92
+ "max-stale": (int, False),
93
+ "min-fresh": (int, True),
94
+ "no-cache": (None, False),
95
+ "no-store": (None, False),
96
+ "no-transform": (None, False),
97
+ "only-if-cached": (None, False),
98
+ "must-revalidate": (None, False),
99
+ "public": (None, False),
100
+ "private": (None, False),
101
+ "proxy-revalidate": (None, False),
102
+ "s-maxage": (int, True),
103
+ }
104
+
105
+ cc_headers = headers.get("cache-control", headers.get("Cache-Control", ""))
106
+
107
+ retval: dict[str, int | None] = {}
108
+
109
+ for cc_directive in cc_headers.split(","):
110
+ if not cc_directive.strip():
111
+ continue
112
+
113
+ parts = cc_directive.split("=", 1)
114
+ directive = parts[0].strip()
115
+
116
+ try:
117
+ typ, required = known_directives[directive]
118
+ except KeyError:
119
+ logger.debug("Ignoring unknown cache-control directive: %s", directive)
120
+ continue
121
+
122
+ if not typ or not required:
123
+ retval[directive] = None
124
+ if typ:
125
+ try:
126
+ retval[directive] = typ(parts[1].strip())
127
+ except IndexError:
128
+ if required:
129
+ logger.debug(
130
+ "Missing value for cache-control " "directive: %s",
131
+ directive,
132
+ )
133
+ except ValueError:
134
+ logger.debug(
135
+ "Invalid value for cache-control directive " "%s, must be %s",
136
+ directive,
137
+ typ.__name__,
138
+ )
139
+
140
+ return retval
141
+
142
+ def _load_from_cache(self, request: PreparedRequest) -> HTTPResponse | None:
143
+ """
144
+ Load a cached response, or return None if it's not available.
145
+ """
146
+ # We do not support caching of partial content: so if the request contains a
147
+ # Range header then we don't want to load anything from the cache.
148
+ if "Range" in request.headers:
149
+ return None
150
+
151
+ cache_url = request.url
152
+ assert cache_url is not None
153
+ cache_data = self.cache.get(cache_url)
154
+ if cache_data is None:
155
+ logger.debug("No cache entry available")
156
+ return None
157
+
158
+ if isinstance(self.cache, SeparateBodyBaseCache):
159
+ body_file = self.cache.get_body(cache_url)
160
+ else:
161
+ body_file = None
162
+
163
+ result = self.serializer.loads(request, cache_data, body_file)
164
+ if result is None:
165
+ logger.warning("Cache entry deserialization failed, entry ignored")
166
+ return result
167
+
168
+ def cached_request(self, request: PreparedRequest) -> HTTPResponse | Literal[False]:
169
+ """
170
+ Return a cached response if it exists in the cache, otherwise
171
+ return False.
172
+ """
173
+ assert request.url is not None
174
+ cache_url = self.cache_url(request.url)
175
+ logger.debug('Looking up "%s" in the cache', cache_url)
176
+ cc = self.parse_cache_control(request.headers)
177
+
178
+ # Bail out if the request insists on fresh data
179
+ if "no-cache" in cc:
180
+ logger.debug('Request header has "no-cache", cache bypassed')
181
+ return False
182
+
183
+ if "max-age" in cc and cc["max-age"] == 0:
184
+ logger.debug('Request header has "max_age" as 0, cache bypassed')
185
+ return False
186
+
187
+ # Check whether we can load the response from the cache:
188
+ resp = self._load_from_cache(request)
189
+ if not resp:
190
+ return False
191
+
192
+ # If we have a cached permanent redirect, return it immediately. We
193
+ # don't need to test our response for other headers b/c it is
194
+ # intrinsically "cacheable" as it is Permanent.
195
+ #
196
+ # See:
197
+ # https://tools.ietf.org/html/rfc7231#section-6.4.2
198
+ #
199
+ # Client can try to refresh the value by repeating the request
200
+ # with cache busting headers as usual (ie no-cache).
201
+ if int(resp.status) in PERMANENT_REDIRECT_STATUSES:
202
+ msg = (
203
+ "Returning cached permanent redirect response "
204
+ "(ignoring date and etag information)"
205
+ )
206
+ logger.debug(msg)
207
+ return resp
208
+
209
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(resp.headers)
210
+ if not headers or "date" not in headers:
211
+ if "etag" not in headers:
212
+ # Without date or etag, the cached response can never be used
213
+ # and should be deleted.
214
+ logger.debug("Purging cached response: no date or etag")
215
+ self.cache.delete(cache_url)
216
+ logger.debug("Ignoring cached response: no date")
217
+ return False
218
+
219
+ now = time.time()
220
+ time_tuple = parsedate_tz(headers["date"])
221
+ assert time_tuple is not None
222
+ date = calendar.timegm(time_tuple[:6])
223
+ current_age = max(0, now - date)
224
+ logger.debug("Current age based on date: %i", current_age)
225
+
226
+ # TODO: There is an assumption that the result will be a
227
+ # urllib3 response object. This may not be best since we
228
+ # could probably avoid instantiating or constructing the
229
+ # response until we know we need it.
230
+ resp_cc = self.parse_cache_control(headers)
231
+
232
+ # determine freshness
233
+ freshness_lifetime = 0
234
+
235
+ # Check the max-age pragma in the cache control header
236
+ max_age = resp_cc.get("max-age")
237
+ if max_age is not None:
238
+ freshness_lifetime = max_age
239
+ logger.debug("Freshness lifetime from max-age: %i", freshness_lifetime)
240
+
241
+ # If there isn't a max-age, check for an expires header
242
+ elif "expires" in headers:
243
+ expires = parsedate_tz(headers["expires"])
244
+ if expires is not None:
245
+ expire_time = calendar.timegm(expires[:6]) - date
246
+ freshness_lifetime = max(0, expire_time)
247
+ logger.debug("Freshness lifetime from expires: %i", freshness_lifetime)
248
+
249
+ # Determine if we are setting freshness limit in the
250
+ # request. Note, this overrides what was in the response.
251
+ max_age = cc.get("max-age")
252
+ if max_age is not None:
253
+ freshness_lifetime = max_age
254
+ logger.debug(
255
+ "Freshness lifetime from request max-age: %i", freshness_lifetime
256
+ )
257
+
258
+ min_fresh = cc.get("min-fresh")
259
+ if min_fresh is not None:
260
+ # adjust our current age by our min fresh
261
+ current_age += min_fresh
262
+ logger.debug("Adjusted current age from min-fresh: %i", current_age)
263
+
264
+ # Return entry if it is fresh enough
265
+ if freshness_lifetime > current_age:
266
+ logger.debug('The response is "fresh", returning cached response')
267
+ logger.debug("%i > %i", freshness_lifetime, current_age)
268
+ return resp
269
+
270
+ # we're not fresh. If we don't have an Etag, clear it out
271
+ if "etag" not in headers:
272
+ logger.debug('The cached response is "stale" with no etag, purging')
273
+ self.cache.delete(cache_url)
274
+
275
+ # return the original handler
276
+ return False
277
+
278
+ def conditional_headers(self, request: PreparedRequest) -> dict[str, str]:
279
+ resp = self._load_from_cache(request)
280
+ new_headers = {}
281
+
282
+ if resp:
283
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(resp.headers)
284
+
285
+ if "etag" in headers:
286
+ new_headers["If-None-Match"] = headers["ETag"]
287
+
288
+ if "last-modified" in headers:
289
+ new_headers["If-Modified-Since"] = headers["Last-Modified"]
290
+
291
+ return new_headers
292
+
293
+ def _cache_set(
294
+ self,
295
+ cache_url: str,
296
+ request: PreparedRequest,
297
+ response: HTTPResponse,
298
+ body: bytes | None = None,
299
+ expires_time: int | None = None,
300
+ ) -> None:
301
+ """
302
+ Store the data in the cache.
303
+ """
304
+ if isinstance(self.cache, SeparateBodyBaseCache):
305
+ # We pass in the body separately; just put a placeholder empty
306
+ # string in the metadata.
307
+ self.cache.set(
308
+ cache_url,
309
+ self.serializer.dumps(request, response, b""),
310
+ expires=expires_time,
311
+ )
312
+ # body is None can happen when, for example, we're only updating
313
+ # headers, as is the case in update_cached_response().
314
+ if body is not None:
315
+ self.cache.set_body(cache_url, body)
316
+ else:
317
+ self.cache.set(
318
+ cache_url,
319
+ self.serializer.dumps(request, response, body),
320
+ expires=expires_time,
321
+ )
322
+
323
+ def cache_response(
324
+ self,
325
+ request: PreparedRequest,
326
+ response: HTTPResponse,
327
+ body: bytes | None = None,
328
+ status_codes: Collection[int] | None = None,
329
+ ) -> None:
330
+ """
331
+ Algorithm for caching requests.
332
+
333
+ This assumes a requests Response object.
334
+ """
335
+ # From httplib2: Don't cache 206's since we aren't going to
336
+ # handle byte range requests
337
+ cacheable_status_codes = status_codes or self.cacheable_status_codes
338
+ if response.status not in cacheable_status_codes:
339
+ logger.debug(
340
+ "Status code %s not in %s", response.status, cacheable_status_codes
341
+ )
342
+ return
343
+
344
+ response_headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
345
+ response.headers
346
+ )
347
+
348
+ if "date" in response_headers:
349
+ time_tuple = parsedate_tz(response_headers["date"])
350
+ assert time_tuple is not None
351
+ date = calendar.timegm(time_tuple[:6])
352
+ else:
353
+ date = 0
354
+
355
+ # If we've been given a body, our response has a Content-Length, that
356
+ # Content-Length is valid then we can check to see if the body we've
357
+ # been given matches the expected size, and if it doesn't we'll just
358
+ # skip trying to cache it.
359
+ if (
360
+ body is not None
361
+ and "content-length" in response_headers
362
+ and response_headers["content-length"].isdigit()
363
+ and int(response_headers["content-length"]) != len(body)
364
+ ):
365
+ return
366
+
367
+ cc_req = self.parse_cache_control(request.headers)
368
+ cc = self.parse_cache_control(response_headers)
369
+
370
+ assert request.url is not None
371
+ cache_url = self.cache_url(request.url)
372
+ logger.debug('Updating cache with response from "%s"', cache_url)
373
+
374
+ # Delete it from the cache if we happen to have it stored there
375
+ no_store = False
376
+ if "no-store" in cc:
377
+ no_store = True
378
+ logger.debug('Response header has "no-store"')
379
+ if "no-store" in cc_req:
380
+ no_store = True
381
+ logger.debug('Request header has "no-store"')
382
+ if no_store and self.cache.get(cache_url):
383
+ logger.debug('Purging existing cache entry to honor "no-store"')
384
+ self.cache.delete(cache_url)
385
+ if no_store:
386
+ return
387
+
388
+ # https://tools.ietf.org/html/rfc7234#section-4.1:
389
+ # A Vary header field-value of "*" always fails to match.
390
+ # Storing such a response leads to a deserialization warning
391
+ # during cache lookup and is not allowed to ever be served,
392
+ # so storing it can be avoided.
393
+ if "*" in response_headers.get("vary", ""):
394
+ logger.debug('Response header has "Vary: *"')
395
+ return
396
+
397
+ # If we've been given an etag, then keep the response
398
+ if self.cache_etags and "etag" in response_headers:
399
+ expires_time = 0
400
+ if response_headers.get("expires"):
401
+ expires = parsedate_tz(response_headers["expires"])
402
+ if expires is not None:
403
+ expires_time = calendar.timegm(expires[:6]) - date
404
+
405
+ expires_time = max(expires_time, 14 * 86400)
406
+
407
+ logger.debug(f"etag object cached for {expires_time} seconds")
408
+ logger.debug("Caching due to etag")
409
+ self._cache_set(cache_url, request, response, body, expires_time)
410
+
411
+ # Add to the cache any permanent redirects. We do this before looking
412
+ # that the Date headers.
413
+ elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
414
+ logger.debug("Caching permanent redirect")
415
+ self._cache_set(cache_url, request, response, b"")
416
+
417
+ # Add to the cache if the response headers demand it. If there
418
+ # is no date header then we can't do anything about expiring
419
+ # the cache.
420
+ elif "date" in response_headers:
421
+ time_tuple = parsedate_tz(response_headers["date"])
422
+ assert time_tuple is not None
423
+ date = calendar.timegm(time_tuple[:6])
424
+ # cache when there is a max-age > 0
425
+ max_age = cc.get("max-age")
426
+ if max_age is not None and max_age > 0:
427
+ logger.debug("Caching b/c date exists and max-age > 0")
428
+ expires_time = max_age
429
+ self._cache_set(
430
+ cache_url,
431
+ request,
432
+ response,
433
+ body,
434
+ expires_time,
435
+ )
436
+
437
+ # If the request can expire, it means we should cache it
438
+ # in the meantime.
439
+ elif "expires" in response_headers:
440
+ if response_headers["expires"]:
441
+ expires = parsedate_tz(response_headers["expires"])
442
+ if expires is not None:
443
+ expires_time = calendar.timegm(expires[:6]) - date
444
+ else:
445
+ expires_time = None
446
+
447
+ logger.debug(
448
+ "Caching b/c of expires header. expires in {} seconds".format(
449
+ expires_time
450
+ )
451
+ )
452
+ self._cache_set(
453
+ cache_url,
454
+ request,
455
+ response,
456
+ body,
457
+ expires_time,
458
+ )
459
+
460
+ def update_cached_response(
461
+ self, request: PreparedRequest, response: HTTPResponse
462
+ ) -> HTTPResponse:
463
+ """On a 304 we will get a new set of headers that we want to
464
+ update our cached value with, assuming we have one.
465
+
466
+ This should only ever be called when we've sent an ETag and
467
+ gotten a 304 as the response.
468
+ """
469
+ assert request.url is not None
470
+ cache_url = self.cache_url(request.url)
471
+ cached_response = self._load_from_cache(request)
472
+
473
+ if not cached_response:
474
+ # we didn't have a cached response
475
+ return response
476
+
477
+ # Lets update our headers with the headers from the new request:
478
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-26#section-4.1
479
+ #
480
+ # The server isn't supposed to send headers that would make
481
+ # the cached body invalid. But... just in case, we'll be sure
482
+ # to strip out ones we know that might be problmatic due to
483
+ # typical assumptions.
484
+ excluded_headers = ["content-length"]
485
+
486
+ cached_response.headers.update(
487
+ {
488
+ k: v
489
+ for k, v in response.headers.items()
490
+ if k.lower() not in excluded_headers
491
+ }
492
+ )
493
+
494
+ # we want a 200 b/c we have content via the cache
495
+ cached_response.status = 200
496
+
497
+ # update our cache
498
+ self._cache_set(cache_url, request, cached_response)
499
+
500
+ return cached_response
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/filewrapper.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 http.client import HTTPResponse
12
+
13
+
14
+ class CallbackFileWrapper:
15
+ """
16
+ Small wrapper around a fp object which will tee everything read into a
17
+ buffer, and when that file is closed it will execute a callback with the
18
+ contents of that buffer.
19
+
20
+ All attributes are proxied to the underlying file object.
21
+
22
+ This class uses members with a double underscore (__) leading prefix so as
23
+ not to accidentally shadow an attribute.
24
+
25
+ The data is stored in a temporary file until it is all available. As long
26
+ as the temporary files directory is disk-based (sometimes it's a
27
+ memory-backed-``tmpfs`` on Linux), data will be unloaded to disk if memory
28
+ pressure is high. For small files the disk usually won't be used at all,
29
+ it'll all be in the filesystem memory cache, so there should be no
30
+ performance impact.
31
+ """
32
+
33
+ def __init__(
34
+ self, fp: HTTPResponse, callback: Callable[[bytes], None] | None
35
+ ) -> None:
36
+ self.__buf = NamedTemporaryFile("rb+", delete=True)
37
+ self.__fp = fp
38
+ self.__callback = callback
39
+
40
+ def __getattr__(self, name: str) -> Any:
41
+ # The vagaries of garbage collection means that self.__fp is
42
+ # not always set. By using __getattribute__ and the private
43
+ # name[0] allows looking up the attribute value and raising an
44
+ # AttributeError when it doesn't exist. This stop things from
45
+ # infinitely recursing calls to getattr in the case where
46
+ # self.__fp hasn't been set.
47
+ #
48
+ # [0] https://docs.python.org/2/reference/expressions.html#atom-identifiers
49
+ fp = self.__getattribute__("_CallbackFileWrapper__fp")
50
+ return getattr(fp, name)
51
+
52
+ def __is_fp_closed(self) -> bool:
53
+ try:
54
+ return self.__fp.fp is None
55
+
56
+ except AttributeError:
57
+ pass
58
+
59
+ try:
60
+ closed: bool = self.__fp.closed
61
+ return closed
62
+
63
+ except AttributeError:
64
+ pass
65
+
66
+ # We just don't cache it then.
67
+ # TODO: Add some logging here...
68
+ return False
69
+
70
+ def _close(self) -> None:
71
+ if self.__callback:
72
+ if self.__buf.tell() == 0:
73
+ # Empty file:
74
+ result = b""
75
+ else:
76
+ # Return the data without actually loading it into memory,
77
+ # relying on Python's buffer API and mmap(). mmap() just gives
78
+ # a view directly into the filesystem's memory cache, so it
79
+ # doesn't result in duplicate memory use.
80
+ self.__buf.seek(0, 0)
81
+ result = memoryview(
82
+ mmap.mmap(self.__buf.fileno(), 0, access=mmap.ACCESS_READ)
83
+ )
84
+ self.__callback(result)
85
+
86
+ # We assign this to None here, because otherwise we can get into
87
+ # really tricky problems where the CPython interpreter dead locks
88
+ # because the callback is holding a reference to something which
89
+ # has a __del__ method. Setting this to None breaks the cycle
90
+ # and allows the garbage collector to do it's thing normally.
91
+ self.__callback = None
92
+
93
+ # Closing the temporary file releases memory and frees disk space.
94
+ # Important when caching big files.
95
+ self.__buf.close()
96
+
97
+ def read(self, amt: int | None = None) -> bytes:
98
+ data: bytes = self.__fp.read(amt)
99
+ if data:
100
+ # We may be dealing with b'', a sign that things are over:
101
+ # it's passed e.g. after we've already closed self.__buf.
102
+ self.__buf.write(data)
103
+ if self.__is_fp_closed():
104
+ self._close()
105
+
106
+ return data
107
+
108
+ def _safe_read(self, amt: int) -> bytes:
109
+ data: bytes = self.__fp._safe_read(amt) # type: ignore[attr-defined]
110
+ if amt == 2 and data == b"\r\n":
111
+ # urllib executes this read to toss the CRLF at the end
112
+ # of the chunk.
113
+ return data
114
+
115
+ self.__buf.write(data)
116
+ if self.__is_fp_closed():
117
+ self._close()
118
+
119
+ return data
llava/lib/python3.10/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
llava/lib/python3.10/site-packages/pip/_vendor/cachecontrol/py.typed ADDED
File without changes
llava/lib/python3.10/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)
llava/lib/python3.10/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
llava/lib/python3.10/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**")
llava/lib/python3.10/site-packages/pip/_vendor/rich/_cell_widths.py ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Auto generated by make_terminal_widths.py
2
+
3
+ CELL_WIDTHS = [
4
+ (0, 0, 0),
5
+ (1, 31, -1),
6
+ (127, 159, -1),
7
+ (173, 173, 0),
8
+ (768, 879, 0),
9
+ (1155, 1161, 0),
10
+ (1425, 1469, 0),
11
+ (1471, 1471, 0),
12
+ (1473, 1474, 0),
13
+ (1476, 1477, 0),
14
+ (1479, 1479, 0),
15
+ (1536, 1541, 0),
16
+ (1552, 1562, 0),
17
+ (1564, 1564, 0),
18
+ (1611, 1631, 0),
19
+ (1648, 1648, 0),
20
+ (1750, 1757, 0),
21
+ (1759, 1764, 0),
22
+ (1767, 1768, 0),
23
+ (1770, 1773, 0),
24
+ (1807, 1807, 0),
25
+ (1809, 1809, 0),
26
+ (1840, 1866, 0),
27
+ (1958, 1968, 0),
28
+ (2027, 2035, 0),
29
+ (2045, 2045, 0),
30
+ (2070, 2073, 0),
31
+ (2075, 2083, 0),
32
+ (2085, 2087, 0),
33
+ (2089, 2093, 0),
34
+ (2137, 2139, 0),
35
+ (2192, 2193, 0),
36
+ (2200, 2207, 0),
37
+ (2250, 2307, 0),
38
+ (2362, 2364, 0),
39
+ (2366, 2383, 0),
40
+ (2385, 2391, 0),
41
+ (2402, 2403, 0),
42
+ (2433, 2435, 0),
43
+ (2492, 2492, 0),
44
+ (2494, 2500, 0),
45
+ (2503, 2504, 0),
46
+ (2507, 2509, 0),
47
+ (2519, 2519, 0),
48
+ (2530, 2531, 0),
49
+ (2558, 2558, 0),
50
+ (2561, 2563, 0),
51
+ (2620, 2620, 0),
52
+ (2622, 2626, 0),
53
+ (2631, 2632, 0),
54
+ (2635, 2637, 0),
55
+ (2641, 2641, 0),
56
+ (2672, 2673, 0),
57
+ (2677, 2677, 0),
58
+ (2689, 2691, 0),
59
+ (2748, 2748, 0),
60
+ (2750, 2757, 0),
61
+ (2759, 2761, 0),
62
+ (2763, 2765, 0),
63
+ (2786, 2787, 0),
64
+ (2810, 2815, 0),
65
+ (2817, 2819, 0),
66
+ (2876, 2876, 0),
67
+ (2878, 2884, 0),
68
+ (2887, 2888, 0),
69
+ (2891, 2893, 0),
70
+ (2901, 2903, 0),
71
+ (2914, 2915, 0),
72
+ (2946, 2946, 0),
73
+ (3006, 3010, 0),
74
+ (3014, 3016, 0),
75
+ (3018, 3021, 0),
76
+ (3031, 3031, 0),
77
+ (3072, 3076, 0),
78
+ (3132, 3132, 0),
79
+ (3134, 3140, 0),
80
+ (3142, 3144, 0),
81
+ (3146, 3149, 0),
82
+ (3157, 3158, 0),
83
+ (3170, 3171, 0),
84
+ (3201, 3203, 0),
85
+ (3260, 3260, 0),
86
+ (3262, 3268, 0),
87
+ (3270, 3272, 0),
88
+ (3274, 3277, 0),
89
+ (3285, 3286, 0),
90
+ (3298, 3299, 0),
91
+ (3315, 3315, 0),
92
+ (3328, 3331, 0),
93
+ (3387, 3388, 0),
94
+ (3390, 3396, 0),
95
+ (3398, 3400, 0),
96
+ (3402, 3405, 0),
97
+ (3415, 3415, 0),
98
+ (3426, 3427, 0),
99
+ (3457, 3459, 0),
100
+ (3530, 3530, 0),
101
+ (3535, 3540, 0),
102
+ (3542, 3542, 0),
103
+ (3544, 3551, 0),
104
+ (3570, 3571, 0),
105
+ (3633, 3633, 0),
106
+ (3636, 3642, 0),
107
+ (3655, 3662, 0),
108
+ (3761, 3761, 0),
109
+ (3764, 3772, 0),
110
+ (3784, 3790, 0),
111
+ (3864, 3865, 0),
112
+ (3893, 3893, 0),
113
+ (3895, 3895, 0),
114
+ (3897, 3897, 0),
115
+ (3902, 3903, 0),
116
+ (3953, 3972, 0),
117
+ (3974, 3975, 0),
118
+ (3981, 3991, 0),
119
+ (3993, 4028, 0),
120
+ (4038, 4038, 0),
121
+ (4139, 4158, 0),
122
+ (4182, 4185, 0),
123
+ (4190, 4192, 0),
124
+ (4194, 4196, 0),
125
+ (4199, 4205, 0),
126
+ (4209, 4212, 0),
127
+ (4226, 4237, 0),
128
+ (4239, 4239, 0),
129
+ (4250, 4253, 0),
130
+ (4352, 4447, 2),
131
+ (4448, 4607, 0),
132
+ (4957, 4959, 0),
133
+ (5906, 5909, 0),
134
+ (5938, 5940, 0),
135
+ (5970, 5971, 0),
136
+ (6002, 6003, 0),
137
+ (6068, 6099, 0),
138
+ (6109, 6109, 0),
139
+ (6155, 6159, 0),
140
+ (6277, 6278, 0),
141
+ (6313, 6313, 0),
142
+ (6432, 6443, 0),
143
+ (6448, 6459, 0),
144
+ (6679, 6683, 0),
145
+ (6741, 6750, 0),
146
+ (6752, 6780, 0),
147
+ (6783, 6783, 0),
148
+ (6832, 6862, 0),
149
+ (6912, 6916, 0),
150
+ (6964, 6980, 0),
151
+ (7019, 7027, 0),
152
+ (7040, 7042, 0),
153
+ (7073, 7085, 0),
154
+ (7142, 7155, 0),
155
+ (7204, 7223, 0),
156
+ (7376, 7378, 0),
157
+ (7380, 7400, 0),
158
+ (7405, 7405, 0),
159
+ (7412, 7412, 0),
160
+ (7415, 7417, 0),
161
+ (7616, 7679, 0),
162
+ (8203, 8207, 0),
163
+ (8232, 8238, 0),
164
+ (8288, 8292, 0),
165
+ (8294, 8303, 0),
166
+ (8400, 8432, 0),
167
+ (8986, 8987, 2),
168
+ (9001, 9002, 2),
169
+ (9193, 9196, 2),
170
+ (9200, 9200, 2),
171
+ (9203, 9203, 2),
172
+ (9725, 9726, 2),
173
+ (9748, 9749, 2),
174
+ (9800, 9811, 2),
175
+ (9855, 9855, 2),
176
+ (9875, 9875, 2),
177
+ (9889, 9889, 2),
178
+ (9898, 9899, 2),
179
+ (9917, 9918, 2),
180
+ (9924, 9925, 2),
181
+ (9934, 9934, 2),
182
+ (9940, 9940, 2),
183
+ (9962, 9962, 2),
184
+ (9970, 9971, 2),
185
+ (9973, 9973, 2),
186
+ (9978, 9978, 2),
187
+ (9981, 9981, 2),
188
+ (9989, 9989, 2),
189
+ (9994, 9995, 2),
190
+ (10024, 10024, 2),
191
+ (10060, 10060, 2),
192
+ (10062, 10062, 2),
193
+ (10067, 10069, 2),
194
+ (10071, 10071, 2),
195
+ (10133, 10135, 2),
196
+ (10160, 10160, 2),
197
+ (10175, 10175, 2),
198
+ (11035, 11036, 2),
199
+ (11088, 11088, 2),
200
+ (11093, 11093, 2),
201
+ (11503, 11505, 0),
202
+ (11647, 11647, 0),
203
+ (11744, 11775, 0),
204
+ (11904, 11929, 2),
205
+ (11931, 12019, 2),
206
+ (12032, 12245, 2),
207
+ (12272, 12329, 2),
208
+ (12330, 12335, 0),
209
+ (12336, 12350, 2),
210
+ (12353, 12438, 2),
211
+ (12441, 12442, 0),
212
+ (12443, 12543, 2),
213
+ (12549, 12591, 2),
214
+ (12593, 12686, 2),
215
+ (12688, 12771, 2),
216
+ (12783, 12830, 2),
217
+ (12832, 12871, 2),
218
+ (12880, 19903, 2),
219
+ (19968, 42124, 2),
220
+ (42128, 42182, 2),
221
+ (42607, 42610, 0),
222
+ (42612, 42621, 0),
223
+ (42654, 42655, 0),
224
+ (42736, 42737, 0),
225
+ (43010, 43010, 0),
226
+ (43014, 43014, 0),
227
+ (43019, 43019, 0),
228
+ (43043, 43047, 0),
229
+ (43052, 43052, 0),
230
+ (43136, 43137, 0),
231
+ (43188, 43205, 0),
232
+ (43232, 43249, 0),
233
+ (43263, 43263, 0),
234
+ (43302, 43309, 0),
235
+ (43335, 43347, 0),
236
+ (43360, 43388, 2),
237
+ (43392, 43395, 0),
238
+ (43443, 43456, 0),
239
+ (43493, 43493, 0),
240
+ (43561, 43574, 0),
241
+ (43587, 43587, 0),
242
+ (43596, 43597, 0),
243
+ (43643, 43645, 0),
244
+ (43696, 43696, 0),
245
+ (43698, 43700, 0),
246
+ (43703, 43704, 0),
247
+ (43710, 43711, 0),
248
+ (43713, 43713, 0),
249
+ (43755, 43759, 0),
250
+ (43765, 43766, 0),
251
+ (44003, 44010, 0),
252
+ (44012, 44013, 0),
253
+ (44032, 55203, 2),
254
+ (55216, 55295, 0),
255
+ (63744, 64255, 2),
256
+ (64286, 64286, 0),
257
+ (65024, 65039, 0),
258
+ (65040, 65049, 2),
259
+ (65056, 65071, 0),
260
+ (65072, 65106, 2),
261
+ (65108, 65126, 2),
262
+ (65128, 65131, 2),
263
+ (65279, 65279, 0),
264
+ (65281, 65376, 2),
265
+ (65504, 65510, 2),
266
+ (65529, 65531, 0),
267
+ (66045, 66045, 0),
268
+ (66272, 66272, 0),
269
+ (66422, 66426, 0),
270
+ (68097, 68099, 0),
271
+ (68101, 68102, 0),
272
+ (68108, 68111, 0),
273
+ (68152, 68154, 0),
274
+ (68159, 68159, 0),
275
+ (68325, 68326, 0),
276
+ (68900, 68903, 0),
277
+ (69291, 69292, 0),
278
+ (69373, 69375, 0),
279
+ (69446, 69456, 0),
280
+ (69506, 69509, 0),
281
+ (69632, 69634, 0),
282
+ (69688, 69702, 0),
283
+ (69744, 69744, 0),
284
+ (69747, 69748, 0),
285
+ (69759, 69762, 0),
286
+ (69808, 69818, 0),
287
+ (69821, 69821, 0),
288
+ (69826, 69826, 0),
289
+ (69837, 69837, 0),
290
+ (69888, 69890, 0),
291
+ (69927, 69940, 0),
292
+ (69957, 69958, 0),
293
+ (70003, 70003, 0),
294
+ (70016, 70018, 0),
295
+ (70067, 70080, 0),
296
+ (70089, 70092, 0),
297
+ (70094, 70095, 0),
298
+ (70188, 70199, 0),
299
+ (70206, 70206, 0),
300
+ (70209, 70209, 0),
301
+ (70367, 70378, 0),
302
+ (70400, 70403, 0),
303
+ (70459, 70460, 0),
304
+ (70462, 70468, 0),
305
+ (70471, 70472, 0),
306
+ (70475, 70477, 0),
307
+ (70487, 70487, 0),
308
+ (70498, 70499, 0),
309
+ (70502, 70508, 0),
310
+ (70512, 70516, 0),
311
+ (70709, 70726, 0),
312
+ (70750, 70750, 0),
313
+ (70832, 70851, 0),
314
+ (71087, 71093, 0),
315
+ (71096, 71104, 0),
316
+ (71132, 71133, 0),
317
+ (71216, 71232, 0),
318
+ (71339, 71351, 0),
319
+ (71453, 71467, 0),
320
+ (71724, 71738, 0),
321
+ (71984, 71989, 0),
322
+ (71991, 71992, 0),
323
+ (71995, 71998, 0),
324
+ (72000, 72000, 0),
325
+ (72002, 72003, 0),
326
+ (72145, 72151, 0),
327
+ (72154, 72160, 0),
328
+ (72164, 72164, 0),
329
+ (72193, 72202, 0),
330
+ (72243, 72249, 0),
331
+ (72251, 72254, 0),
332
+ (72263, 72263, 0),
333
+ (72273, 72283, 0),
334
+ (72330, 72345, 0),
335
+ (72751, 72758, 0),
336
+ (72760, 72767, 0),
337
+ (72850, 72871, 0),
338
+ (72873, 72886, 0),
339
+ (73009, 73014, 0),
340
+ (73018, 73018, 0),
341
+ (73020, 73021, 0),
342
+ (73023, 73029, 0),
343
+ (73031, 73031, 0),
344
+ (73098, 73102, 0),
345
+ (73104, 73105, 0),
346
+ (73107, 73111, 0),
347
+ (73459, 73462, 0),
348
+ (73472, 73473, 0),
349
+ (73475, 73475, 0),
350
+ (73524, 73530, 0),
351
+ (73534, 73538, 0),
352
+ (78896, 78912, 0),
353
+ (78919, 78933, 0),
354
+ (92912, 92916, 0),
355
+ (92976, 92982, 0),
356
+ (94031, 94031, 0),
357
+ (94033, 94087, 0),
358
+ (94095, 94098, 0),
359
+ (94176, 94179, 2),
360
+ (94180, 94180, 0),
361
+ (94192, 94193, 0),
362
+ (94208, 100343, 2),
363
+ (100352, 101589, 2),
364
+ (101632, 101640, 2),
365
+ (110576, 110579, 2),
366
+ (110581, 110587, 2),
367
+ (110589, 110590, 2),
368
+ (110592, 110882, 2),
369
+ (110898, 110898, 2),
370
+ (110928, 110930, 2),
371
+ (110933, 110933, 2),
372
+ (110948, 110951, 2),
373
+ (110960, 111355, 2),
374
+ (113821, 113822, 0),
375
+ (113824, 113827, 0),
376
+ (118528, 118573, 0),
377
+ (118576, 118598, 0),
378
+ (119141, 119145, 0),
379
+ (119149, 119170, 0),
380
+ (119173, 119179, 0),
381
+ (119210, 119213, 0),
382
+ (119362, 119364, 0),
383
+ (121344, 121398, 0),
384
+ (121403, 121452, 0),
385
+ (121461, 121461, 0),
386
+ (121476, 121476, 0),
387
+ (121499, 121503, 0),
388
+ (121505, 121519, 0),
389
+ (122880, 122886, 0),
390
+ (122888, 122904, 0),
391
+ (122907, 122913, 0),
392
+ (122915, 122916, 0),
393
+ (122918, 122922, 0),
394
+ (123023, 123023, 0),
395
+ (123184, 123190, 0),
396
+ (123566, 123566, 0),
397
+ (123628, 123631, 0),
398
+ (124140, 124143, 0),
399
+ (125136, 125142, 0),
400
+ (125252, 125258, 0),
401
+ (126980, 126980, 2),
402
+ (127183, 127183, 2),
403
+ (127374, 127374, 2),
404
+ (127377, 127386, 2),
405
+ (127488, 127490, 2),
406
+ (127504, 127547, 2),
407
+ (127552, 127560, 2),
408
+ (127568, 127569, 2),
409
+ (127584, 127589, 2),
410
+ (127744, 127776, 2),
411
+ (127789, 127797, 2),
412
+ (127799, 127868, 2),
413
+ (127870, 127891, 2),
414
+ (127904, 127946, 2),
415
+ (127951, 127955, 2),
416
+ (127968, 127984, 2),
417
+ (127988, 127988, 2),
418
+ (127992, 127994, 2),
419
+ (127995, 127999, 0),
420
+ (128000, 128062, 2),
421
+ (128064, 128064, 2),
422
+ (128066, 128252, 2),
423
+ (128255, 128317, 2),
424
+ (128331, 128334, 2),
425
+ (128336, 128359, 2),
426
+ (128378, 128378, 2),
427
+ (128405, 128406, 2),
428
+ (128420, 128420, 2),
429
+ (128507, 128591, 2),
430
+ (128640, 128709, 2),
431
+ (128716, 128716, 2),
432
+ (128720, 128722, 2),
433
+ (128725, 128727, 2),
434
+ (128732, 128735, 2),
435
+ (128747, 128748, 2),
436
+ (128756, 128764, 2),
437
+ (128992, 129003, 2),
438
+ (129008, 129008, 2),
439
+ (129292, 129338, 2),
440
+ (129340, 129349, 2),
441
+ (129351, 129535, 2),
442
+ (129648, 129660, 2),
443
+ (129664, 129672, 2),
444
+ (129680, 129725, 2),
445
+ (129727, 129733, 2),
446
+ (129742, 129755, 2),
447
+ (129760, 129768, 2),
448
+ (129776, 129784, 2),
449
+ (131072, 196605, 2),
450
+ (196608, 262141, 2),
451
+ (917505, 917505, 0),
452
+ (917536, 917631, 0),
453
+ (917760, 917999, 0),
454
+ ]
llava/lib/python3.10/site-packages/pip/_vendor/rich/_emoji_codes.py ADDED
The diff for this file is too large to render. See raw diff
 
llava/lib/python3.10/site-packages/pip/_vendor/rich/_inspect.py ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import inspect
2
+ from inspect import cleandoc, getdoc, getfile, isclass, ismodule, signature
3
+ from typing import Any, Collection, Iterable, Optional, Tuple, Type, Union
4
+
5
+ from .console import Group, RenderableType
6
+ from .control import escape_control_codes
7
+ from .highlighter import ReprHighlighter
8
+ from .jupyter import JupyterMixin
9
+ from .panel import Panel
10
+ from .pretty import Pretty
11
+ from .table import Table
12
+ from .text import Text, TextType
13
+
14
+
15
+ def _first_paragraph(doc: str) -> str:
16
+ """Get the first paragraph from a docstring."""
17
+ paragraph, _, _ = doc.partition("\n\n")
18
+ return paragraph
19
+
20
+
21
+ class Inspect(JupyterMixin):
22
+ """A renderable to inspect any Python Object.
23
+
24
+ Args:
25
+ obj (Any): An object to inspect.
26
+ title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
27
+ help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
28
+ methods (bool, optional): Enable inspection of callables. Defaults to False.
29
+ docs (bool, optional): Also render doc strings. Defaults to True.
30
+ private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
31
+ dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
32
+ sort (bool, optional): Sort attributes alphabetically. Defaults to True.
33
+ all (bool, optional): Show all attributes. Defaults to False.
34
+ value (bool, optional): Pretty print value of object. Defaults to True.
35
+ """
36
+
37
+ def __init__(
38
+ self,
39
+ obj: Any,
40
+ *,
41
+ title: Optional[TextType] = None,
42
+ help: bool = False,
43
+ methods: bool = False,
44
+ docs: bool = True,
45
+ private: bool = False,
46
+ dunder: bool = False,
47
+ sort: bool = True,
48
+ all: bool = True,
49
+ value: bool = True,
50
+ ) -> None:
51
+ self.highlighter = ReprHighlighter()
52
+ self.obj = obj
53
+ self.title = title or self._make_title(obj)
54
+ if all:
55
+ methods = private = dunder = True
56
+ self.help = help
57
+ self.methods = methods
58
+ self.docs = docs or help
59
+ self.private = private or dunder
60
+ self.dunder = dunder
61
+ self.sort = sort
62
+ self.value = value
63
+
64
+ def _make_title(self, obj: Any) -> Text:
65
+ """Make a default title."""
66
+ title_str = (
67
+ str(obj)
68
+ if (isclass(obj) or callable(obj) or ismodule(obj))
69
+ else str(type(obj))
70
+ )
71
+ title_text = self.highlighter(title_str)
72
+ return title_text
73
+
74
+ def __rich__(self) -> Panel:
75
+ return Panel.fit(
76
+ Group(*self._render()),
77
+ title=self.title,
78
+ border_style="scope.border",
79
+ padding=(0, 1),
80
+ )
81
+
82
+ def _get_signature(self, name: str, obj: Any) -> Optional[Text]:
83
+ """Get a signature for a callable."""
84
+ try:
85
+ _signature = str(signature(obj)) + ":"
86
+ except ValueError:
87
+ _signature = "(...)"
88
+ except TypeError:
89
+ return None
90
+
91
+ source_filename: Optional[str] = None
92
+ try:
93
+ source_filename = getfile(obj)
94
+ except (OSError, TypeError):
95
+ # OSError is raised if obj has no source file, e.g. when defined in REPL.
96
+ pass
97
+
98
+ callable_name = Text(name, style="inspect.callable")
99
+ if source_filename:
100
+ callable_name.stylize(f"link file://{source_filename}")
101
+ signature_text = self.highlighter(_signature)
102
+
103
+ qualname = name or getattr(obj, "__qualname__", name)
104
+
105
+ # If obj is a module, there may be classes (which are callable) to display
106
+ if inspect.isclass(obj):
107
+ prefix = "class"
108
+ elif inspect.iscoroutinefunction(obj):
109
+ prefix = "async def"
110
+ else:
111
+ prefix = "def"
112
+
113
+ qual_signature = Text.assemble(
114
+ (f"{prefix} ", f"inspect.{prefix.replace(' ', '_')}"),
115
+ (qualname, "inspect.callable"),
116
+ signature_text,
117
+ )
118
+
119
+ return qual_signature
120
+
121
+ def _render(self) -> Iterable[RenderableType]:
122
+ """Render object."""
123
+
124
+ def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
125
+ key, (_error, value) = item
126
+ return (callable(value), key.strip("_").lower())
127
+
128
+ def safe_getattr(attr_name: str) -> Tuple[Any, Any]:
129
+ """Get attribute or any exception."""
130
+ try:
131
+ return (None, getattr(obj, attr_name))
132
+ except Exception as error:
133
+ return (error, None)
134
+
135
+ obj = self.obj
136
+ keys = dir(obj)
137
+ total_items = len(keys)
138
+ if not self.dunder:
139
+ keys = [key for key in keys if not key.startswith("__")]
140
+ if not self.private:
141
+ keys = [key for key in keys if not key.startswith("_")]
142
+ not_shown_count = total_items - len(keys)
143
+ items = [(key, safe_getattr(key)) for key in keys]
144
+ if self.sort:
145
+ items.sort(key=sort_items)
146
+
147
+ items_table = Table.grid(padding=(0, 1), expand=False)
148
+ items_table.add_column(justify="right")
149
+ add_row = items_table.add_row
150
+ highlighter = self.highlighter
151
+
152
+ if callable(obj):
153
+ signature = self._get_signature("", obj)
154
+ if signature is not None:
155
+ yield signature
156
+ yield ""
157
+
158
+ if self.docs:
159
+ _doc = self._get_formatted_doc(obj)
160
+ if _doc is not None:
161
+ doc_text = Text(_doc, style="inspect.help")
162
+ doc_text = highlighter(doc_text)
163
+ yield doc_text
164
+ yield ""
165
+
166
+ if self.value and not (isclass(obj) or callable(obj) or ismodule(obj)):
167
+ yield Panel(
168
+ Pretty(obj, indent_guides=True, max_length=10, max_string=60),
169
+ border_style="inspect.value.border",
170
+ )
171
+ yield ""
172
+
173
+ for key, (error, value) in items:
174
+ key_text = Text.assemble(
175
+ (
176
+ key,
177
+ "inspect.attr.dunder" if key.startswith("__") else "inspect.attr",
178
+ ),
179
+ (" =", "inspect.equals"),
180
+ )
181
+ if error is not None:
182
+ warning = key_text.copy()
183
+ warning.stylize("inspect.error")
184
+ add_row(warning, highlighter(repr(error)))
185
+ continue
186
+
187
+ if callable(value):
188
+ if not self.methods:
189
+ continue
190
+
191
+ _signature_text = self._get_signature(key, value)
192
+ if _signature_text is None:
193
+ add_row(key_text, Pretty(value, highlighter=highlighter))
194
+ else:
195
+ if self.docs:
196
+ docs = self._get_formatted_doc(value)
197
+ if docs is not None:
198
+ _signature_text.append("\n" if "\n" in docs else " ")
199
+ doc = highlighter(docs)
200
+ doc.stylize("inspect.doc")
201
+ _signature_text.append(doc)
202
+
203
+ add_row(key_text, _signature_text)
204
+ else:
205
+ add_row(key_text, Pretty(value, highlighter=highlighter))
206
+ if items_table.row_count:
207
+ yield items_table
208
+ elif not_shown_count:
209
+ yield Text.from_markup(
210
+ f"[b cyan]{not_shown_count}[/][i] attribute(s) not shown.[/i] "
211
+ f"Run [b][magenta]inspect[/]([not b]inspect[/])[/b] for options."
212
+ )
213
+
214
+ def _get_formatted_doc(self, object_: Any) -> Optional[str]:
215
+ """
216
+ Extract the docstring of an object, process it and returns it.
217
+ The processing consists in cleaning up the doctring's indentation,
218
+ taking only its 1st paragraph if `self.help` is not True,
219
+ and escape its control codes.
220
+
221
+ Args:
222
+ object_ (Any): the object to get the docstring from.
223
+
224
+ Returns:
225
+ Optional[str]: the processed docstring, or None if no docstring was found.
226
+ """
227
+ docs = getdoc(object_)
228
+ if docs is None:
229
+ return None
230
+ docs = cleandoc(docs).strip()
231
+ if not self.help:
232
+ docs = _first_paragraph(docs)
233
+ return escape_control_codes(docs)
234
+
235
+
236
+ def get_object_types_mro(obj: Union[object, Type[Any]]) -> Tuple[type, ...]:
237
+ """Returns the MRO of an object's class, or of the object itself if it's a class."""
238
+ if not hasattr(obj, "__mro__"):
239
+ # N.B. we cannot use `if type(obj) is type` here because it doesn't work with
240
+ # some types of classes, such as the ones that use abc.ABCMeta.
241
+ obj = type(obj)
242
+ return getattr(obj, "__mro__", ())
243
+
244
+
245
+ def get_object_types_mro_as_strings(obj: object) -> Collection[str]:
246
+ """
247
+ Returns the MRO of an object's class as full qualified names, or of the object itself if it's a class.
248
+
249
+ Examples:
250
+ `object_types_mro_as_strings(JSONDecoder)` will return `['json.decoder.JSONDecoder', 'builtins.object']`
251
+ """
252
+ return [
253
+ f'{getattr(type_, "__module__", "")}.{getattr(type_, "__qualname__", "")}'
254
+ for type_ in get_object_types_mro(obj)
255
+ ]
256
+
257
+
258
+ def is_object_one_of_types(
259
+ obj: object, fully_qualified_types_names: Collection[str]
260
+ ) -> bool:
261
+ """
262
+ Returns `True` if the given object's class (or the object itself, if it's a class) has one of the
263
+ fully qualified names in its MRO.
264
+ """
265
+ for type_name in get_object_types_mro_as_strings(obj):
266
+ if type_name in fully_qualified_types_names:
267
+ return True
268
+ return False
llava/lib/python3.10/site-packages/pip/_vendor/rich/_ratio.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from fractions import Fraction
3
+ from math import ceil
4
+ from typing import cast, List, Optional, Sequence
5
+
6
+ if sys.version_info >= (3, 8):
7
+ from typing import Protocol
8
+ else:
9
+ from pip._vendor.typing_extensions import Protocol # pragma: no cover
10
+
11
+
12
+ class Edge(Protocol):
13
+ """Any object that defines an edge (such as Layout)."""
14
+
15
+ size: Optional[int] = None
16
+ ratio: int = 1
17
+ minimum_size: int = 1
18
+
19
+
20
+ def ratio_resolve(total: int, edges: Sequence[Edge]) -> List[int]:
21
+ """Divide total space to satisfy size, ratio, and minimum_size, constraints.
22
+
23
+ The returned list of integers should add up to total in most cases, unless it is
24
+ impossible to satisfy all the constraints. For instance, if there are two edges
25
+ with a minimum size of 20 each and `total` is 30 then the returned list will be
26
+ greater than total. In practice, this would mean that a Layout object would
27
+ clip the rows that would overflow the screen height.
28
+
29
+ Args:
30
+ total (int): Total number of characters.
31
+ edges (List[Edge]): Edges within total space.
32
+
33
+ Returns:
34
+ List[int]: Number of characters for each edge.
35
+ """
36
+ # Size of edge or None for yet to be determined
37
+ sizes = [(edge.size or None) for edge in edges]
38
+
39
+ _Fraction = Fraction
40
+
41
+ # While any edges haven't been calculated
42
+ while None in sizes:
43
+ # Get flexible edges and index to map these back on to sizes list
44
+ flexible_edges = [
45
+ (index, edge)
46
+ for index, (size, edge) in enumerate(zip(sizes, edges))
47
+ if size is None
48
+ ]
49
+ # Remaining space in total
50
+ remaining = total - sum(size or 0 for size in sizes)
51
+ if remaining <= 0:
52
+ # No room for flexible edges
53
+ return [
54
+ ((edge.minimum_size or 1) if size is None else size)
55
+ for size, edge in zip(sizes, edges)
56
+ ]
57
+ # Calculate number of characters in a ratio portion
58
+ portion = _Fraction(
59
+ remaining, sum((edge.ratio or 1) for _, edge in flexible_edges)
60
+ )
61
+
62
+ # If any edges will be less than their minimum, replace size with the minimum
63
+ for index, edge in flexible_edges:
64
+ if portion * edge.ratio <= edge.minimum_size:
65
+ sizes[index] = edge.minimum_size
66
+ # New fixed size will invalidate calculations, so we need to repeat the process
67
+ break
68
+ else:
69
+ # Distribute flexible space and compensate for rounding error
70
+ # Since edge sizes can only be integers we need to add the remainder
71
+ # to the following line
72
+ remainder = _Fraction(0)
73
+ for index, edge in flexible_edges:
74
+ size, remainder = divmod(portion * edge.ratio + remainder, 1)
75
+ sizes[index] = size
76
+ break
77
+ # Sizes now contains integers only
78
+ return cast(List[int], sizes)
79
+
80
+
81
+ def ratio_reduce(
82
+ total: int, ratios: List[int], maximums: List[int], values: List[int]
83
+ ) -> List[int]:
84
+ """Divide an integer total in to parts based on ratios.
85
+
86
+ Args:
87
+ total (int): The total to divide.
88
+ ratios (List[int]): A list of integer ratios.
89
+ maximums (List[int]): List of maximums values for each slot.
90
+ values (List[int]): List of values
91
+
92
+ Returns:
93
+ List[int]: A list of integers guaranteed to sum to total.
94
+ """
95
+ ratios = [ratio if _max else 0 for ratio, _max in zip(ratios, maximums)]
96
+ total_ratio = sum(ratios)
97
+ if not total_ratio:
98
+ return values[:]
99
+ total_remaining = total
100
+ result: List[int] = []
101
+ append = result.append
102
+ for ratio, maximum, value in zip(ratios, maximums, values):
103
+ if ratio and total_ratio > 0:
104
+ distributed = min(maximum, round(ratio * total_remaining / total_ratio))
105
+ append(value - distributed)
106
+ total_remaining -= distributed
107
+ total_ratio -= ratio
108
+ else:
109
+ append(value)
110
+ return result
111
+
112
+
113
+ def ratio_distribute(
114
+ total: int, ratios: List[int], minimums: Optional[List[int]] = None
115
+ ) -> List[int]:
116
+ """Distribute an integer total in to parts based on ratios.
117
+
118
+ Args:
119
+ total (int): The total to divide.
120
+ ratios (List[int]): A list of integer ratios.
121
+ minimums (List[int]): List of minimum values for each slot.
122
+
123
+ Returns:
124
+ List[int]: A list of integers guaranteed to sum to total.
125
+ """
126
+ if minimums:
127
+ ratios = [ratio if _min else 0 for ratio, _min in zip(ratios, minimums)]
128
+ total_ratio = sum(ratios)
129
+ assert total_ratio > 0, "Sum of ratios must be > 0"
130
+
131
+ total_remaining = total
132
+ distributed_total: List[int] = []
133
+ append = distributed_total.append
134
+ if minimums is None:
135
+ _minimums = [0] * len(ratios)
136
+ else:
137
+ _minimums = minimums
138
+ for ratio, minimum in zip(ratios, _minimums):
139
+ if total_ratio > 0:
140
+ distributed = max(minimum, ceil(ratio * total_remaining / total_ratio))
141
+ else:
142
+ distributed = total_remaining
143
+ append(distributed)
144
+ total_ratio -= ratio
145
+ total_remaining -= distributed
146
+ return distributed_total
147
+
148
+
149
+ if __name__ == "__main__":
150
+ from dataclasses import dataclass
151
+
152
+ @dataclass
153
+ class E:
154
+ size: Optional[int] = None
155
+ ratio: int = 1
156
+ minimum_size: int = 1
157
+
158
+ resolved = ratio_resolve(110, [E(None, 1, 1), E(None, 1, 1), E(None, 1, 1)])
159
+ print(sum(resolved))
llava/lib/python3.10/site-packages/pip/_vendor/rich/_wrap.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from typing import Iterable
5
+
6
+ from ._loop import loop_last
7
+ from .cells import cell_len, chop_cells
8
+
9
+ re_word = re.compile(r"\s*\S+\s*")
10
+
11
+
12
+ def words(text: str) -> Iterable[tuple[int, int, str]]:
13
+ """Yields each word from the text as a tuple
14
+ containing (start_index, end_index, word). A "word" in this context may
15
+ include the actual word and any whitespace to the right.
16
+ """
17
+ position = 0
18
+ word_match = re_word.match(text, position)
19
+ while word_match is not None:
20
+ start, end = word_match.span()
21
+ word = word_match.group(0)
22
+ yield start, end, word
23
+ word_match = re_word.match(text, end)
24
+
25
+
26
+ def divide_line(text: str, width: int, fold: bool = True) -> list[int]:
27
+ """Given a string of text, and a width (measured in cells), return a list
28
+ of cell offsets which the string should be split at in order for it to fit
29
+ within the given width.
30
+
31
+ Args:
32
+ text: The text to examine.
33
+ width: The available cell width.
34
+ fold: If True, words longer than `width` will be folded onto a new line.
35
+
36
+ Returns:
37
+ A list of indices to break the line at.
38
+ """
39
+ break_positions: list[int] = [] # offsets to insert the breaks at
40
+ append = break_positions.append
41
+ cell_offset = 0
42
+ _cell_len = cell_len
43
+
44
+ for start, _end, word in words(text):
45
+ word_length = _cell_len(word.rstrip())
46
+ remaining_space = width - cell_offset
47
+ word_fits_remaining_space = remaining_space >= word_length
48
+
49
+ if word_fits_remaining_space:
50
+ # Simplest case - the word fits within the remaining width for this line.
51
+ cell_offset += _cell_len(word)
52
+ else:
53
+ # Not enough space remaining for this word on the current line.
54
+ if word_length > width:
55
+ # The word doesn't fit on any line, so we can't simply
56
+ # place it on the next line...
57
+ if fold:
58
+ # Fold the word across multiple lines.
59
+ folded_word = chop_cells(word, width=width)
60
+ for last, line in loop_last(folded_word):
61
+ if start:
62
+ append(start)
63
+ if last:
64
+ cell_offset = _cell_len(line)
65
+ else:
66
+ start += len(line)
67
+ else:
68
+ # Folding isn't allowed, so crop the word.
69
+ if start:
70
+ append(start)
71
+ cell_offset = _cell_len(word)
72
+ elif cell_offset and start:
73
+ # The word doesn't fit within the remaining space on the current
74
+ # line, but it *can* fit on to the next (empty) line.
75
+ append(start)
76
+ cell_offset = _cell_len(word)
77
+
78
+ return break_positions
79
+
80
+
81
+ if __name__ == "__main__": # pragma: no cover
82
+ from .console import Console
83
+
84
+ console = Console(width=10)
85
+ console.print("12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345")
86
+ print(chop_cells("abcdefghijklmnopqrstuvwxyz", 10))
87
+
88
+ console = Console(width=20)
89
+ console.rule()
90
+ console.print("TextualはPythonの高速アプリケーション開発フレームワークです")
91
+
92
+ console.rule()
93
+ console.print("アプリケーションは1670万色を使用でき")
llava/lib/python3.10/site-packages/pip/_vendor/rich/default_styles.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict
2
+
3
+ from .style import Style
4
+
5
+ DEFAULT_STYLES: Dict[str, Style] = {
6
+ "none": Style.null(),
7
+ "reset": Style(
8
+ color="default",
9
+ bgcolor="default",
10
+ dim=False,
11
+ bold=False,
12
+ italic=False,
13
+ underline=False,
14
+ blink=False,
15
+ blink2=False,
16
+ reverse=False,
17
+ conceal=False,
18
+ strike=False,
19
+ ),
20
+ "dim": Style(dim=True),
21
+ "bright": Style(dim=False),
22
+ "bold": Style(bold=True),
23
+ "strong": Style(bold=True),
24
+ "code": Style(reverse=True, bold=True),
25
+ "italic": Style(italic=True),
26
+ "emphasize": Style(italic=True),
27
+ "underline": Style(underline=True),
28
+ "blink": Style(blink=True),
29
+ "blink2": Style(blink2=True),
30
+ "reverse": Style(reverse=True),
31
+ "strike": Style(strike=True),
32
+ "black": Style(color="black"),
33
+ "red": Style(color="red"),
34
+ "green": Style(color="green"),
35
+ "yellow": Style(color="yellow"),
36
+ "magenta": Style(color="magenta"),
37
+ "cyan": Style(color="cyan"),
38
+ "white": Style(color="white"),
39
+ "inspect.attr": Style(color="yellow", italic=True),
40
+ "inspect.attr.dunder": Style(color="yellow", italic=True, dim=True),
41
+ "inspect.callable": Style(bold=True, color="red"),
42
+ "inspect.async_def": Style(italic=True, color="bright_cyan"),
43
+ "inspect.def": Style(italic=True, color="bright_cyan"),
44
+ "inspect.class": Style(italic=True, color="bright_cyan"),
45
+ "inspect.error": Style(bold=True, color="red"),
46
+ "inspect.equals": Style(),
47
+ "inspect.help": Style(color="cyan"),
48
+ "inspect.doc": Style(dim=True),
49
+ "inspect.value.border": Style(color="green"),
50
+ "live.ellipsis": Style(bold=True, color="red"),
51
+ "layout.tree.row": Style(dim=False, color="red"),
52
+ "layout.tree.column": Style(dim=False, color="blue"),
53
+ "logging.keyword": Style(bold=True, color="yellow"),
54
+ "logging.level.notset": Style(dim=True),
55
+ "logging.level.debug": Style(color="green"),
56
+ "logging.level.info": Style(color="blue"),
57
+ "logging.level.warning": Style(color="yellow"),
58
+ "logging.level.error": Style(color="red", bold=True),
59
+ "logging.level.critical": Style(color="red", bold=True, reverse=True),
60
+ "log.level": Style.null(),
61
+ "log.time": Style(color="cyan", dim=True),
62
+ "log.message": Style.null(),
63
+ "log.path": Style(dim=True),
64
+ "repr.ellipsis": Style(color="yellow"),
65
+ "repr.indent": Style(color="green", dim=True),
66
+ "repr.error": Style(color="red", bold=True),
67
+ "repr.str": Style(color="green", italic=False, bold=False),
68
+ "repr.brace": Style(bold=True),
69
+ "repr.comma": Style(bold=True),
70
+ "repr.ipv4": Style(bold=True, color="bright_green"),
71
+ "repr.ipv6": Style(bold=True, color="bright_green"),
72
+ "repr.eui48": Style(bold=True, color="bright_green"),
73
+ "repr.eui64": Style(bold=True, color="bright_green"),
74
+ "repr.tag_start": Style(bold=True),
75
+ "repr.tag_name": Style(color="bright_magenta", bold=True),
76
+ "repr.tag_contents": Style(color="default"),
77
+ "repr.tag_end": Style(bold=True),
78
+ "repr.attrib_name": Style(color="yellow", italic=False),
79
+ "repr.attrib_equal": Style(bold=True),
80
+ "repr.attrib_value": Style(color="magenta", italic=False),
81
+ "repr.number": Style(color="cyan", bold=True, italic=False),
82
+ "repr.number_complex": Style(color="cyan", bold=True, italic=False), # same
83
+ "repr.bool_true": Style(color="bright_green", italic=True),
84
+ "repr.bool_false": Style(color="bright_red", italic=True),
85
+ "repr.none": Style(color="magenta", italic=True),
86
+ "repr.url": Style(underline=True, color="bright_blue", italic=False, bold=False),
87
+ "repr.uuid": Style(color="bright_yellow", bold=False),
88
+ "repr.call": Style(color="magenta", bold=True),
89
+ "repr.path": Style(color="magenta"),
90
+ "repr.filename": Style(color="bright_magenta"),
91
+ "rule.line": Style(color="bright_green"),
92
+ "rule.text": Style.null(),
93
+ "json.brace": Style(bold=True),
94
+ "json.bool_true": Style(color="bright_green", italic=True),
95
+ "json.bool_false": Style(color="bright_red", italic=True),
96
+ "json.null": Style(color="magenta", italic=True),
97
+ "json.number": Style(color="cyan", bold=True, italic=False),
98
+ "json.str": Style(color="green", italic=False, bold=False),
99
+ "json.key": Style(color="blue", bold=True),
100
+ "prompt": Style.null(),
101
+ "prompt.choices": Style(color="magenta", bold=True),
102
+ "prompt.default": Style(color="cyan", bold=True),
103
+ "prompt.invalid": Style(color="red"),
104
+ "prompt.invalid.choice": Style(color="red"),
105
+ "pretty": Style.null(),
106
+ "scope.border": Style(color="blue"),
107
+ "scope.key": Style(color="yellow", italic=True),
108
+ "scope.key.special": Style(color="yellow", italic=True, dim=True),
109
+ "scope.equals": Style(color="red"),
110
+ "table.header": Style(bold=True),
111
+ "table.footer": Style(bold=True),
112
+ "table.cell": Style.null(),
113
+ "table.title": Style(italic=True),
114
+ "table.caption": Style(italic=True, dim=True),
115
+ "traceback.error": Style(color="red", italic=True),
116
+ "traceback.border.syntax_error": Style(color="bright_red"),
117
+ "traceback.border": Style(color="red"),
118
+ "traceback.text": Style.null(),
119
+ "traceback.title": Style(color="red", bold=True),
120
+ "traceback.exc_type": Style(color="bright_red", bold=True),
121
+ "traceback.exc_value": Style.null(),
122
+ "traceback.offset": Style(color="bright_red", bold=True),
123
+ "traceback.error_range": Style(underline=True, bold=True, dim=False),
124
+ "bar.back": Style(color="grey23"),
125
+ "bar.complete": Style(color="rgb(249,38,114)"),
126
+ "bar.finished": Style(color="rgb(114,156,31)"),
127
+ "bar.pulse": Style(color="rgb(249,38,114)"),
128
+ "progress.description": Style.null(),
129
+ "progress.filesize": Style(color="green"),
130
+ "progress.filesize.total": Style(color="green"),
131
+ "progress.download": Style(color="green"),
132
+ "progress.elapsed": Style(color="yellow"),
133
+ "progress.percentage": Style(color="magenta"),
134
+ "progress.remaining": Style(color="cyan"),
135
+ "progress.data.speed": Style(color="red"),
136
+ "progress.spinner": Style(color="green"),
137
+ "status.spinner": Style(color="green"),
138
+ "tree": Style(),
139
+ "tree.line": Style(),
140
+ "markdown.paragraph": Style(),
141
+ "markdown.text": Style(),
142
+ "markdown.em": Style(italic=True),
143
+ "markdown.emph": Style(italic=True), # For commonmark backwards compatibility
144
+ "markdown.strong": Style(bold=True),
145
+ "markdown.code": Style(bold=True, color="cyan", bgcolor="black"),
146
+ "markdown.code_block": Style(color="cyan", bgcolor="black"),
147
+ "markdown.block_quote": Style(color="magenta"),
148
+ "markdown.list": Style(color="cyan"),
149
+ "markdown.item": Style(),
150
+ "markdown.item.bullet": Style(color="yellow", bold=True),
151
+ "markdown.item.number": Style(color="yellow", bold=True),
152
+ "markdown.hr": Style(color="yellow"),
153
+ "markdown.h1.border": Style(),
154
+ "markdown.h1": Style(bold=True),
155
+ "markdown.h2": Style(bold=True, underline=True),
156
+ "markdown.h3": Style(bold=True),
157
+ "markdown.h4": Style(bold=True, dim=True),
158
+ "markdown.h5": Style(underline=True),
159
+ "markdown.h6": Style(italic=True),
160
+ "markdown.h7": Style(italic=True, dim=True),
161
+ "markdown.link": Style(color="bright_blue"),
162
+ "markdown.link_url": Style(color="blue", underline=True),
163
+ "markdown.s": Style(strike=True),
164
+ "iso8601.date": Style(color="blue"),
165
+ "iso8601.time": Style(color="magenta"),
166
+ "iso8601.timezone": Style(color="yellow"),
167
+ }
168
+
169
+
170
+ if __name__ == "__main__": # pragma: no cover
171
+ import argparse
172
+ import io
173
+
174
+ from pip._vendor.rich.console import Console
175
+ from pip._vendor.rich.table import Table
176
+ from pip._vendor.rich.text import Text
177
+
178
+ parser = argparse.ArgumentParser()
179
+ parser.add_argument("--html", action="store_true", help="Export as HTML table")
180
+ args = parser.parse_args()
181
+ html: bool = args.html
182
+ console = Console(record=True, width=70, file=io.StringIO()) if html else Console()
183
+
184
+ table = Table("Name", "Styling")
185
+
186
+ for style_name, style in DEFAULT_STYLES.items():
187
+ table.add_row(Text(style_name, style=style), str(style))
188
+
189
+ console.print(table)
190
+ if html:
191
+ print(console.export_html(inline_styles=True))
llava/lib/python3.10/site-packages/pip/_vendor/rich/status.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from types import TracebackType
2
+ from typing import Optional, Type
3
+
4
+ from .console import Console, RenderableType
5
+ from .jupyter import JupyterMixin
6
+ from .live import Live
7
+ from .spinner import Spinner
8
+ from .style import StyleType
9
+
10
+
11
+ class Status(JupyterMixin):
12
+ """Displays a status indicator with a 'spinner' animation.
13
+
14
+ Args:
15
+ status (RenderableType): A status renderable (str or Text typically).
16
+ console (Console, optional): Console instance to use, or None for global console. Defaults to None.
17
+ spinner (str, optional): Name of spinner animation (see python -m rich.spinner). Defaults to "dots".
18
+ spinner_style (StyleType, optional): Style of spinner. Defaults to "status.spinner".
19
+ speed (float, optional): Speed factor for spinner animation. Defaults to 1.0.
20
+ refresh_per_second (float, optional): Number of refreshes per second. Defaults to 12.5.
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ status: RenderableType,
26
+ *,
27
+ console: Optional[Console] = None,
28
+ spinner: str = "dots",
29
+ spinner_style: StyleType = "status.spinner",
30
+ speed: float = 1.0,
31
+ refresh_per_second: float = 12.5,
32
+ ):
33
+ self.status = status
34
+ self.spinner_style = spinner_style
35
+ self.speed = speed
36
+ self._spinner = Spinner(spinner, text=status, style=spinner_style, speed=speed)
37
+ self._live = Live(
38
+ self.renderable,
39
+ console=console,
40
+ refresh_per_second=refresh_per_second,
41
+ transient=True,
42
+ )
43
+
44
+ @property
45
+ def renderable(self) -> Spinner:
46
+ return self._spinner
47
+
48
+ @property
49
+ def console(self) -> "Console":
50
+ """Get the Console used by the Status objects."""
51
+ return self._live.console
52
+
53
+ def update(
54
+ self,
55
+ status: Optional[RenderableType] = None,
56
+ *,
57
+ spinner: Optional[str] = None,
58
+ spinner_style: Optional[StyleType] = None,
59
+ speed: Optional[float] = None,
60
+ ) -> None:
61
+ """Update status.
62
+
63
+ Args:
64
+ status (Optional[RenderableType], optional): New status renderable or None for no change. Defaults to None.
65
+ spinner (Optional[str], optional): New spinner or None for no change. Defaults to None.
66
+ spinner_style (Optional[StyleType], optional): New spinner style or None for no change. Defaults to None.
67
+ speed (Optional[float], optional): Speed factor for spinner animation or None for no change. Defaults to None.
68
+ """
69
+ if status is not None:
70
+ self.status = status
71
+ if spinner_style is not None:
72
+ self.spinner_style = spinner_style
73
+ if speed is not None:
74
+ self.speed = speed
75
+ if spinner is not None:
76
+ self._spinner = Spinner(
77
+ spinner, text=self.status, style=self.spinner_style, speed=self.speed
78
+ )
79
+ self._live.update(self.renderable, refresh=True)
80
+ else:
81
+ self._spinner.update(
82
+ text=self.status, style=self.spinner_style, speed=self.speed
83
+ )
84
+
85
+ def start(self) -> None:
86
+ """Start the status animation."""
87
+ self._live.start()
88
+
89
+ def stop(self) -> None:
90
+ """Stop the spinner animation."""
91
+ self._live.stop()
92
+
93
+ def __rich__(self) -> RenderableType:
94
+ return self.renderable
95
+
96
+ def __enter__(self) -> "Status":
97
+ self.start()
98
+ return self
99
+
100
+ def __exit__(
101
+ self,
102
+ exc_type: Optional[Type[BaseException]],
103
+ exc_val: Optional[BaseException],
104
+ exc_tb: Optional[TracebackType],
105
+ ) -> None:
106
+ self.stop()
107
+
108
+
109
+ if __name__ == "__main__": # pragma: no cover
110
+ from time import sleep
111
+
112
+ from .console import Console
113
+
114
+ console = Console()
115
+ with console.status("[magenta]Covid detector booting up") as status:
116
+ sleep(3)
117
+ console.log("Importing advanced AI")
118
+ sleep(3)
119
+ console.log("Advanced Covid AI Ready")
120
+ sleep(3)
121
+ status.update(status="[bold blue] Scanning for Covid", spinner="earth")
122
+ sleep(3)
123
+ console.log("Found 10,000,000,000 copies of Covid32.exe")
124
+ sleep(3)
125
+ status.update(
126
+ status="[bold red]Moving Covid32.exe to Trash",
127
+ spinner="bouncingBall",
128
+ spinner_style="yellow",
129
+ )
130
+ sleep(5)
131
+ console.print("[bold green]Covid deleted successfully")
llava/lib/python3.10/site-packages/pip/_vendor/rich/style.py ADDED
@@ -0,0 +1,796 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from functools import lru_cache
3
+ from marshal import dumps, loads
4
+ from random import randint
5
+ from typing import Any, Dict, Iterable, List, Optional, Type, Union, cast
6
+
7
+ from . import errors
8
+ from .color import Color, ColorParseError, ColorSystem, blend_rgb
9
+ from .repr import Result, rich_repr
10
+ from .terminal_theme import DEFAULT_TERMINAL_THEME, TerminalTheme
11
+
12
+ # Style instances and style definitions are often interchangeable
13
+ StyleType = Union[str, "Style"]
14
+
15
+
16
+ class _Bit:
17
+ """A descriptor to get/set a style attribute bit."""
18
+
19
+ __slots__ = ["bit"]
20
+
21
+ def __init__(self, bit_no: int) -> None:
22
+ self.bit = 1 << bit_no
23
+
24
+ def __get__(self, obj: "Style", objtype: Type["Style"]) -> Optional[bool]:
25
+ if obj._set_attributes & self.bit:
26
+ return obj._attributes & self.bit != 0
27
+ return None
28
+
29
+
30
+ @rich_repr
31
+ class Style:
32
+ """A terminal style.
33
+
34
+ A terminal style consists of a color (`color`), a background color (`bgcolor`), and a number of attributes, such
35
+ as bold, italic etc. The attributes have 3 states: they can either be on
36
+ (``True``), off (``False``), or not set (``None``).
37
+
38
+ Args:
39
+ color (Union[Color, str], optional): Color of terminal text. Defaults to None.
40
+ bgcolor (Union[Color, str], optional): Color of terminal background. Defaults to None.
41
+ bold (bool, optional): Enable bold text. Defaults to None.
42
+ dim (bool, optional): Enable dim text. Defaults to None.
43
+ italic (bool, optional): Enable italic text. Defaults to None.
44
+ underline (bool, optional): Enable underlined text. Defaults to None.
45
+ blink (bool, optional): Enabled blinking text. Defaults to None.
46
+ blink2 (bool, optional): Enable fast blinking text. Defaults to None.
47
+ reverse (bool, optional): Enabled reverse text. Defaults to None.
48
+ conceal (bool, optional): Enable concealed text. Defaults to None.
49
+ strike (bool, optional): Enable strikethrough text. Defaults to None.
50
+ underline2 (bool, optional): Enable doubly underlined text. Defaults to None.
51
+ frame (bool, optional): Enable framed text. Defaults to None.
52
+ encircle (bool, optional): Enable encircled text. Defaults to None.
53
+ overline (bool, optional): Enable overlined text. Defaults to None.
54
+ link (str, link): Link URL. Defaults to None.
55
+
56
+ """
57
+
58
+ _color: Optional[Color]
59
+ _bgcolor: Optional[Color]
60
+ _attributes: int
61
+ _set_attributes: int
62
+ _hash: Optional[int]
63
+ _null: bool
64
+ _meta: Optional[bytes]
65
+
66
+ __slots__ = [
67
+ "_color",
68
+ "_bgcolor",
69
+ "_attributes",
70
+ "_set_attributes",
71
+ "_link",
72
+ "_link_id",
73
+ "_ansi",
74
+ "_style_definition",
75
+ "_hash",
76
+ "_null",
77
+ "_meta",
78
+ ]
79
+
80
+ # maps bits on to SGR parameter
81
+ _style_map = {
82
+ 0: "1",
83
+ 1: "2",
84
+ 2: "3",
85
+ 3: "4",
86
+ 4: "5",
87
+ 5: "6",
88
+ 6: "7",
89
+ 7: "8",
90
+ 8: "9",
91
+ 9: "21",
92
+ 10: "51",
93
+ 11: "52",
94
+ 12: "53",
95
+ }
96
+
97
+ STYLE_ATTRIBUTES = {
98
+ "dim": "dim",
99
+ "d": "dim",
100
+ "bold": "bold",
101
+ "b": "bold",
102
+ "italic": "italic",
103
+ "i": "italic",
104
+ "underline": "underline",
105
+ "u": "underline",
106
+ "blink": "blink",
107
+ "blink2": "blink2",
108
+ "reverse": "reverse",
109
+ "r": "reverse",
110
+ "conceal": "conceal",
111
+ "c": "conceal",
112
+ "strike": "strike",
113
+ "s": "strike",
114
+ "underline2": "underline2",
115
+ "uu": "underline2",
116
+ "frame": "frame",
117
+ "encircle": "encircle",
118
+ "overline": "overline",
119
+ "o": "overline",
120
+ }
121
+
122
+ def __init__(
123
+ self,
124
+ *,
125
+ color: Optional[Union[Color, str]] = None,
126
+ bgcolor: Optional[Union[Color, str]] = None,
127
+ bold: Optional[bool] = None,
128
+ dim: Optional[bool] = None,
129
+ italic: Optional[bool] = None,
130
+ underline: Optional[bool] = None,
131
+ blink: Optional[bool] = None,
132
+ blink2: Optional[bool] = None,
133
+ reverse: Optional[bool] = None,
134
+ conceal: Optional[bool] = None,
135
+ strike: Optional[bool] = None,
136
+ underline2: Optional[bool] = None,
137
+ frame: Optional[bool] = None,
138
+ encircle: Optional[bool] = None,
139
+ overline: Optional[bool] = None,
140
+ link: Optional[str] = None,
141
+ meta: Optional[Dict[str, Any]] = None,
142
+ ):
143
+ self._ansi: Optional[str] = None
144
+ self._style_definition: Optional[str] = None
145
+
146
+ def _make_color(color: Union[Color, str]) -> Color:
147
+ return color if isinstance(color, Color) else Color.parse(color)
148
+
149
+ self._color = None if color is None else _make_color(color)
150
+ self._bgcolor = None if bgcolor is None else _make_color(bgcolor)
151
+ self._set_attributes = sum(
152
+ (
153
+ bold is not None,
154
+ dim is not None and 2,
155
+ italic is not None and 4,
156
+ underline is not None and 8,
157
+ blink is not None and 16,
158
+ blink2 is not None and 32,
159
+ reverse is not None and 64,
160
+ conceal is not None and 128,
161
+ strike is not None and 256,
162
+ underline2 is not None and 512,
163
+ frame is not None and 1024,
164
+ encircle is not None and 2048,
165
+ overline is not None and 4096,
166
+ )
167
+ )
168
+ self._attributes = (
169
+ sum(
170
+ (
171
+ bold and 1 or 0,
172
+ dim and 2 or 0,
173
+ italic and 4 or 0,
174
+ underline and 8 or 0,
175
+ blink and 16 or 0,
176
+ blink2 and 32 or 0,
177
+ reverse and 64 or 0,
178
+ conceal and 128 or 0,
179
+ strike and 256 or 0,
180
+ underline2 and 512 or 0,
181
+ frame and 1024 or 0,
182
+ encircle and 2048 or 0,
183
+ overline and 4096 or 0,
184
+ )
185
+ )
186
+ if self._set_attributes
187
+ else 0
188
+ )
189
+
190
+ self._link = link
191
+ self._meta = None if meta is None else dumps(meta)
192
+ self._link_id = (
193
+ f"{randint(0, 999999)}{hash(self._meta)}" if (link or meta) else ""
194
+ )
195
+ self._hash: Optional[int] = None
196
+ self._null = not (self._set_attributes or color or bgcolor or link or meta)
197
+
198
+ @classmethod
199
+ def null(cls) -> "Style":
200
+ """Create an 'null' style, equivalent to Style(), but more performant."""
201
+ return NULL_STYLE
202
+
203
+ @classmethod
204
+ def from_color(
205
+ cls, color: Optional[Color] = None, bgcolor: Optional[Color] = None
206
+ ) -> "Style":
207
+ """Create a new style with colors and no attributes.
208
+
209
+ Returns:
210
+ color (Optional[Color]): A (foreground) color, or None for no color. Defaults to None.
211
+ bgcolor (Optional[Color]): A (background) color, or None for no color. Defaults to None.
212
+ """
213
+ style: Style = cls.__new__(Style)
214
+ style._ansi = None
215
+ style._style_definition = None
216
+ style._color = color
217
+ style._bgcolor = bgcolor
218
+ style._set_attributes = 0
219
+ style._attributes = 0
220
+ style._link = None
221
+ style._link_id = ""
222
+ style._meta = None
223
+ style._null = not (color or bgcolor)
224
+ style._hash = None
225
+ return style
226
+
227
+ @classmethod
228
+ def from_meta(cls, meta: Optional[Dict[str, Any]]) -> "Style":
229
+ """Create a new style with meta data.
230
+
231
+ Returns:
232
+ meta (Optional[Dict[str, Any]]): A dictionary of meta data. Defaults to None.
233
+ """
234
+ style: Style = cls.__new__(Style)
235
+ style._ansi = None
236
+ style._style_definition = None
237
+ style._color = None
238
+ style._bgcolor = None
239
+ style._set_attributes = 0
240
+ style._attributes = 0
241
+ style._link = None
242
+ style._meta = dumps(meta)
243
+ style._link_id = f"{randint(0, 999999)}{hash(style._meta)}"
244
+ style._hash = None
245
+ style._null = not (meta)
246
+ return style
247
+
248
+ @classmethod
249
+ def on(cls, meta: Optional[Dict[str, Any]] = None, **handlers: Any) -> "Style":
250
+ """Create a blank style with meta information.
251
+
252
+ Example:
253
+ style = Style.on(click=self.on_click)
254
+
255
+ Args:
256
+ meta (Optional[Dict[str, Any]], optional): An optional dict of meta information.
257
+ **handlers (Any): Keyword arguments are translated in to handlers.
258
+
259
+ Returns:
260
+ Style: A Style with meta information attached.
261
+ """
262
+ meta = {} if meta is None else meta
263
+ meta.update({f"@{key}": value for key, value in handlers.items()})
264
+ return cls.from_meta(meta)
265
+
266
+ bold = _Bit(0)
267
+ dim = _Bit(1)
268
+ italic = _Bit(2)
269
+ underline = _Bit(3)
270
+ blink = _Bit(4)
271
+ blink2 = _Bit(5)
272
+ reverse = _Bit(6)
273
+ conceal = _Bit(7)
274
+ strike = _Bit(8)
275
+ underline2 = _Bit(9)
276
+ frame = _Bit(10)
277
+ encircle = _Bit(11)
278
+ overline = _Bit(12)
279
+
280
+ @property
281
+ def link_id(self) -> str:
282
+ """Get a link id, used in ansi code for links."""
283
+ return self._link_id
284
+
285
+ def __str__(self) -> str:
286
+ """Re-generate style definition from attributes."""
287
+ if self._style_definition is None:
288
+ attributes: List[str] = []
289
+ append = attributes.append
290
+ bits = self._set_attributes
291
+ if bits & 0b0000000001111:
292
+ if bits & 1:
293
+ append("bold" if self.bold else "not bold")
294
+ if bits & (1 << 1):
295
+ append("dim" if self.dim else "not dim")
296
+ if bits & (1 << 2):
297
+ append("italic" if self.italic else "not italic")
298
+ if bits & (1 << 3):
299
+ append("underline" if self.underline else "not underline")
300
+ if bits & 0b0000111110000:
301
+ if bits & (1 << 4):
302
+ append("blink" if self.blink else "not blink")
303
+ if bits & (1 << 5):
304
+ append("blink2" if self.blink2 else "not blink2")
305
+ if bits & (1 << 6):
306
+ append("reverse" if self.reverse else "not reverse")
307
+ if bits & (1 << 7):
308
+ append("conceal" if self.conceal else "not conceal")
309
+ if bits & (1 << 8):
310
+ append("strike" if self.strike else "not strike")
311
+ if bits & 0b1111000000000:
312
+ if bits & (1 << 9):
313
+ append("underline2" if self.underline2 else "not underline2")
314
+ if bits & (1 << 10):
315
+ append("frame" if self.frame else "not frame")
316
+ if bits & (1 << 11):
317
+ append("encircle" if self.encircle else "not encircle")
318
+ if bits & (1 << 12):
319
+ append("overline" if self.overline else "not overline")
320
+ if self._color is not None:
321
+ append(self._color.name)
322
+ if self._bgcolor is not None:
323
+ append("on")
324
+ append(self._bgcolor.name)
325
+ if self._link:
326
+ append("link")
327
+ append(self._link)
328
+ self._style_definition = " ".join(attributes) or "none"
329
+ return self._style_definition
330
+
331
+ def __bool__(self) -> bool:
332
+ """A Style is false if it has no attributes, colors, or links."""
333
+ return not self._null
334
+
335
+ def _make_ansi_codes(self, color_system: ColorSystem) -> str:
336
+ """Generate ANSI codes for this style.
337
+
338
+ Args:
339
+ color_system (ColorSystem): Color system.
340
+
341
+ Returns:
342
+ str: String containing codes.
343
+ """
344
+
345
+ if self._ansi is None:
346
+ sgr: List[str] = []
347
+ append = sgr.append
348
+ _style_map = self._style_map
349
+ attributes = self._attributes & self._set_attributes
350
+ if attributes:
351
+ if attributes & 1:
352
+ append(_style_map[0])
353
+ if attributes & 2:
354
+ append(_style_map[1])
355
+ if attributes & 4:
356
+ append(_style_map[2])
357
+ if attributes & 8:
358
+ append(_style_map[3])
359
+ if attributes & 0b0000111110000:
360
+ for bit in range(4, 9):
361
+ if attributes & (1 << bit):
362
+ append(_style_map[bit])
363
+ if attributes & 0b1111000000000:
364
+ for bit in range(9, 13):
365
+ if attributes & (1 << bit):
366
+ append(_style_map[bit])
367
+ if self._color is not None:
368
+ sgr.extend(self._color.downgrade(color_system).get_ansi_codes())
369
+ if self._bgcolor is not None:
370
+ sgr.extend(
371
+ self._bgcolor.downgrade(color_system).get_ansi_codes(
372
+ foreground=False
373
+ )
374
+ )
375
+ self._ansi = ";".join(sgr)
376
+ return self._ansi
377
+
378
+ @classmethod
379
+ @lru_cache(maxsize=1024)
380
+ def normalize(cls, style: str) -> str:
381
+ """Normalize a style definition so that styles with the same effect have the same string
382
+ representation.
383
+
384
+ Args:
385
+ style (str): A style definition.
386
+
387
+ Returns:
388
+ str: Normal form of style definition.
389
+ """
390
+ try:
391
+ return str(cls.parse(style))
392
+ except errors.StyleSyntaxError:
393
+ return style.strip().lower()
394
+
395
+ @classmethod
396
+ def pick_first(cls, *values: Optional[StyleType]) -> StyleType:
397
+ """Pick first non-None style."""
398
+ for value in values:
399
+ if value is not None:
400
+ return value
401
+ raise ValueError("expected at least one non-None style")
402
+
403
+ def __rich_repr__(self) -> Result:
404
+ yield "color", self.color, None
405
+ yield "bgcolor", self.bgcolor, None
406
+ yield "bold", self.bold, None,
407
+ yield "dim", self.dim, None,
408
+ yield "italic", self.italic, None
409
+ yield "underline", self.underline, None,
410
+ yield "blink", self.blink, None
411
+ yield "blink2", self.blink2, None
412
+ yield "reverse", self.reverse, None
413
+ yield "conceal", self.conceal, None
414
+ yield "strike", self.strike, None
415
+ yield "underline2", self.underline2, None
416
+ yield "frame", self.frame, None
417
+ yield "encircle", self.encircle, None
418
+ yield "link", self.link, None
419
+ if self._meta:
420
+ yield "meta", self.meta
421
+
422
+ def __eq__(self, other: Any) -> bool:
423
+ if not isinstance(other, Style):
424
+ return NotImplemented
425
+ return self.__hash__() == other.__hash__()
426
+
427
+ def __ne__(self, other: Any) -> bool:
428
+ if not isinstance(other, Style):
429
+ return NotImplemented
430
+ return self.__hash__() != other.__hash__()
431
+
432
+ def __hash__(self) -> int:
433
+ if self._hash is not None:
434
+ return self._hash
435
+ self._hash = hash(
436
+ (
437
+ self._color,
438
+ self._bgcolor,
439
+ self._attributes,
440
+ self._set_attributes,
441
+ self._link,
442
+ self._meta,
443
+ )
444
+ )
445
+ return self._hash
446
+
447
+ @property
448
+ def color(self) -> Optional[Color]:
449
+ """The foreground color or None if it is not set."""
450
+ return self._color
451
+
452
+ @property
453
+ def bgcolor(self) -> Optional[Color]:
454
+ """The background color or None if it is not set."""
455
+ return self._bgcolor
456
+
457
+ @property
458
+ def link(self) -> Optional[str]:
459
+ """Link text, if set."""
460
+ return self._link
461
+
462
+ @property
463
+ def transparent_background(self) -> bool:
464
+ """Check if the style specified a transparent background."""
465
+ return self.bgcolor is None or self.bgcolor.is_default
466
+
467
+ @property
468
+ def background_style(self) -> "Style":
469
+ """A Style with background only."""
470
+ return Style(bgcolor=self.bgcolor)
471
+
472
+ @property
473
+ def meta(self) -> Dict[str, Any]:
474
+ """Get meta information (can not be changed after construction)."""
475
+ return {} if self._meta is None else cast(Dict[str, Any], loads(self._meta))
476
+
477
+ @property
478
+ def without_color(self) -> "Style":
479
+ """Get a copy of the style with color removed."""
480
+ if self._null:
481
+ return NULL_STYLE
482
+ style: Style = self.__new__(Style)
483
+ style._ansi = None
484
+ style._style_definition = None
485
+ style._color = None
486
+ style._bgcolor = None
487
+ style._attributes = self._attributes
488
+ style._set_attributes = self._set_attributes
489
+ style._link = self._link
490
+ style._link_id = f"{randint(0, 999999)}" if self._link else ""
491
+ style._null = False
492
+ style._meta = None
493
+ style._hash = None
494
+ return style
495
+
496
+ @classmethod
497
+ @lru_cache(maxsize=4096)
498
+ def parse(cls, style_definition: str) -> "Style":
499
+ """Parse a style definition.
500
+
501
+ Args:
502
+ style_definition (str): A string containing a style.
503
+
504
+ Raises:
505
+ errors.StyleSyntaxError: If the style definition syntax is invalid.
506
+
507
+ Returns:
508
+ `Style`: A Style instance.
509
+ """
510
+ if style_definition.strip() == "none" or not style_definition:
511
+ return cls.null()
512
+
513
+ STYLE_ATTRIBUTES = cls.STYLE_ATTRIBUTES
514
+ color: Optional[str] = None
515
+ bgcolor: Optional[str] = None
516
+ attributes: Dict[str, Optional[Any]] = {}
517
+ link: Optional[str] = None
518
+
519
+ words = iter(style_definition.split())
520
+ for original_word in words:
521
+ word = original_word.lower()
522
+ if word == "on":
523
+ word = next(words, "")
524
+ if not word:
525
+ raise errors.StyleSyntaxError("color expected after 'on'")
526
+ try:
527
+ Color.parse(word) is None
528
+ except ColorParseError as error:
529
+ raise errors.StyleSyntaxError(
530
+ f"unable to parse {word!r} as background color; {error}"
531
+ ) from None
532
+ bgcolor = word
533
+
534
+ elif word == "not":
535
+ word = next(words, "")
536
+ attribute = STYLE_ATTRIBUTES.get(word)
537
+ if attribute is None:
538
+ raise errors.StyleSyntaxError(
539
+ f"expected style attribute after 'not', found {word!r}"
540
+ )
541
+ attributes[attribute] = False
542
+
543
+ elif word == "link":
544
+ word = next(words, "")
545
+ if not word:
546
+ raise errors.StyleSyntaxError("URL expected after 'link'")
547
+ link = word
548
+
549
+ elif word in STYLE_ATTRIBUTES:
550
+ attributes[STYLE_ATTRIBUTES[word]] = True
551
+
552
+ else:
553
+ try:
554
+ Color.parse(word)
555
+ except ColorParseError as error:
556
+ raise errors.StyleSyntaxError(
557
+ f"unable to parse {word!r} as color; {error}"
558
+ ) from None
559
+ color = word
560
+ style = Style(color=color, bgcolor=bgcolor, link=link, **attributes)
561
+ return style
562
+
563
+ @lru_cache(maxsize=1024)
564
+ def get_html_style(self, theme: Optional[TerminalTheme] = None) -> str:
565
+ """Get a CSS style rule."""
566
+ theme = theme or DEFAULT_TERMINAL_THEME
567
+ css: List[str] = []
568
+ append = css.append
569
+
570
+ color = self.color
571
+ bgcolor = self.bgcolor
572
+ if self.reverse:
573
+ color, bgcolor = bgcolor, color
574
+ if self.dim:
575
+ foreground_color = (
576
+ theme.foreground_color if color is None else color.get_truecolor(theme)
577
+ )
578
+ color = Color.from_triplet(
579
+ blend_rgb(foreground_color, theme.background_color, 0.5)
580
+ )
581
+ if color is not None:
582
+ theme_color = color.get_truecolor(theme)
583
+ append(f"color: {theme_color.hex}")
584
+ append(f"text-decoration-color: {theme_color.hex}")
585
+ if bgcolor is not None:
586
+ theme_color = bgcolor.get_truecolor(theme, foreground=False)
587
+ append(f"background-color: {theme_color.hex}")
588
+ if self.bold:
589
+ append("font-weight: bold")
590
+ if self.italic:
591
+ append("font-style: italic")
592
+ if self.underline:
593
+ append("text-decoration: underline")
594
+ if self.strike:
595
+ append("text-decoration: line-through")
596
+ if self.overline:
597
+ append("text-decoration: overline")
598
+ return "; ".join(css)
599
+
600
+ @classmethod
601
+ def combine(cls, styles: Iterable["Style"]) -> "Style":
602
+ """Combine styles and get result.
603
+
604
+ Args:
605
+ styles (Iterable[Style]): Styles to combine.
606
+
607
+ Returns:
608
+ Style: A new style instance.
609
+ """
610
+ iter_styles = iter(styles)
611
+ return sum(iter_styles, next(iter_styles))
612
+
613
+ @classmethod
614
+ def chain(cls, *styles: "Style") -> "Style":
615
+ """Combine styles from positional argument in to a single style.
616
+
617
+ Args:
618
+ *styles (Iterable[Style]): Styles to combine.
619
+
620
+ Returns:
621
+ Style: A new style instance.
622
+ """
623
+ iter_styles = iter(styles)
624
+ return sum(iter_styles, next(iter_styles))
625
+
626
+ def copy(self) -> "Style":
627
+ """Get a copy of this style.
628
+
629
+ Returns:
630
+ Style: A new Style instance with identical attributes.
631
+ """
632
+ if self._null:
633
+ return NULL_STYLE
634
+ style: Style = self.__new__(Style)
635
+ style._ansi = self._ansi
636
+ style._style_definition = self._style_definition
637
+ style._color = self._color
638
+ style._bgcolor = self._bgcolor
639
+ style._attributes = self._attributes
640
+ style._set_attributes = self._set_attributes
641
+ style._link = self._link
642
+ style._link_id = f"{randint(0, 999999)}" if self._link else ""
643
+ style._hash = self._hash
644
+ style._null = False
645
+ style._meta = self._meta
646
+ return style
647
+
648
+ @lru_cache(maxsize=128)
649
+ def clear_meta_and_links(self) -> "Style":
650
+ """Get a copy of this style with link and meta information removed.
651
+
652
+ Returns:
653
+ Style: New style object.
654
+ """
655
+ if self._null:
656
+ return NULL_STYLE
657
+ style: Style = self.__new__(Style)
658
+ style._ansi = self._ansi
659
+ style._style_definition = self._style_definition
660
+ style._color = self._color
661
+ style._bgcolor = self._bgcolor
662
+ style._attributes = self._attributes
663
+ style._set_attributes = self._set_attributes
664
+ style._link = None
665
+ style._link_id = ""
666
+ style._hash = None
667
+ style._null = False
668
+ style._meta = None
669
+ return style
670
+
671
+ def update_link(self, link: Optional[str] = None) -> "Style":
672
+ """Get a copy with a different value for link.
673
+
674
+ Args:
675
+ link (str, optional): New value for link. Defaults to None.
676
+
677
+ Returns:
678
+ Style: A new Style instance.
679
+ """
680
+ style: Style = self.__new__(Style)
681
+ style._ansi = self._ansi
682
+ style._style_definition = self._style_definition
683
+ style._color = self._color
684
+ style._bgcolor = self._bgcolor
685
+ style._attributes = self._attributes
686
+ style._set_attributes = self._set_attributes
687
+ style._link = link
688
+ style._link_id = f"{randint(0, 999999)}" if link else ""
689
+ style._hash = None
690
+ style._null = False
691
+ style._meta = self._meta
692
+ return style
693
+
694
+ def render(
695
+ self,
696
+ text: str = "",
697
+ *,
698
+ color_system: Optional[ColorSystem] = ColorSystem.TRUECOLOR,
699
+ legacy_windows: bool = False,
700
+ ) -> str:
701
+ """Render the ANSI codes for the style.
702
+
703
+ Args:
704
+ text (str, optional): A string to style. Defaults to "".
705
+ color_system (Optional[ColorSystem], optional): Color system to render to. Defaults to ColorSystem.TRUECOLOR.
706
+
707
+ Returns:
708
+ str: A string containing ANSI style codes.
709
+ """
710
+ if not text or color_system is None:
711
+ return text
712
+ attrs = self._ansi or self._make_ansi_codes(color_system)
713
+ rendered = f"\x1b[{attrs}m{text}\x1b[0m" if attrs else text
714
+ if self._link and not legacy_windows:
715
+ rendered = (
716
+ f"\x1b]8;id={self._link_id};{self._link}\x1b\\{rendered}\x1b]8;;\x1b\\"
717
+ )
718
+ return rendered
719
+
720
+ def test(self, text: Optional[str] = None) -> None:
721
+ """Write text with style directly to terminal.
722
+
723
+ This method is for testing purposes only.
724
+
725
+ Args:
726
+ text (Optional[str], optional): Text to style or None for style name.
727
+
728
+ """
729
+ text = text or str(self)
730
+ sys.stdout.write(f"{self.render(text)}\n")
731
+
732
+ @lru_cache(maxsize=1024)
733
+ def _add(self, style: Optional["Style"]) -> "Style":
734
+ if style is None or style._null:
735
+ return self
736
+ if self._null:
737
+ return style
738
+ new_style: Style = self.__new__(Style)
739
+ new_style._ansi = None
740
+ new_style._style_definition = None
741
+ new_style._color = style._color or self._color
742
+ new_style._bgcolor = style._bgcolor or self._bgcolor
743
+ new_style._attributes = (self._attributes & ~style._set_attributes) | (
744
+ style._attributes & style._set_attributes
745
+ )
746
+ new_style._set_attributes = self._set_attributes | style._set_attributes
747
+ new_style._link = style._link or self._link
748
+ new_style._link_id = style._link_id or self._link_id
749
+ new_style._null = style._null
750
+ if self._meta and style._meta:
751
+ new_style._meta = dumps({**self.meta, **style.meta})
752
+ else:
753
+ new_style._meta = self._meta or style._meta
754
+ new_style._hash = None
755
+ return new_style
756
+
757
+ def __add__(self, style: Optional["Style"]) -> "Style":
758
+ combined_style = self._add(style)
759
+ return combined_style.copy() if combined_style.link else combined_style
760
+
761
+
762
+ NULL_STYLE = Style()
763
+
764
+
765
+ class StyleStack:
766
+ """A stack of styles."""
767
+
768
+ __slots__ = ["_stack"]
769
+
770
+ def __init__(self, default_style: "Style") -> None:
771
+ self._stack: List[Style] = [default_style]
772
+
773
+ def __repr__(self) -> str:
774
+ return f"<stylestack {self._stack!r}>"
775
+
776
+ @property
777
+ def current(self) -> Style:
778
+ """Get the Style at the top of the stack."""
779
+ return self._stack[-1]
780
+
781
+ def push(self, style: Style) -> None:
782
+ """Push a new style on to the stack.
783
+
784
+ Args:
785
+ style (Style): New style to combine with current style.
786
+ """
787
+ self._stack.append(self._stack[-1] + style)
788
+
789
+ def pop(self) -> Style:
790
+ """Pop last style and discard.
791
+
792
+ Returns:
793
+ Style: New current style (also available as stack.current)
794
+ """
795
+ self._stack.pop()
796
+ return self._stack[-1]
llava/lib/python3.10/site-packages/pip/_vendor/rich/table.py ADDED
@@ -0,0 +1,1007 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass, field, replace
2
+ from typing import (
3
+ TYPE_CHECKING,
4
+ Dict,
5
+ Iterable,
6
+ List,
7
+ NamedTuple,
8
+ Optional,
9
+ Sequence,
10
+ Tuple,
11
+ Union,
12
+ )
13
+
14
+ from . import box, errors
15
+ from ._loop import loop_first_last, loop_last
16
+ from ._pick import pick_bool
17
+ from ._ratio import ratio_distribute, ratio_reduce
18
+ from .align import VerticalAlignMethod
19
+ from .jupyter import JupyterMixin
20
+ from .measure import Measurement
21
+ from .padding import Padding, PaddingDimensions
22
+ from .protocol import is_renderable
23
+ from .segment import Segment
24
+ from .style import Style, StyleType
25
+ from .text import Text, TextType
26
+
27
+ if TYPE_CHECKING:
28
+ from .console import (
29
+ Console,
30
+ ConsoleOptions,
31
+ JustifyMethod,
32
+ OverflowMethod,
33
+ RenderableType,
34
+ RenderResult,
35
+ )
36
+
37
+
38
+ @dataclass
39
+ class Column:
40
+ """Defines a column within a ~Table.
41
+
42
+ Args:
43
+ title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
44
+ caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
45
+ width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
46
+ min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
47
+ box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
48
+ safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
49
+ padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
50
+ collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
51
+ pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
52
+ expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
53
+ show_header (bool, optional): Show a header row. Defaults to True.
54
+ show_footer (bool, optional): Show a footer row. Defaults to False.
55
+ show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
56
+ show_lines (bool, optional): Draw lines between every row. Defaults to False.
57
+ leading (int, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
58
+ style (Union[str, Style], optional): Default style for the table. Defaults to "none".
59
+ row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
60
+ header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
61
+ footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
62
+ border_style (Union[str, Style], optional): Style of the border. Defaults to None.
63
+ title_style (Union[str, Style], optional): Style of the title. Defaults to None.
64
+ caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
65
+ title_justify (str, optional): Justify method for title. Defaults to "center".
66
+ caption_justify (str, optional): Justify method for caption. Defaults to "center".
67
+ highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
68
+ """
69
+
70
+ header: "RenderableType" = ""
71
+ """RenderableType: Renderable for the header (typically a string)"""
72
+
73
+ footer: "RenderableType" = ""
74
+ """RenderableType: Renderable for the footer (typically a string)"""
75
+
76
+ header_style: StyleType = ""
77
+ """StyleType: The style of the header."""
78
+
79
+ footer_style: StyleType = ""
80
+ """StyleType: The style of the footer."""
81
+
82
+ style: StyleType = ""
83
+ """StyleType: The style of the column."""
84
+
85
+ justify: "JustifyMethod" = "left"
86
+ """str: How to justify text within the column ("left", "center", "right", or "full")"""
87
+
88
+ vertical: "VerticalAlignMethod" = "top"
89
+ """str: How to vertically align content ("top", "middle", or "bottom")"""
90
+
91
+ overflow: "OverflowMethod" = "ellipsis"
92
+ """str: Overflow method."""
93
+
94
+ width: Optional[int] = None
95
+ """Optional[int]: Width of the column, or ``None`` (default) to auto calculate width."""
96
+
97
+ min_width: Optional[int] = None
98
+ """Optional[int]: Minimum width of column, or ``None`` for no minimum. Defaults to None."""
99
+
100
+ max_width: Optional[int] = None
101
+ """Optional[int]: Maximum width of column, or ``None`` for no maximum. Defaults to None."""
102
+
103
+ ratio: Optional[int] = None
104
+ """Optional[int]: Ratio to use when calculating column width, or ``None`` (default) to adapt to column contents."""
105
+
106
+ no_wrap: bool = False
107
+ """bool: Prevent wrapping of text within the column. Defaults to ``False``."""
108
+
109
+ highlight: bool = False
110
+ """bool: Apply highlighter to column. Defaults to ``False``."""
111
+
112
+ _index: int = 0
113
+ """Index of column."""
114
+
115
+ _cells: List["RenderableType"] = field(default_factory=list)
116
+
117
+ def copy(self) -> "Column":
118
+ """Return a copy of this Column."""
119
+ return replace(self, _cells=[])
120
+
121
+ @property
122
+ def cells(self) -> Iterable["RenderableType"]:
123
+ """Get all cells in the column, not including header."""
124
+ yield from self._cells
125
+
126
+ @property
127
+ def flexible(self) -> bool:
128
+ """Check if this column is flexible."""
129
+ return self.ratio is not None
130
+
131
+
132
+ @dataclass
133
+ class Row:
134
+ """Information regarding a row."""
135
+
136
+ style: Optional[StyleType] = None
137
+ """Style to apply to row."""
138
+
139
+ end_section: bool = False
140
+ """Indicated end of section, which will force a line beneath the row."""
141
+
142
+
143
+ class _Cell(NamedTuple):
144
+ """A single cell in a table."""
145
+
146
+ style: StyleType
147
+ """Style to apply to cell."""
148
+ renderable: "RenderableType"
149
+ """Cell renderable."""
150
+ vertical: VerticalAlignMethod
151
+ """Cell vertical alignment."""
152
+
153
+
154
+ class Table(JupyterMixin):
155
+ """A console renderable to draw a table.
156
+
157
+ Args:
158
+ *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
159
+ title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
160
+ caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
161
+ width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
162
+ min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
163
+ box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
164
+ safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
165
+ padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
166
+ collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
167
+ pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
168
+ expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
169
+ show_header (bool, optional): Show a header row. Defaults to True.
170
+ show_footer (bool, optional): Show a footer row. Defaults to False.
171
+ show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
172
+ show_lines (bool, optional): Draw lines between every row. Defaults to False.
173
+ leading (int, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
174
+ style (Union[str, Style], optional): Default style for the table. Defaults to "none".
175
+ row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
176
+ header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
177
+ footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
178
+ border_style (Union[str, Style], optional): Style of the border. Defaults to None.
179
+ title_style (Union[str, Style], optional): Style of the title. Defaults to None.
180
+ caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
181
+ title_justify (str, optional): Justify method for title. Defaults to "center".
182
+ caption_justify (str, optional): Justify method for caption. Defaults to "center".
183
+ highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
184
+ """
185
+
186
+ columns: List[Column]
187
+ rows: List[Row]
188
+
189
+ def __init__(
190
+ self,
191
+ *headers: Union[Column, str],
192
+ title: Optional[TextType] = None,
193
+ caption: Optional[TextType] = None,
194
+ width: Optional[int] = None,
195
+ min_width: Optional[int] = None,
196
+ box: Optional[box.Box] = box.HEAVY_HEAD,
197
+ safe_box: Optional[bool] = None,
198
+ padding: PaddingDimensions = (0, 1),
199
+ collapse_padding: bool = False,
200
+ pad_edge: bool = True,
201
+ expand: bool = False,
202
+ show_header: bool = True,
203
+ show_footer: bool = False,
204
+ show_edge: bool = True,
205
+ show_lines: bool = False,
206
+ leading: int = 0,
207
+ style: StyleType = "none",
208
+ row_styles: Optional[Iterable[StyleType]] = None,
209
+ header_style: Optional[StyleType] = "table.header",
210
+ footer_style: Optional[StyleType] = "table.footer",
211
+ border_style: Optional[StyleType] = None,
212
+ title_style: Optional[StyleType] = None,
213
+ caption_style: Optional[StyleType] = None,
214
+ title_justify: "JustifyMethod" = "center",
215
+ caption_justify: "JustifyMethod" = "center",
216
+ highlight: bool = False,
217
+ ) -> None:
218
+ self.columns: List[Column] = []
219
+ self.rows: List[Row] = []
220
+ self.title = title
221
+ self.caption = caption
222
+ self.width = width
223
+ self.min_width = min_width
224
+ self.box = box
225
+ self.safe_box = safe_box
226
+ self._padding = Padding.unpack(padding)
227
+ self.pad_edge = pad_edge
228
+ self._expand = expand
229
+ self.show_header = show_header
230
+ self.show_footer = show_footer
231
+ self.show_edge = show_edge
232
+ self.show_lines = show_lines
233
+ self.leading = leading
234
+ self.collapse_padding = collapse_padding
235
+ self.style = style
236
+ self.header_style = header_style or ""
237
+ self.footer_style = footer_style or ""
238
+ self.border_style = border_style
239
+ self.title_style = title_style
240
+ self.caption_style = caption_style
241
+ self.title_justify: "JustifyMethod" = title_justify
242
+ self.caption_justify: "JustifyMethod" = caption_justify
243
+ self.highlight = highlight
244
+ self.row_styles: Sequence[StyleType] = list(row_styles or [])
245
+ append_column = self.columns.append
246
+ for header in headers:
247
+ if isinstance(header, str):
248
+ self.add_column(header=header)
249
+ else:
250
+ header._index = len(self.columns)
251
+ append_column(header)
252
+
253
+ @classmethod
254
+ def grid(
255
+ cls,
256
+ *headers: Union[Column, str],
257
+ padding: PaddingDimensions = 0,
258
+ collapse_padding: bool = True,
259
+ pad_edge: bool = False,
260
+ expand: bool = False,
261
+ ) -> "Table":
262
+ """Get a table with no lines, headers, or footer.
263
+
264
+ Args:
265
+ *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
266
+ padding (PaddingDimensions, optional): Get padding around cells. Defaults to 0.
267
+ collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to True.
268
+ pad_edge (bool, optional): Enable padding around edges of table. Defaults to False.
269
+ expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
270
+
271
+ Returns:
272
+ Table: A table instance.
273
+ """
274
+ return cls(
275
+ *headers,
276
+ box=None,
277
+ padding=padding,
278
+ collapse_padding=collapse_padding,
279
+ show_header=False,
280
+ show_footer=False,
281
+ show_edge=False,
282
+ pad_edge=pad_edge,
283
+ expand=expand,
284
+ )
285
+
286
+ @property
287
+ def expand(self) -> bool:
288
+ """Setting a non-None self.width implies expand."""
289
+ return self._expand or self.width is not None
290
+
291
+ @expand.setter
292
+ def expand(self, expand: bool) -> None:
293
+ """Set expand."""
294
+ self._expand = expand
295
+
296
+ @property
297
+ def _extra_width(self) -> int:
298
+ """Get extra width to add to cell content."""
299
+ width = 0
300
+ if self.box and self.show_edge:
301
+ width += 2
302
+ if self.box:
303
+ width += len(self.columns) - 1
304
+ return width
305
+
306
+ @property
307
+ def row_count(self) -> int:
308
+ """Get the current number of rows."""
309
+ return len(self.rows)
310
+
311
+ def get_row_style(self, console: "Console", index: int) -> StyleType:
312
+ """Get the current row style."""
313
+ style = Style.null()
314
+ if self.row_styles:
315
+ style += console.get_style(self.row_styles[index % len(self.row_styles)])
316
+ row_style = self.rows[index].style
317
+ if row_style is not None:
318
+ style += console.get_style(row_style)
319
+ return style
320
+
321
+ def __rich_measure__(
322
+ self, console: "Console", options: "ConsoleOptions"
323
+ ) -> Measurement:
324
+ max_width = options.max_width
325
+ if self.width is not None:
326
+ max_width = self.width
327
+ if max_width < 0:
328
+ return Measurement(0, 0)
329
+
330
+ extra_width = self._extra_width
331
+ max_width = sum(
332
+ self._calculate_column_widths(
333
+ console, options.update_width(max_width - extra_width)
334
+ )
335
+ )
336
+ _measure_column = self._measure_column
337
+
338
+ measurements = [
339
+ _measure_column(console, options.update_width(max_width), column)
340
+ for column in self.columns
341
+ ]
342
+ minimum_width = (
343
+ sum(measurement.minimum for measurement in measurements) + extra_width
344
+ )
345
+ maximum_width = (
346
+ sum(measurement.maximum for measurement in measurements) + extra_width
347
+ if (self.width is None)
348
+ else self.width
349
+ )
350
+ measurement = Measurement(minimum_width, maximum_width)
351
+ measurement = measurement.clamp(self.min_width)
352
+ return measurement
353
+
354
+ @property
355
+ def padding(self) -> Tuple[int, int, int, int]:
356
+ """Get cell padding."""
357
+ return self._padding
358
+
359
+ @padding.setter
360
+ def padding(self, padding: PaddingDimensions) -> "Table":
361
+ """Set cell padding."""
362
+ self._padding = Padding.unpack(padding)
363
+ return self
364
+
365
+ def add_column(
366
+ self,
367
+ header: "RenderableType" = "",
368
+ footer: "RenderableType" = "",
369
+ *,
370
+ header_style: Optional[StyleType] = None,
371
+ highlight: Optional[bool] = None,
372
+ footer_style: Optional[StyleType] = None,
373
+ style: Optional[StyleType] = None,
374
+ justify: "JustifyMethod" = "left",
375
+ vertical: "VerticalAlignMethod" = "top",
376
+ overflow: "OverflowMethod" = "ellipsis",
377
+ width: Optional[int] = None,
378
+ min_width: Optional[int] = None,
379
+ max_width: Optional[int] = None,
380
+ ratio: Optional[int] = None,
381
+ no_wrap: bool = False,
382
+ ) -> None:
383
+ """Add a column to the table.
384
+
385
+ Args:
386
+ header (RenderableType, optional): Text or renderable for the header.
387
+ Defaults to "".
388
+ footer (RenderableType, optional): Text or renderable for the footer.
389
+ Defaults to "".
390
+ header_style (Union[str, Style], optional): Style for the header, or None for default. Defaults to None.
391
+ highlight (bool, optional): Whether to highlight the text. The default of None uses the value of the table (self) object.
392
+ footer_style (Union[str, Style], optional): Style for the footer, or None for default. Defaults to None.
393
+ style (Union[str, Style], optional): Style for the column cells, or None for default. Defaults to None.
394
+ justify (JustifyMethod, optional): Alignment for cells. Defaults to "left".
395
+ vertical (VerticalAlignMethod, optional): Vertical alignment, one of "top", "middle", or "bottom". Defaults to "top".
396
+ overflow (OverflowMethod): Overflow method: "crop", "fold", "ellipsis". Defaults to "ellipsis".
397
+ width (int, optional): Desired width of column in characters, or None to fit to contents. Defaults to None.
398
+ min_width (Optional[int], optional): Minimum width of column, or ``None`` for no minimum. Defaults to None.
399
+ max_width (Optional[int], optional): Maximum width of column, or ``None`` for no maximum. Defaults to None.
400
+ ratio (int, optional): Flexible ratio for the column (requires ``Table.expand`` or ``Table.width``). Defaults to None.
401
+ no_wrap (bool, optional): Set to ``True`` to disable wrapping of this column.
402
+ """
403
+
404
+ column = Column(
405
+ _index=len(self.columns),
406
+ header=header,
407
+ footer=footer,
408
+ header_style=header_style or "",
409
+ highlight=highlight if highlight is not None else self.highlight,
410
+ footer_style=footer_style or "",
411
+ style=style or "",
412
+ justify=justify,
413
+ vertical=vertical,
414
+ overflow=overflow,
415
+ width=width,
416
+ min_width=min_width,
417
+ max_width=max_width,
418
+ ratio=ratio,
419
+ no_wrap=no_wrap,
420
+ )
421
+ self.columns.append(column)
422
+
423
+ def add_row(
424
+ self,
425
+ *renderables: Optional["RenderableType"],
426
+ style: Optional[StyleType] = None,
427
+ end_section: bool = False,
428
+ ) -> None:
429
+ """Add a row of renderables.
430
+
431
+ Args:
432
+ *renderables (None or renderable): Each cell in a row must be a renderable object (including str),
433
+ or ``None`` for a blank cell.
434
+ style (StyleType, optional): An optional style to apply to the entire row. Defaults to None.
435
+ end_section (bool, optional): End a section and draw a line. Defaults to False.
436
+
437
+ Raises:
438
+ errors.NotRenderableError: If you add something that can't be rendered.
439
+ """
440
+
441
+ def add_cell(column: Column, renderable: "RenderableType") -> None:
442
+ column._cells.append(renderable)
443
+
444
+ cell_renderables: List[Optional["RenderableType"]] = list(renderables)
445
+
446
+ columns = self.columns
447
+ if len(cell_renderables) < len(columns):
448
+ cell_renderables = [
449
+ *cell_renderables,
450
+ *[None] * (len(columns) - len(cell_renderables)),
451
+ ]
452
+ for index, renderable in enumerate(cell_renderables):
453
+ if index == len(columns):
454
+ column = Column(_index=index, highlight=self.highlight)
455
+ for _ in self.rows:
456
+ add_cell(column, Text(""))
457
+ self.columns.append(column)
458
+ else:
459
+ column = columns[index]
460
+ if renderable is None:
461
+ add_cell(column, "")
462
+ elif is_renderable(renderable):
463
+ add_cell(column, renderable)
464
+ else:
465
+ raise errors.NotRenderableError(
466
+ f"unable to render {type(renderable).__name__}; a string or other renderable object is required"
467
+ )
468
+ self.rows.append(Row(style=style, end_section=end_section))
469
+
470
+ def add_section(self) -> None:
471
+ """Add a new section (draw a line after current row)."""
472
+
473
+ if self.rows:
474
+ self.rows[-1].end_section = True
475
+
476
+ def __rich_console__(
477
+ self, console: "Console", options: "ConsoleOptions"
478
+ ) -> "RenderResult":
479
+ if not self.columns:
480
+ yield Segment("\n")
481
+ return
482
+
483
+ max_width = options.max_width
484
+ if self.width is not None:
485
+ max_width = self.width
486
+
487
+ extra_width = self._extra_width
488
+ widths = self._calculate_column_widths(
489
+ console, options.update_width(max_width - extra_width)
490
+ )
491
+ table_width = sum(widths) + extra_width
492
+
493
+ render_options = options.update(
494
+ width=table_width, highlight=self.highlight, height=None
495
+ )
496
+
497
+ def render_annotation(
498
+ text: TextType, style: StyleType, justify: "JustifyMethod" = "center"
499
+ ) -> "RenderResult":
500
+ render_text = (
501
+ console.render_str(text, style=style, highlight=False)
502
+ if isinstance(text, str)
503
+ else text
504
+ )
505
+ return console.render(
506
+ render_text, options=render_options.update(justify=justify)
507
+ )
508
+
509
+ if self.title:
510
+ yield from render_annotation(
511
+ self.title,
512
+ style=Style.pick_first(self.title_style, "table.title"),
513
+ justify=self.title_justify,
514
+ )
515
+ yield from self._render(console, render_options, widths)
516
+ if self.caption:
517
+ yield from render_annotation(
518
+ self.caption,
519
+ style=Style.pick_first(self.caption_style, "table.caption"),
520
+ justify=self.caption_justify,
521
+ )
522
+
523
+ def _calculate_column_widths(
524
+ self, console: "Console", options: "ConsoleOptions"
525
+ ) -> List[int]:
526
+ """Calculate the widths of each column, including padding, not including borders."""
527
+ max_width = options.max_width
528
+ columns = self.columns
529
+ width_ranges = [
530
+ self._measure_column(console, options, column) for column in columns
531
+ ]
532
+ widths = [_range.maximum or 1 for _range in width_ranges]
533
+ get_padding_width = self._get_padding_width
534
+ extra_width = self._extra_width
535
+ if self.expand:
536
+ ratios = [col.ratio or 0 for col in columns if col.flexible]
537
+ if any(ratios):
538
+ fixed_widths = [
539
+ 0 if column.flexible else _range.maximum
540
+ for _range, column in zip(width_ranges, columns)
541
+ ]
542
+ flex_minimum = [
543
+ (column.width or 1) + get_padding_width(column._index)
544
+ for column in columns
545
+ if column.flexible
546
+ ]
547
+ flexible_width = max_width - sum(fixed_widths)
548
+ flex_widths = ratio_distribute(flexible_width, ratios, flex_minimum)
549
+ iter_flex_widths = iter(flex_widths)
550
+ for index, column in enumerate(columns):
551
+ if column.flexible:
552
+ widths[index] = fixed_widths[index] + next(iter_flex_widths)
553
+ table_width = sum(widths)
554
+
555
+ if table_width > max_width:
556
+ widths = self._collapse_widths(
557
+ widths,
558
+ [(column.width is None and not column.no_wrap) for column in columns],
559
+ max_width,
560
+ )
561
+ table_width = sum(widths)
562
+ # last resort, reduce columns evenly
563
+ if table_width > max_width:
564
+ excess_width = table_width - max_width
565
+ widths = ratio_reduce(excess_width, [1] * len(widths), widths, widths)
566
+ table_width = sum(widths)
567
+
568
+ width_ranges = [
569
+ self._measure_column(console, options.update_width(width), column)
570
+ for width, column in zip(widths, columns)
571
+ ]
572
+ widths = [_range.maximum or 0 for _range in width_ranges]
573
+
574
+ if (table_width < max_width and self.expand) or (
575
+ self.min_width is not None and table_width < (self.min_width - extra_width)
576
+ ):
577
+ _max_width = (
578
+ max_width
579
+ if self.min_width is None
580
+ else min(self.min_width - extra_width, max_width)
581
+ )
582
+ pad_widths = ratio_distribute(_max_width - table_width, widths)
583
+ widths = [_width + pad for _width, pad in zip(widths, pad_widths)]
584
+
585
+ return widths
586
+
587
+ @classmethod
588
+ def _collapse_widths(
589
+ cls, widths: List[int], wrapable: List[bool], max_width: int
590
+ ) -> List[int]:
591
+ """Reduce widths so that the total is under max_width.
592
+
593
+ Args:
594
+ widths (List[int]): List of widths.
595
+ wrapable (List[bool]): List of booleans that indicate if a column may shrink.
596
+ max_width (int): Maximum width to reduce to.
597
+
598
+ Returns:
599
+ List[int]: A new list of widths.
600
+ """
601
+ total_width = sum(widths)
602
+ excess_width = total_width - max_width
603
+ if any(wrapable):
604
+ while total_width and excess_width > 0:
605
+ max_column = max(
606
+ width for width, allow_wrap in zip(widths, wrapable) if allow_wrap
607
+ )
608
+ second_max_column = max(
609
+ width if allow_wrap and width != max_column else 0
610
+ for width, allow_wrap in zip(widths, wrapable)
611
+ )
612
+ column_difference = max_column - second_max_column
613
+ ratios = [
614
+ (1 if (width == max_column and allow_wrap) else 0)
615
+ for width, allow_wrap in zip(widths, wrapable)
616
+ ]
617
+ if not any(ratios) or not column_difference:
618
+ break
619
+ max_reduce = [min(excess_width, column_difference)] * len(widths)
620
+ widths = ratio_reduce(excess_width, ratios, max_reduce, widths)
621
+
622
+ total_width = sum(widths)
623
+ excess_width = total_width - max_width
624
+ return widths
625
+
626
+ def _get_cells(
627
+ self, console: "Console", column_index: int, column: Column
628
+ ) -> Iterable[_Cell]:
629
+ """Get all the cells with padding and optional header."""
630
+
631
+ collapse_padding = self.collapse_padding
632
+ pad_edge = self.pad_edge
633
+ padding = self.padding
634
+ any_padding = any(padding)
635
+
636
+ first_column = column_index == 0
637
+ last_column = column_index == len(self.columns) - 1
638
+
639
+ _padding_cache: Dict[Tuple[bool, bool], Tuple[int, int, int, int]] = {}
640
+
641
+ def get_padding(first_row: bool, last_row: bool) -> Tuple[int, int, int, int]:
642
+ cached = _padding_cache.get((first_row, last_row))
643
+ if cached:
644
+ return cached
645
+ top, right, bottom, left = padding
646
+
647
+ if collapse_padding:
648
+ if not first_column:
649
+ left = max(0, left - right)
650
+ if not last_row:
651
+ bottom = max(0, top - bottom)
652
+
653
+ if not pad_edge:
654
+ if first_column:
655
+ left = 0
656
+ if last_column:
657
+ right = 0
658
+ if first_row:
659
+ top = 0
660
+ if last_row:
661
+ bottom = 0
662
+ _padding = (top, right, bottom, left)
663
+ _padding_cache[(first_row, last_row)] = _padding
664
+ return _padding
665
+
666
+ raw_cells: List[Tuple[StyleType, "RenderableType"]] = []
667
+ _append = raw_cells.append
668
+ get_style = console.get_style
669
+ if self.show_header:
670
+ header_style = get_style(self.header_style or "") + get_style(
671
+ column.header_style
672
+ )
673
+ _append((header_style, column.header))
674
+ cell_style = get_style(column.style or "")
675
+ for cell in column.cells:
676
+ _append((cell_style, cell))
677
+ if self.show_footer:
678
+ footer_style = get_style(self.footer_style or "") + get_style(
679
+ column.footer_style
680
+ )
681
+ _append((footer_style, column.footer))
682
+
683
+ if any_padding:
684
+ _Padding = Padding
685
+ for first, last, (style, renderable) in loop_first_last(raw_cells):
686
+ yield _Cell(
687
+ style,
688
+ _Padding(renderable, get_padding(first, last)),
689
+ getattr(renderable, "vertical", None) or column.vertical,
690
+ )
691
+ else:
692
+ for style, renderable in raw_cells:
693
+ yield _Cell(
694
+ style,
695
+ renderable,
696
+ getattr(renderable, "vertical", None) or column.vertical,
697
+ )
698
+
699
+ def _get_padding_width(self, column_index: int) -> int:
700
+ """Get extra width from padding."""
701
+ _, pad_right, _, pad_left = self.padding
702
+ if self.collapse_padding:
703
+ if column_index > 0:
704
+ pad_left = max(0, pad_left - pad_right)
705
+ return pad_left + pad_right
706
+
707
+ def _measure_column(
708
+ self,
709
+ console: "Console",
710
+ options: "ConsoleOptions",
711
+ column: Column,
712
+ ) -> Measurement:
713
+ """Get the minimum and maximum width of the column."""
714
+
715
+ max_width = options.max_width
716
+ if max_width < 1:
717
+ return Measurement(0, 0)
718
+
719
+ padding_width = self._get_padding_width(column._index)
720
+
721
+ if column.width is not None:
722
+ # Fixed width column
723
+ return Measurement(
724
+ column.width + padding_width, column.width + padding_width
725
+ ).with_maximum(max_width)
726
+ # Flexible column, we need to measure contents
727
+ min_widths: List[int] = []
728
+ max_widths: List[int] = []
729
+ append_min = min_widths.append
730
+ append_max = max_widths.append
731
+ get_render_width = Measurement.get
732
+ for cell in self._get_cells(console, column._index, column):
733
+ _min, _max = get_render_width(console, options, cell.renderable)
734
+ append_min(_min)
735
+ append_max(_max)
736
+
737
+ measurement = Measurement(
738
+ max(min_widths) if min_widths else 1,
739
+ max(max_widths) if max_widths else max_width,
740
+ ).with_maximum(max_width)
741
+ measurement = measurement.clamp(
742
+ None if column.min_width is None else column.min_width + padding_width,
743
+ None if column.max_width is None else column.max_width + padding_width,
744
+ )
745
+ return measurement
746
+
747
+ def _render(
748
+ self, console: "Console", options: "ConsoleOptions", widths: List[int]
749
+ ) -> "RenderResult":
750
+ table_style = console.get_style(self.style or "")
751
+
752
+ border_style = table_style + console.get_style(self.border_style or "")
753
+ _column_cells = (
754
+ self._get_cells(console, column_index, column)
755
+ for column_index, column in enumerate(self.columns)
756
+ )
757
+ row_cells: List[Tuple[_Cell, ...]] = list(zip(*_column_cells))
758
+ _box = (
759
+ self.box.substitute(
760
+ options, safe=pick_bool(self.safe_box, console.safe_box)
761
+ )
762
+ if self.box
763
+ else None
764
+ )
765
+ _box = _box.get_plain_headed_box() if _box and not self.show_header else _box
766
+
767
+ new_line = Segment.line()
768
+
769
+ columns = self.columns
770
+ show_header = self.show_header
771
+ show_footer = self.show_footer
772
+ show_edge = self.show_edge
773
+ show_lines = self.show_lines
774
+ leading = self.leading
775
+
776
+ _Segment = Segment
777
+ if _box:
778
+ box_segments = [
779
+ (
780
+ _Segment(_box.head_left, border_style),
781
+ _Segment(_box.head_right, border_style),
782
+ _Segment(_box.head_vertical, border_style),
783
+ ),
784
+ (
785
+ _Segment(_box.mid_left, border_style),
786
+ _Segment(_box.mid_right, border_style),
787
+ _Segment(_box.mid_vertical, border_style),
788
+ ),
789
+ (
790
+ _Segment(_box.foot_left, border_style),
791
+ _Segment(_box.foot_right, border_style),
792
+ _Segment(_box.foot_vertical, border_style),
793
+ ),
794
+ ]
795
+ if show_edge:
796
+ yield _Segment(_box.get_top(widths), border_style)
797
+ yield new_line
798
+ else:
799
+ box_segments = []
800
+
801
+ get_row_style = self.get_row_style
802
+ get_style = console.get_style
803
+
804
+ for index, (first, last, row_cell) in enumerate(loop_first_last(row_cells)):
805
+ header_row = first and show_header
806
+ footer_row = last and show_footer
807
+ row = (
808
+ self.rows[index - show_header]
809
+ if (not header_row and not footer_row)
810
+ else None
811
+ )
812
+ max_height = 1
813
+ cells: List[List[List[Segment]]] = []
814
+ if header_row or footer_row:
815
+ row_style = Style.null()
816
+ else:
817
+ row_style = get_style(
818
+ get_row_style(console, index - 1 if show_header else index)
819
+ )
820
+ for width, cell, column in zip(widths, row_cell, columns):
821
+ render_options = options.update(
822
+ width=width,
823
+ justify=column.justify,
824
+ no_wrap=column.no_wrap,
825
+ overflow=column.overflow,
826
+ height=None,
827
+ highlight=column.highlight,
828
+ )
829
+ lines = console.render_lines(
830
+ cell.renderable,
831
+ render_options,
832
+ style=get_style(cell.style) + row_style,
833
+ )
834
+ max_height = max(max_height, len(lines))
835
+ cells.append(lines)
836
+
837
+ row_height = max(len(cell) for cell in cells)
838
+
839
+ def align_cell(
840
+ cell: List[List[Segment]],
841
+ vertical: "VerticalAlignMethod",
842
+ width: int,
843
+ style: Style,
844
+ ) -> List[List[Segment]]:
845
+ if header_row:
846
+ vertical = "bottom"
847
+ elif footer_row:
848
+ vertical = "top"
849
+
850
+ if vertical == "top":
851
+ return _Segment.align_top(cell, width, row_height, style)
852
+ elif vertical == "middle":
853
+ return _Segment.align_middle(cell, width, row_height, style)
854
+ return _Segment.align_bottom(cell, width, row_height, style)
855
+
856
+ cells[:] = [
857
+ _Segment.set_shape(
858
+ align_cell(
859
+ cell,
860
+ _cell.vertical,
861
+ width,
862
+ get_style(_cell.style) + row_style,
863
+ ),
864
+ width,
865
+ max_height,
866
+ )
867
+ for width, _cell, cell, column in zip(widths, row_cell, cells, columns)
868
+ ]
869
+
870
+ if _box:
871
+ if last and show_footer:
872
+ yield _Segment(
873
+ _box.get_row(widths, "foot", edge=show_edge), border_style
874
+ )
875
+ yield new_line
876
+ left, right, _divider = box_segments[0 if first else (2 if last else 1)]
877
+
878
+ # If the column divider is whitespace also style it with the row background
879
+ divider = (
880
+ _divider
881
+ if _divider.text.strip()
882
+ else _Segment(
883
+ _divider.text, row_style.background_style + _divider.style
884
+ )
885
+ )
886
+ for line_no in range(max_height):
887
+ if show_edge:
888
+ yield left
889
+ for last_cell, rendered_cell in loop_last(cells):
890
+ yield from rendered_cell[line_no]
891
+ if not last_cell:
892
+ yield divider
893
+ if show_edge:
894
+ yield right
895
+ yield new_line
896
+ else:
897
+ for line_no in range(max_height):
898
+ for rendered_cell in cells:
899
+ yield from rendered_cell[line_no]
900
+ yield new_line
901
+ if _box and first and show_header:
902
+ yield _Segment(
903
+ _box.get_row(widths, "head", edge=show_edge), border_style
904
+ )
905
+ yield new_line
906
+ end_section = row and row.end_section
907
+ if _box and (show_lines or leading or end_section):
908
+ if (
909
+ not last
910
+ and not (show_footer and index >= len(row_cells) - 2)
911
+ and not (show_header and header_row)
912
+ ):
913
+ if leading:
914
+ yield _Segment(
915
+ _box.get_row(widths, "mid", edge=show_edge) * leading,
916
+ border_style,
917
+ )
918
+ else:
919
+ yield _Segment(
920
+ _box.get_row(widths, "row", edge=show_edge), border_style
921
+ )
922
+ yield new_line
923
+
924
+ if _box and show_edge:
925
+ yield _Segment(_box.get_bottom(widths), border_style)
926
+ yield new_line
927
+
928
+
929
+ if __name__ == "__main__": # pragma: no cover
930
+ from pip._vendor.rich.console import Console
931
+ from pip._vendor.rich.highlighter import ReprHighlighter
932
+ from pip._vendor.rich.table import Table as Table
933
+
934
+ from ._timer import timer
935
+
936
+ with timer("Table render"):
937
+ table = Table(
938
+ title="Star Wars Movies",
939
+ caption="Rich example table",
940
+ caption_justify="right",
941
+ )
942
+
943
+ table.add_column(
944
+ "Released", header_style="bright_cyan", style="cyan", no_wrap=True
945
+ )
946
+ table.add_column("Title", style="magenta")
947
+ table.add_column("Box Office", justify="right", style="green")
948
+
949
+ table.add_row(
950
+ "Dec 20, 2019",
951
+ "Star Wars: The Rise of Skywalker",
952
+ "$952,110,690",
953
+ )
954
+ table.add_row("May 25, 2018", "Solo: A Star Wars Story", "$393,151,347")
955
+ table.add_row(
956
+ "Dec 15, 2017",
957
+ "Star Wars Ep. V111: The Last Jedi",
958
+ "$1,332,539,889",
959
+ style="on black",
960
+ end_section=True,
961
+ )
962
+ table.add_row(
963
+ "Dec 16, 2016",
964
+ "Rogue One: A Star Wars Story",
965
+ "$1,332,439,889",
966
+ )
967
+
968
+ def header(text: str) -> None:
969
+ console.print()
970
+ console.rule(highlight(text))
971
+ console.print()
972
+
973
+ console = Console()
974
+ highlight = ReprHighlighter()
975
+ header("Example Table")
976
+ console.print(table, justify="center")
977
+
978
+ table.expand = True
979
+ header("expand=True")
980
+ console.print(table)
981
+
982
+ table.width = 50
983
+ header("width=50")
984
+
985
+ console.print(table, justify="center")
986
+
987
+ table.width = None
988
+ table.expand = False
989
+ table.row_styles = ["dim", "none"]
990
+ header("row_styles=['dim', 'none']")
991
+
992
+ console.print(table, justify="center")
993
+
994
+ table.width = None
995
+ table.expand = False
996
+ table.row_styles = ["dim", "none"]
997
+ table.leading = 1
998
+ header("leading=1, row_styles=['dim', 'none']")
999
+ console.print(table, justify="center")
1000
+
1001
+ table.width = None
1002
+ table.expand = False
1003
+ table.row_styles = ["dim", "none"]
1004
+ table.show_lines = True
1005
+ table.leading = 0
1006
+ header("show_lines=True, row_styles=['dim', 'none']")
1007
+ console.print(table, justify="center")
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Cipher/test_CAST.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # SelfTest/Cipher/CAST.py: Self-test for the CAST-128 (CAST5) cipher
4
+ #
5
+ # Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
6
+ #
7
+ # ===================================================================
8
+ # The contents of this file are dedicated to the public domain. To
9
+ # the extent that dedication to the public domain is not available,
10
+ # everyone is granted a worldwide, perpetual, royalty-free,
11
+ # non-exclusive license to exercise all rights associated with the
12
+ # contents of this file for any purpose whatsoever.
13
+ # No rights are reserved.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # ===================================================================
24
+
25
+ """Self-test suite for Crypto.Cipher.CAST"""
26
+
27
+ import unittest
28
+
29
+ from Crypto.Util.py3compat import bchr
30
+
31
+ from Crypto.Cipher import CAST
32
+
33
+ # This is a list of (plaintext, ciphertext, key) tuples.
34
+ test_data = [
35
+ # Test vectors from RFC 2144, B.1
36
+ ('0123456789abcdef', '238b4fe5847e44b2',
37
+ '0123456712345678234567893456789a',
38
+ '128-bit key'),
39
+
40
+ ('0123456789abcdef', 'eb6a711a2c02271b',
41
+ '01234567123456782345',
42
+ '80-bit key'),
43
+
44
+ ('0123456789abcdef', '7ac816d16e9b302e',
45
+ '0123456712',
46
+ '40-bit key'),
47
+ ]
48
+
49
+
50
+ class KeyLength(unittest.TestCase):
51
+
52
+ def runTest(self):
53
+ self.assertRaises(ValueError, CAST.new, bchr(0) * 4, CAST.MODE_ECB)
54
+ self.assertRaises(ValueError, CAST.new, bchr(0) * 17, CAST.MODE_ECB)
55
+
56
+
57
+ class TestOutput(unittest.TestCase):
58
+
59
+ def runTest(self):
60
+ # Encrypt/Decrypt data and test output parameter
61
+
62
+ cipher = CAST.new(b'4'*16, CAST.MODE_ECB)
63
+
64
+ pt = b'5' * 16
65
+ ct = cipher.encrypt(pt)
66
+
67
+ output = bytearray(16)
68
+ res = cipher.encrypt(pt, output=output)
69
+ self.assertEqual(ct, output)
70
+ self.assertEqual(res, None)
71
+
72
+ res = cipher.decrypt(ct, output=output)
73
+ self.assertEqual(pt, output)
74
+ self.assertEqual(res, None)
75
+
76
+ output = memoryview(bytearray(16))
77
+ cipher.encrypt(pt, output=output)
78
+ self.assertEqual(ct, output)
79
+
80
+ cipher.decrypt(ct, output=output)
81
+ self.assertEqual(pt, output)
82
+
83
+ self.assertRaises(TypeError, cipher.encrypt, pt, output=b'0'*16)
84
+ self.assertRaises(TypeError, cipher.decrypt, ct, output=b'0'*16)
85
+
86
+ shorter_output = bytearray(7)
87
+ self.assertRaises(ValueError, cipher.encrypt, pt, output=shorter_output)
88
+ self.assertRaises(ValueError, cipher.decrypt, ct, output=shorter_output)
89
+
90
+
91
+ def get_tests(config={}):
92
+ from .common import make_block_tests
93
+
94
+ tests = make_block_tests(CAST, "CAST", test_data)
95
+ tests.append(KeyLength())
96
+ tests.append(TestOutput())
97
+ return tests
98
+
99
+ if __name__ == '__main__':
100
+ suite = lambda: unittest.TestSuite(get_tests())
101
+ unittest.main(defaultTest='suite')
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.96 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/common.cpython-310.pyc ADDED
Binary file (7.07 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_CMAC.cpython-310.pyc ADDED
Binary file (9.02 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_HMAC.cpython-310.pyc ADDED
Binary file (14.3 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_KMAC.cpython-310.pyc ADDED
Binary file (9.2 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_KangarooTwelve.cpython-310.pyc ADDED
Binary file (10.7 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_MD2.cpython-310.pyc ADDED
Binary file (1.31 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_MD4.cpython-310.pyc ADDED
Binary file (1.34 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_MD5.cpython-310.pyc ADDED
Binary file (2.23 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_Poly1305.cpython-310.pyc ADDED
Binary file (14.5 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_RIPEMD160.cpython-310.pyc ADDED
Binary file (1.55 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA1.cpython-310.pyc ADDED
Binary file (2.18 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA224.cpython-310.pyc ADDED
Binary file (1.37 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA256.cpython-310.pyc ADDED
Binary file (2.23 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA384.cpython-310.pyc ADDED
Binary file (1.5 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_224.cpython-310.pyc ADDED
Binary file (2.01 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_256.cpython-310.pyc ADDED
Binary file (2.01 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_384.cpython-310.pyc ADDED
Binary file (2.01 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_SHA3_512.cpython-310.pyc ADDED
Binary file (2.01 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_TupleHash.cpython-310.pyc ADDED
Binary file (7.31 kB). View file
 
minigpt2/lib/python3.10/site-packages/Crypto/SelfTest/Hash/__pycache__/test_TurboSHAKE.cpython-310.pyc ADDED
Binary file (14.9 kB). View file