ZTWHHH commited on
Commit
c2e3c48
·
verified ·
1 Parent(s): 047fc19

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/rich/_export_format.py +76 -0
  2. llava/lib/python3.10/site-packages/pip/_vendor/rich/_extension.py +10 -0
  3. llava/lib/python3.10/site-packages/pip/_vendor/rich/_null_file.py +69 -0
  4. llava/lib/python3.10/site-packages/pip/_vendor/rich/_pick.py +17 -0
  5. llava/lib/python3.10/site-packages/pip/_vendor/rich/_timer.py +19 -0
  6. llava/lib/python3.10/site-packages/pip/_vendor/rich/_win32_console.py +661 -0
  7. llava/lib/python3.10/site-packages/pip/_vendor/rich/_windows.py +71 -0
  8. llava/lib/python3.10/site-packages/pip/_vendor/rich/abc.py +33 -0
  9. llava/lib/python3.10/site-packages/pip/_vendor/rich/color.py +621 -0
  10. llava/lib/python3.10/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
  11. llava/lib/python3.10/site-packages/pip/_vendor/rich/columns.py +187 -0
  12. llava/lib/python3.10/site-packages/pip/_vendor/rich/emoji.py +96 -0
  13. llava/lib/python3.10/site-packages/pip/_vendor/rich/errors.py +34 -0
  14. llava/lib/python3.10/site-packages/pip/_vendor/rich/jupyter.py +101 -0
  15. llava/lib/python3.10/site-packages/pip/_vendor/rich/layout.py +442 -0
  16. llava/lib/python3.10/site-packages/pip/_vendor/rich/live.py +375 -0
  17. llava/lib/python3.10/site-packages/pip/_vendor/rich/live_render.py +112 -0
  18. llava/lib/python3.10/site-packages/pip/_vendor/rich/measure.py +151 -0
  19. llava/lib/python3.10/site-packages/pip/_vendor/rich/pager.py +34 -0
  20. llava/lib/python3.10/site-packages/pip/_vendor/rich/pretty.py +1016 -0
  21. llava/lib/python3.10/site-packages/pip/_vendor/rich/region.py +10 -0
  22. llava/lib/python3.10/site-packages/pip/_vendor/rich/scope.py +86 -0
  23. llava/lib/python3.10/site-packages/pip/_vendor/rich/styled.py +42 -0
  24. minigpt2/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle.cpython-310.pyc +0 -0
  25. minigpt2/lib/python3.10/site-packages/cloudpickle/cloudpickle_fast.py +14 -0
  26. minigpt2/lib/python3.10/site-packages/imageio/__init__.py +131 -0
  27. minigpt2/lib/python3.10/site-packages/imageio/__main__.py +169 -0
  28. minigpt2/lib/python3.10/site-packages/imageio/testing.py +69 -0
  29. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/INSTALLER +1 -0
  30. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/RECORD +164 -0
  31. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/REQUESTED +0 -0
  32. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/WHEEL +5 -0
  33. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/licenses/LICENSE.md +30 -0
  34. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/licenses/licenses/LICENSE.libsodium.txt +18 -0
  35. minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/licenses/licenses/LICENSE.zeromq.txt +373 -0
  36. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/INSTALLER +1 -0
  37. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/LICENSE +21 -0
  38. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/METADATA +169 -0
  39. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/RECORD +23 -0
  40. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/REQUESTED +0 -0
  41. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/WHEEL +6 -0
  42. minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/top_level.txt +2 -0
  43. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_convert_weight_to_int4pack_cpu_dispatch.h +23 -0
  44. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_efficient_attention_backward_native.h +21 -0
  45. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_fft_c2c_native.h +24 -0
  46. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_fill_mem_eff_dropout_mask_meta_dispatch.h +23 -0
  47. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_pin_memory_compositeexplicitautograd_dispatch.h +24 -0
  48. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_sobol_engine_scramble_ops.h +28 -0
  49. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_softmax_backward_data_meta_dispatch.h +25 -0
  50. parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_semi_structured_apply_dense_native.h +21 -0
llava/lib/python3.10/site-packages/pip/_vendor/rich/_export_format.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CONSOLE_HTML_FORMAT = """\
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <style>
7
+ {stylesheet}
8
+ body {{
9
+ color: {foreground};
10
+ background-color: {background};
11
+ }}
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{code}</code></pre>
16
+ </body>
17
+ </html>
18
+ """
19
+
20
+ CONSOLE_SVG_FORMAT = """\
21
+ <svg class="rich-terminal" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
22
+ <!-- Generated with Rich https://www.textualize.io -->
23
+ <style>
24
+
25
+ @font-face {{
26
+ font-family: "Fira Code";
27
+ src: local("FiraCode-Regular"),
28
+ url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
29
+ url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
30
+ font-style: normal;
31
+ font-weight: 400;
32
+ }}
33
+ @font-face {{
34
+ font-family: "Fira Code";
35
+ src: local("FiraCode-Bold"),
36
+ url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
37
+ url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
38
+ font-style: bold;
39
+ font-weight: 700;
40
+ }}
41
+
42
+ .{unique_id}-matrix {{
43
+ font-family: Fira Code, monospace;
44
+ font-size: {char_height}px;
45
+ line-height: {line_height}px;
46
+ font-variant-east-asian: full-width;
47
+ }}
48
+
49
+ .{unique_id}-title {{
50
+ font-size: 18px;
51
+ font-weight: bold;
52
+ font-family: arial;
53
+ }}
54
+
55
+ {styles}
56
+ </style>
57
+
58
+ <defs>
59
+ <clipPath id="{unique_id}-clip-terminal">
60
+ <rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
61
+ </clipPath>
62
+ {lines}
63
+ </defs>
64
+
65
+ {chrome}
66
+ <g transform="translate({terminal_x}, {terminal_y})" clip-path="url(#{unique_id}-clip-terminal)">
67
+ {backgrounds}
68
+ <g class="{unique_id}-matrix">
69
+ {matrix}
70
+ </g>
71
+ </g>
72
+ </svg>
73
+ """
74
+
75
+ _SVG_FONT_FAMILY = "Rich Fira Code"
76
+ _SVG_CLASSES_PREFIX = "rich-svg"
llava/lib/python3.10/site-packages/pip/_vendor/rich/_extension.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any
2
+
3
+
4
+ def load_ipython_extension(ip: Any) -> None: # pragma: no cover
5
+ # prevent circular import
6
+ from pip._vendor.rich.pretty import install
7
+ from pip._vendor.rich.traceback import install as tr_install
8
+
9
+ install()
10
+ tr_install()
llava/lib/python3.10/site-packages/pip/_vendor/rich/_null_file.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from types import TracebackType
2
+ from typing import IO, Iterable, Iterator, List, Optional, Type
3
+
4
+
5
+ class NullFile(IO[str]):
6
+ def close(self) -> None:
7
+ pass
8
+
9
+ def isatty(self) -> bool:
10
+ return False
11
+
12
+ def read(self, __n: int = 1) -> str:
13
+ return ""
14
+
15
+ def readable(self) -> bool:
16
+ return False
17
+
18
+ def readline(self, __limit: int = 1) -> str:
19
+ return ""
20
+
21
+ def readlines(self, __hint: int = 1) -> List[str]:
22
+ return []
23
+
24
+ def seek(self, __offset: int, __whence: int = 1) -> int:
25
+ return 0
26
+
27
+ def seekable(self) -> bool:
28
+ return False
29
+
30
+ def tell(self) -> int:
31
+ return 0
32
+
33
+ def truncate(self, __size: Optional[int] = 1) -> int:
34
+ return 0
35
+
36
+ def writable(self) -> bool:
37
+ return False
38
+
39
+ def writelines(self, __lines: Iterable[str]) -> None:
40
+ pass
41
+
42
+ def __next__(self) -> str:
43
+ return ""
44
+
45
+ def __iter__(self) -> Iterator[str]:
46
+ return iter([""])
47
+
48
+ def __enter__(self) -> IO[str]:
49
+ return self
50
+
51
+ def __exit__(
52
+ self,
53
+ __t: Optional[Type[BaseException]],
54
+ __value: Optional[BaseException],
55
+ __traceback: Optional[TracebackType],
56
+ ) -> None:
57
+ pass
58
+
59
+ def write(self, text: str) -> int:
60
+ return 0
61
+
62
+ def flush(self) -> None:
63
+ pass
64
+
65
+ def fileno(self) -> int:
66
+ return -1
67
+
68
+
69
+ NULL_FILE = NullFile()
llava/lib/python3.10/site-packages/pip/_vendor/rich/_pick.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+
4
+ def pick_bool(*values: Optional[bool]) -> bool:
5
+ """Pick the first non-none bool or return the last value.
6
+
7
+ Args:
8
+ *values (bool): Any number of boolean or None values.
9
+
10
+ Returns:
11
+ bool: First non-none boolean.
12
+ """
13
+ assert values, "1 or more values required"
14
+ for value in values:
15
+ if value is not None:
16
+ return value
17
+ return bool(value)
llava/lib/python3.10/site-packages/pip/_vendor/rich/_timer.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Timer context manager, only used in debug.
3
+
4
+ """
5
+
6
+ from time import time
7
+
8
+ import contextlib
9
+ from typing import Generator
10
+
11
+
12
+ @contextlib.contextmanager
13
+ def timer(subject: str = "time") -> Generator[None, None, None]:
14
+ """print the elapsed time. (only used in debugging)"""
15
+ start = time()
16
+ yield
17
+ elapsed = time() - start
18
+ elapsed_ms = elapsed * 1000
19
+ print(f"{subject} elapsed {elapsed_ms:.1f}ms")
llava/lib/python3.10/site-packages/pip/_vendor/rich/_win32_console.py ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Light wrapper around the Win32 Console API - this module should only be imported on Windows
2
+
3
+ The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
4
+ """
5
+
6
+ import ctypes
7
+ import sys
8
+ from typing import Any
9
+
10
+ windll: Any = None
11
+ if sys.platform == "win32":
12
+ windll = ctypes.LibraryLoader(ctypes.WinDLL)
13
+ else:
14
+ raise ImportError(f"{__name__} can only be imported on Windows")
15
+
16
+ import time
17
+ from ctypes import Structure, byref, wintypes
18
+ from typing import IO, NamedTuple, Type, cast
19
+
20
+ from pip._vendor.rich.color import ColorSystem
21
+ from pip._vendor.rich.style import Style
22
+
23
+ STDOUT = -11
24
+ ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
25
+
26
+ COORD = wintypes._COORD
27
+
28
+
29
+ class LegacyWindowsError(Exception):
30
+ pass
31
+
32
+
33
+ class WindowsCoordinates(NamedTuple):
34
+ """Coordinates in the Windows Console API are (y, x), not (x, y).
35
+ This class is intended to prevent that confusion.
36
+ Rows and columns are indexed from 0.
37
+ This class can be used in place of wintypes._COORD in arguments and argtypes.
38
+ """
39
+
40
+ row: int
41
+ col: int
42
+
43
+ @classmethod
44
+ def from_param(cls, value: "WindowsCoordinates") -> COORD:
45
+ """Converts a WindowsCoordinates into a wintypes _COORD structure.
46
+ This classmethod is internally called by ctypes to perform the conversion.
47
+
48
+ Args:
49
+ value (WindowsCoordinates): The input coordinates to convert.
50
+
51
+ Returns:
52
+ wintypes._COORD: The converted coordinates struct.
53
+ """
54
+ return COORD(value.col, value.row)
55
+
56
+
57
+ class CONSOLE_SCREEN_BUFFER_INFO(Structure):
58
+ _fields_ = [
59
+ ("dwSize", COORD),
60
+ ("dwCursorPosition", COORD),
61
+ ("wAttributes", wintypes.WORD),
62
+ ("srWindow", wintypes.SMALL_RECT),
63
+ ("dwMaximumWindowSize", COORD),
64
+ ]
65
+
66
+
67
+ class CONSOLE_CURSOR_INFO(ctypes.Structure):
68
+ _fields_ = [("dwSize", wintypes.DWORD), ("bVisible", wintypes.BOOL)]
69
+
70
+
71
+ _GetStdHandle = windll.kernel32.GetStdHandle
72
+ _GetStdHandle.argtypes = [
73
+ wintypes.DWORD,
74
+ ]
75
+ _GetStdHandle.restype = wintypes.HANDLE
76
+
77
+
78
+ def GetStdHandle(handle: int = STDOUT) -> wintypes.HANDLE:
79
+ """Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
80
+
81
+ Args:
82
+ handle (int): Integer identifier for the handle. Defaults to -11 (stdout).
83
+
84
+ Returns:
85
+ wintypes.HANDLE: The handle
86
+ """
87
+ return cast(wintypes.HANDLE, _GetStdHandle(handle))
88
+
89
+
90
+ _GetConsoleMode = windll.kernel32.GetConsoleMode
91
+ _GetConsoleMode.argtypes = [wintypes.HANDLE, wintypes.LPDWORD]
92
+ _GetConsoleMode.restype = wintypes.BOOL
93
+
94
+
95
+ def GetConsoleMode(std_handle: wintypes.HANDLE) -> int:
96
+ """Retrieves the current input mode of a console's input buffer
97
+ or the current output mode of a console screen buffer.
98
+
99
+ Args:
100
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
101
+
102
+ Raises:
103
+ LegacyWindowsError: If any error occurs while calling the Windows console API.
104
+
105
+ Returns:
106
+ int: Value representing the current console mode as documented at
107
+ https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters
108
+ """
109
+
110
+ console_mode = wintypes.DWORD()
111
+ success = bool(_GetConsoleMode(std_handle, console_mode))
112
+ if not success:
113
+ raise LegacyWindowsError("Unable to get legacy Windows Console Mode")
114
+ return console_mode.value
115
+
116
+
117
+ _FillConsoleOutputCharacterW = windll.kernel32.FillConsoleOutputCharacterW
118
+ _FillConsoleOutputCharacterW.argtypes = [
119
+ wintypes.HANDLE,
120
+ ctypes.c_char,
121
+ wintypes.DWORD,
122
+ cast(Type[COORD], WindowsCoordinates),
123
+ ctypes.POINTER(wintypes.DWORD),
124
+ ]
125
+ _FillConsoleOutputCharacterW.restype = wintypes.BOOL
126
+
127
+
128
+ def FillConsoleOutputCharacter(
129
+ std_handle: wintypes.HANDLE,
130
+ char: str,
131
+ length: int,
132
+ start: WindowsCoordinates,
133
+ ) -> int:
134
+ """Writes a character to the console screen buffer a specified number of times, beginning at the specified coordinates.
135
+
136
+ Args:
137
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
138
+ char (str): The character to write. Must be a string of length 1.
139
+ length (int): The number of times to write the character.
140
+ start (WindowsCoordinates): The coordinates to start writing at.
141
+
142
+ Returns:
143
+ int: The number of characters written.
144
+ """
145
+ character = ctypes.c_char(char.encode())
146
+ num_characters = wintypes.DWORD(length)
147
+ num_written = wintypes.DWORD(0)
148
+ _FillConsoleOutputCharacterW(
149
+ std_handle,
150
+ character,
151
+ num_characters,
152
+ start,
153
+ byref(num_written),
154
+ )
155
+ return num_written.value
156
+
157
+
158
+ _FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
159
+ _FillConsoleOutputAttribute.argtypes = [
160
+ wintypes.HANDLE,
161
+ wintypes.WORD,
162
+ wintypes.DWORD,
163
+ cast(Type[COORD], WindowsCoordinates),
164
+ ctypes.POINTER(wintypes.DWORD),
165
+ ]
166
+ _FillConsoleOutputAttribute.restype = wintypes.BOOL
167
+
168
+
169
+ def FillConsoleOutputAttribute(
170
+ std_handle: wintypes.HANDLE,
171
+ attributes: int,
172
+ length: int,
173
+ start: WindowsCoordinates,
174
+ ) -> int:
175
+ """Sets the character attributes for a specified number of character cells,
176
+ beginning at the specified coordinates in a screen buffer.
177
+
178
+ Args:
179
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
180
+ attributes (int): Integer value representing the foreground and background colours of the cells.
181
+ length (int): The number of cells to set the output attribute of.
182
+ start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set.
183
+
184
+ Returns:
185
+ int: The number of cells whose attributes were actually set.
186
+ """
187
+ num_cells = wintypes.DWORD(length)
188
+ style_attrs = wintypes.WORD(attributes)
189
+ num_written = wintypes.DWORD(0)
190
+ _FillConsoleOutputAttribute(
191
+ std_handle, style_attrs, num_cells, start, byref(num_written)
192
+ )
193
+ return num_written.value
194
+
195
+
196
+ _SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
197
+ _SetConsoleTextAttribute.argtypes = [
198
+ wintypes.HANDLE,
199
+ wintypes.WORD,
200
+ ]
201
+ _SetConsoleTextAttribute.restype = wintypes.BOOL
202
+
203
+
204
+ def SetConsoleTextAttribute(
205
+ std_handle: wintypes.HANDLE, attributes: wintypes.WORD
206
+ ) -> bool:
207
+ """Set the colour attributes for all text written after this function is called.
208
+
209
+ Args:
210
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
211
+ attributes (int): Integer value representing the foreground and background colours.
212
+
213
+
214
+ Returns:
215
+ bool: True if the attribute was set successfully, otherwise False.
216
+ """
217
+ return bool(_SetConsoleTextAttribute(std_handle, attributes))
218
+
219
+
220
+ _GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
221
+ _GetConsoleScreenBufferInfo.argtypes = [
222
+ wintypes.HANDLE,
223
+ ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO),
224
+ ]
225
+ _GetConsoleScreenBufferInfo.restype = wintypes.BOOL
226
+
227
+
228
+ def GetConsoleScreenBufferInfo(
229
+ std_handle: wintypes.HANDLE,
230
+ ) -> CONSOLE_SCREEN_BUFFER_INFO:
231
+ """Retrieves information about the specified console screen buffer.
232
+
233
+ Args:
234
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
235
+
236
+ Returns:
237
+ CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about
238
+ screen size, cursor position, colour attributes, and more."""
239
+ console_screen_buffer_info = CONSOLE_SCREEN_BUFFER_INFO()
240
+ _GetConsoleScreenBufferInfo(std_handle, byref(console_screen_buffer_info))
241
+ return console_screen_buffer_info
242
+
243
+
244
+ _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
245
+ _SetConsoleCursorPosition.argtypes = [
246
+ wintypes.HANDLE,
247
+ cast(Type[COORD], WindowsCoordinates),
248
+ ]
249
+ _SetConsoleCursorPosition.restype = wintypes.BOOL
250
+
251
+
252
+ def SetConsoleCursorPosition(
253
+ std_handle: wintypes.HANDLE, coords: WindowsCoordinates
254
+ ) -> bool:
255
+ """Set the position of the cursor in the console screen
256
+
257
+ Args:
258
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
259
+ coords (WindowsCoordinates): The coordinates to move the cursor to.
260
+
261
+ Returns:
262
+ bool: True if the function succeeds, otherwise False.
263
+ """
264
+ return bool(_SetConsoleCursorPosition(std_handle, coords))
265
+
266
+
267
+ _GetConsoleCursorInfo = windll.kernel32.GetConsoleCursorInfo
268
+ _GetConsoleCursorInfo.argtypes = [
269
+ wintypes.HANDLE,
270
+ ctypes.POINTER(CONSOLE_CURSOR_INFO),
271
+ ]
272
+ _GetConsoleCursorInfo.restype = wintypes.BOOL
273
+
274
+
275
+ def GetConsoleCursorInfo(
276
+ std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
277
+ ) -> bool:
278
+ """Get the cursor info - used to get cursor visibility and width
279
+
280
+ Args:
281
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
282
+ cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information
283
+ about the console's cursor.
284
+
285
+ Returns:
286
+ bool: True if the function succeeds, otherwise False.
287
+ """
288
+ return bool(_GetConsoleCursorInfo(std_handle, byref(cursor_info)))
289
+
290
+
291
+ _SetConsoleCursorInfo = windll.kernel32.SetConsoleCursorInfo
292
+ _SetConsoleCursorInfo.argtypes = [
293
+ wintypes.HANDLE,
294
+ ctypes.POINTER(CONSOLE_CURSOR_INFO),
295
+ ]
296
+ _SetConsoleCursorInfo.restype = wintypes.BOOL
297
+
298
+
299
+ def SetConsoleCursorInfo(
300
+ std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
301
+ ) -> bool:
302
+ """Set the cursor info - used for adjusting cursor visibility and width
303
+
304
+ Args:
305
+ std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
306
+ cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info.
307
+
308
+ Returns:
309
+ bool: True if the function succeeds, otherwise False.
310
+ """
311
+ return bool(_SetConsoleCursorInfo(std_handle, byref(cursor_info)))
312
+
313
+
314
+ _SetConsoleTitle = windll.kernel32.SetConsoleTitleW
315
+ _SetConsoleTitle.argtypes = [wintypes.LPCWSTR]
316
+ _SetConsoleTitle.restype = wintypes.BOOL
317
+
318
+
319
+ def SetConsoleTitle(title: str) -> bool:
320
+ """Sets the title of the current console window
321
+
322
+ Args:
323
+ title (str): The new title of the console window.
324
+
325
+ Returns:
326
+ bool: True if the function succeeds, otherwise False.
327
+ """
328
+ return bool(_SetConsoleTitle(title))
329
+
330
+
331
+ class LegacyWindowsTerm:
332
+ """This class allows interaction with the legacy Windows Console API. It should only be used in the context
333
+ of environments where virtual terminal processing is not available. However, if it is used in a Windows environment,
334
+ the entire API should work.
335
+
336
+ Args:
337
+ file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout.
338
+ """
339
+
340
+ BRIGHT_BIT = 8
341
+
342
+ # Indices are ANSI color numbers, values are the corresponding Windows Console API color numbers
343
+ ANSI_TO_WINDOWS = [
344
+ 0, # black The Windows colours are defined in wincon.h as follows:
345
+ 4, # red define FOREGROUND_BLUE 0x0001 -- 0000 0001
346
+ 2, # green define FOREGROUND_GREEN 0x0002 -- 0000 0010
347
+ 6, # yellow define FOREGROUND_RED 0x0004 -- 0000 0100
348
+ 1, # blue define FOREGROUND_INTENSITY 0x0008 -- 0000 1000
349
+ 5, # magenta define BACKGROUND_BLUE 0x0010 -- 0001 0000
350
+ 3, # cyan define BACKGROUND_GREEN 0x0020 -- 0010 0000
351
+ 7, # white define BACKGROUND_RED 0x0040 -- 0100 0000
352
+ 8, # bright black (grey) define BACKGROUND_INTENSITY 0x0080 -- 1000 0000
353
+ 12, # bright red
354
+ 10, # bright green
355
+ 14, # bright yellow
356
+ 9, # bright blue
357
+ 13, # bright magenta
358
+ 11, # bright cyan
359
+ 15, # bright white
360
+ ]
361
+
362
+ def __init__(self, file: "IO[str]") -> None:
363
+ handle = GetStdHandle(STDOUT)
364
+ self._handle = handle
365
+ default_text = GetConsoleScreenBufferInfo(handle).wAttributes
366
+ self._default_text = default_text
367
+
368
+ self._default_fore = default_text & 7
369
+ self._default_back = (default_text >> 4) & 7
370
+ self._default_attrs = self._default_fore | (self._default_back << 4)
371
+
372
+ self._file = file
373
+ self.write = file.write
374
+ self.flush = file.flush
375
+
376
+ @property
377
+ def cursor_position(self) -> WindowsCoordinates:
378
+ """Returns the current position of the cursor (0-based)
379
+
380
+ Returns:
381
+ WindowsCoordinates: The current cursor position.
382
+ """
383
+ coord: COORD = GetConsoleScreenBufferInfo(self._handle).dwCursorPosition
384
+ return WindowsCoordinates(row=coord.Y, col=coord.X)
385
+
386
+ @property
387
+ def screen_size(self) -> WindowsCoordinates:
388
+ """Returns the current size of the console screen buffer, in character columns and rows
389
+
390
+ Returns:
391
+ WindowsCoordinates: The width and height of the screen as WindowsCoordinates.
392
+ """
393
+ screen_size: COORD = GetConsoleScreenBufferInfo(self._handle).dwSize
394
+ return WindowsCoordinates(row=screen_size.Y, col=screen_size.X)
395
+
396
+ def write_text(self, text: str) -> None:
397
+ """Write text directly to the terminal without any modification of styles
398
+
399
+ Args:
400
+ text (str): The text to write to the console
401
+ """
402
+ self.write(text)
403
+ self.flush()
404
+
405
+ def write_styled(self, text: str, style: Style) -> None:
406
+ """Write styled text to the terminal.
407
+
408
+ Args:
409
+ text (str): The text to write
410
+ style (Style): The style of the text
411
+ """
412
+ color = style.color
413
+ bgcolor = style.bgcolor
414
+ if style.reverse:
415
+ color, bgcolor = bgcolor, color
416
+
417
+ if color:
418
+ fore = color.downgrade(ColorSystem.WINDOWS).number
419
+ fore = fore if fore is not None else 7 # Default to ANSI 7: White
420
+ if style.bold:
421
+ fore = fore | self.BRIGHT_BIT
422
+ if style.dim:
423
+ fore = fore & ~self.BRIGHT_BIT
424
+ fore = self.ANSI_TO_WINDOWS[fore]
425
+ else:
426
+ fore = self._default_fore
427
+
428
+ if bgcolor:
429
+ back = bgcolor.downgrade(ColorSystem.WINDOWS).number
430
+ back = back if back is not None else 0 # Default to ANSI 0: Black
431
+ back = self.ANSI_TO_WINDOWS[back]
432
+ else:
433
+ back = self._default_back
434
+
435
+ assert fore is not None
436
+ assert back is not None
437
+
438
+ SetConsoleTextAttribute(
439
+ self._handle, attributes=ctypes.c_ushort(fore | (back << 4))
440
+ )
441
+ self.write_text(text)
442
+ SetConsoleTextAttribute(self._handle, attributes=self._default_text)
443
+
444
+ def move_cursor_to(self, new_position: WindowsCoordinates) -> None:
445
+ """Set the position of the cursor
446
+
447
+ Args:
448
+ new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor.
449
+ """
450
+ if new_position.col < 0 or new_position.row < 0:
451
+ return
452
+ SetConsoleCursorPosition(self._handle, coords=new_position)
453
+
454
+ def erase_line(self) -> None:
455
+ """Erase all content on the line the cursor is currently located at"""
456
+ screen_size = self.screen_size
457
+ cursor_position = self.cursor_position
458
+ cells_to_erase = screen_size.col
459
+ start_coordinates = WindowsCoordinates(row=cursor_position.row, col=0)
460
+ FillConsoleOutputCharacter(
461
+ self._handle, " ", length=cells_to_erase, start=start_coordinates
462
+ )
463
+ FillConsoleOutputAttribute(
464
+ self._handle,
465
+ self._default_attrs,
466
+ length=cells_to_erase,
467
+ start=start_coordinates,
468
+ )
469
+
470
+ def erase_end_of_line(self) -> None:
471
+ """Erase all content from the cursor position to the end of that line"""
472
+ cursor_position = self.cursor_position
473
+ cells_to_erase = self.screen_size.col - cursor_position.col
474
+ FillConsoleOutputCharacter(
475
+ self._handle, " ", length=cells_to_erase, start=cursor_position
476
+ )
477
+ FillConsoleOutputAttribute(
478
+ self._handle,
479
+ self._default_attrs,
480
+ length=cells_to_erase,
481
+ start=cursor_position,
482
+ )
483
+
484
+ def erase_start_of_line(self) -> None:
485
+ """Erase all content from the cursor position to the start of that line"""
486
+ row, col = self.cursor_position
487
+ start = WindowsCoordinates(row, 0)
488
+ FillConsoleOutputCharacter(self._handle, " ", length=col, start=start)
489
+ FillConsoleOutputAttribute(
490
+ self._handle, self._default_attrs, length=col, start=start
491
+ )
492
+
493
+ def move_cursor_up(self) -> None:
494
+ """Move the cursor up a single cell"""
495
+ cursor_position = self.cursor_position
496
+ SetConsoleCursorPosition(
497
+ self._handle,
498
+ coords=WindowsCoordinates(
499
+ row=cursor_position.row - 1, col=cursor_position.col
500
+ ),
501
+ )
502
+
503
+ def move_cursor_down(self) -> None:
504
+ """Move the cursor down a single cell"""
505
+ cursor_position = self.cursor_position
506
+ SetConsoleCursorPosition(
507
+ self._handle,
508
+ coords=WindowsCoordinates(
509
+ row=cursor_position.row + 1,
510
+ col=cursor_position.col,
511
+ ),
512
+ )
513
+
514
+ def move_cursor_forward(self) -> None:
515
+ """Move the cursor forward a single cell. Wrap to the next line if required."""
516
+ row, col = self.cursor_position
517
+ if col == self.screen_size.col - 1:
518
+ row += 1
519
+ col = 0
520
+ else:
521
+ col += 1
522
+ SetConsoleCursorPosition(
523
+ self._handle, coords=WindowsCoordinates(row=row, col=col)
524
+ )
525
+
526
+ def move_cursor_to_column(self, column: int) -> None:
527
+ """Move cursor to the column specified by the zero-based column index, staying on the same row
528
+
529
+ Args:
530
+ column (int): The zero-based column index to move the cursor to.
531
+ """
532
+ row, _ = self.cursor_position
533
+ SetConsoleCursorPosition(self._handle, coords=WindowsCoordinates(row, column))
534
+
535
+ def move_cursor_backward(self) -> None:
536
+ """Move the cursor backward a single cell. Wrap to the previous line if required."""
537
+ row, col = self.cursor_position
538
+ if col == 0:
539
+ row -= 1
540
+ col = self.screen_size.col - 1
541
+ else:
542
+ col -= 1
543
+ SetConsoleCursorPosition(
544
+ self._handle, coords=WindowsCoordinates(row=row, col=col)
545
+ )
546
+
547
+ def hide_cursor(self) -> None:
548
+ """Hide the cursor"""
549
+ current_cursor_size = self._get_cursor_size()
550
+ invisible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=0)
551
+ SetConsoleCursorInfo(self._handle, cursor_info=invisible_cursor)
552
+
553
+ def show_cursor(self) -> None:
554
+ """Show the cursor"""
555
+ current_cursor_size = self._get_cursor_size()
556
+ visible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=1)
557
+ SetConsoleCursorInfo(self._handle, cursor_info=visible_cursor)
558
+
559
+ def set_title(self, title: str) -> None:
560
+ """Set the title of the terminal window
561
+
562
+ Args:
563
+ title (str): The new title of the console window
564
+ """
565
+ assert len(title) < 255, "Console title must be less than 255 characters"
566
+ SetConsoleTitle(title)
567
+
568
+ def _get_cursor_size(self) -> int:
569
+ """Get the percentage of the character cell that is filled by the cursor"""
570
+ cursor_info = CONSOLE_CURSOR_INFO()
571
+ GetConsoleCursorInfo(self._handle, cursor_info=cursor_info)
572
+ return int(cursor_info.dwSize)
573
+
574
+
575
+ if __name__ == "__main__":
576
+ handle = GetStdHandle()
577
+
578
+ from pip._vendor.rich.console import Console
579
+
580
+ console = Console()
581
+
582
+ term = LegacyWindowsTerm(sys.stdout)
583
+ term.set_title("Win32 Console Examples")
584
+
585
+ style = Style(color="black", bgcolor="red")
586
+
587
+ heading = Style.parse("black on green")
588
+
589
+ # Check colour output
590
+ console.rule("Checking colour output")
591
+ console.print("[on red]on red!")
592
+ console.print("[blue]blue!")
593
+ console.print("[yellow]yellow!")
594
+ console.print("[bold yellow]bold yellow!")
595
+ console.print("[bright_yellow]bright_yellow!")
596
+ console.print("[dim bright_yellow]dim bright_yellow!")
597
+ console.print("[italic cyan]italic cyan!")
598
+ console.print("[bold white on blue]bold white on blue!")
599
+ console.print("[reverse bold white on blue]reverse bold white on blue!")
600
+ console.print("[bold black on cyan]bold black on cyan!")
601
+ console.print("[black on green]black on green!")
602
+ console.print("[blue on green]blue on green!")
603
+ console.print("[white on black]white on black!")
604
+ console.print("[black on white]black on white!")
605
+ console.print("[#1BB152 on #DA812D]#1BB152 on #DA812D!")
606
+
607
+ # Check cursor movement
608
+ console.rule("Checking cursor movement")
609
+ console.print()
610
+ term.move_cursor_backward()
611
+ term.move_cursor_backward()
612
+ term.write_text("went back and wrapped to prev line")
613
+ time.sleep(1)
614
+ term.move_cursor_up()
615
+ term.write_text("we go up")
616
+ time.sleep(1)
617
+ term.move_cursor_down()
618
+ term.write_text("and down")
619
+ time.sleep(1)
620
+ term.move_cursor_up()
621
+ term.move_cursor_backward()
622
+ term.move_cursor_backward()
623
+ term.write_text("we went up and back 2")
624
+ time.sleep(1)
625
+ term.move_cursor_down()
626
+ term.move_cursor_backward()
627
+ term.move_cursor_backward()
628
+ term.write_text("we went down and back 2")
629
+ time.sleep(1)
630
+
631
+ # Check erasing of lines
632
+ term.hide_cursor()
633
+ console.print()
634
+ console.rule("Checking line erasing")
635
+ console.print("\n...Deleting to the start of the line...")
636
+ term.write_text("The red arrow shows the cursor location, and direction of erase")
637
+ time.sleep(1)
638
+ term.move_cursor_to_column(16)
639
+ term.write_styled("<", Style.parse("black on red"))
640
+ term.move_cursor_backward()
641
+ time.sleep(1)
642
+ term.erase_start_of_line()
643
+ time.sleep(1)
644
+
645
+ console.print("\n\n...And to the end of the line...")
646
+ term.write_text("The red arrow shows the cursor location, and direction of erase")
647
+ time.sleep(1)
648
+
649
+ term.move_cursor_to_column(16)
650
+ term.write_styled(">", Style.parse("black on red"))
651
+ time.sleep(1)
652
+ term.erase_end_of_line()
653
+ time.sleep(1)
654
+
655
+ console.print("\n\n...Now the whole line will be erased...")
656
+ term.write_styled("I'm going to disappear!", style=Style.parse("black on cyan"))
657
+ time.sleep(1)
658
+ term.erase_line()
659
+
660
+ term.show_cursor()
661
+ print("\n")
llava/lib/python3.10/site-packages/pip/_vendor/rich/_windows.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from dataclasses import dataclass
3
+
4
+
5
+ @dataclass
6
+ class WindowsConsoleFeatures:
7
+ """Windows features available."""
8
+
9
+ vt: bool = False
10
+ """The console supports VT codes."""
11
+ truecolor: bool = False
12
+ """The console supports truecolor."""
13
+
14
+
15
+ try:
16
+ import ctypes
17
+ from ctypes import LibraryLoader
18
+
19
+ if sys.platform == "win32":
20
+ windll = LibraryLoader(ctypes.WinDLL)
21
+ else:
22
+ windll = None
23
+ raise ImportError("Not windows")
24
+
25
+ from pip._vendor.rich._win32_console import (
26
+ ENABLE_VIRTUAL_TERMINAL_PROCESSING,
27
+ GetConsoleMode,
28
+ GetStdHandle,
29
+ LegacyWindowsError,
30
+ )
31
+
32
+ except (AttributeError, ImportError, ValueError):
33
+ # Fallback if we can't load the Windows DLL
34
+ def get_windows_console_features() -> WindowsConsoleFeatures:
35
+ features = WindowsConsoleFeatures()
36
+ return features
37
+
38
+ else:
39
+
40
+ def get_windows_console_features() -> WindowsConsoleFeatures:
41
+ """Get windows console features.
42
+
43
+ Returns:
44
+ WindowsConsoleFeatures: An instance of WindowsConsoleFeatures.
45
+ """
46
+ handle = GetStdHandle()
47
+ try:
48
+ console_mode = GetConsoleMode(handle)
49
+ success = True
50
+ except LegacyWindowsError:
51
+ console_mode = 0
52
+ success = False
53
+ vt = bool(success and console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
54
+ truecolor = False
55
+ if vt:
56
+ win_version = sys.getwindowsversion()
57
+ truecolor = win_version.major > 10 or (
58
+ win_version.major == 10 and win_version.build >= 15063
59
+ )
60
+ features = WindowsConsoleFeatures(vt=vt, truecolor=truecolor)
61
+ return features
62
+
63
+
64
+ if __name__ == "__main__":
65
+ import platform
66
+
67
+ features = get_windows_console_features()
68
+ from pip._vendor.rich import print
69
+
70
+ print(f'platform="{platform.system()}"')
71
+ print(repr(features))
llava/lib/python3.10/site-packages/pip/_vendor/rich/abc.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC
2
+
3
+
4
+ class RichRenderable(ABC):
5
+ """An abstract base class for Rich renderables.
6
+
7
+ Note that there is no need to extend this class, the intended use is to check if an
8
+ object supports the Rich renderable protocol. For example::
9
+
10
+ if isinstance(my_object, RichRenderable):
11
+ console.print(my_object)
12
+
13
+ """
14
+
15
+ @classmethod
16
+ def __subclasshook__(cls, other: type) -> bool:
17
+ """Check if this class supports the rich render protocol."""
18
+ return hasattr(other, "__rich_console__") or hasattr(other, "__rich__")
19
+
20
+
21
+ if __name__ == "__main__": # pragma: no cover
22
+ from pip._vendor.rich.text import Text
23
+
24
+ t = Text()
25
+ print(isinstance(Text, RichRenderable))
26
+ print(isinstance(t, RichRenderable))
27
+
28
+ class Foo:
29
+ pass
30
+
31
+ f = Foo()
32
+ print(isinstance(f, RichRenderable))
33
+ print(isinstance("", RichRenderable))
llava/lib/python3.10/site-packages/pip/_vendor/rich/color.py ADDED
@@ -0,0 +1,621 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import sys
3
+ from colorsys import rgb_to_hls
4
+ from enum import IntEnum
5
+ from functools import lru_cache
6
+ from typing import TYPE_CHECKING, NamedTuple, Optional, Tuple
7
+
8
+ from ._palettes import EIGHT_BIT_PALETTE, STANDARD_PALETTE, WINDOWS_PALETTE
9
+ from .color_triplet import ColorTriplet
10
+ from .repr import Result, rich_repr
11
+ from .terminal_theme import DEFAULT_TERMINAL_THEME
12
+
13
+ if TYPE_CHECKING: # pragma: no cover
14
+ from .terminal_theme import TerminalTheme
15
+ from .text import Text
16
+
17
+
18
+ WINDOWS = sys.platform == "win32"
19
+
20
+
21
+ class ColorSystem(IntEnum):
22
+ """One of the 3 color system supported by terminals."""
23
+
24
+ STANDARD = 1
25
+ EIGHT_BIT = 2
26
+ TRUECOLOR = 3
27
+ WINDOWS = 4
28
+
29
+ def __repr__(self) -> str:
30
+ return f"ColorSystem.{self.name}"
31
+
32
+ def __str__(self) -> str:
33
+ return repr(self)
34
+
35
+
36
+ class ColorType(IntEnum):
37
+ """Type of color stored in Color class."""
38
+
39
+ DEFAULT = 0
40
+ STANDARD = 1
41
+ EIGHT_BIT = 2
42
+ TRUECOLOR = 3
43
+ WINDOWS = 4
44
+
45
+ def __repr__(self) -> str:
46
+ return f"ColorType.{self.name}"
47
+
48
+
49
+ ANSI_COLOR_NAMES = {
50
+ "black": 0,
51
+ "red": 1,
52
+ "green": 2,
53
+ "yellow": 3,
54
+ "blue": 4,
55
+ "magenta": 5,
56
+ "cyan": 6,
57
+ "white": 7,
58
+ "bright_black": 8,
59
+ "bright_red": 9,
60
+ "bright_green": 10,
61
+ "bright_yellow": 11,
62
+ "bright_blue": 12,
63
+ "bright_magenta": 13,
64
+ "bright_cyan": 14,
65
+ "bright_white": 15,
66
+ "grey0": 16,
67
+ "gray0": 16,
68
+ "navy_blue": 17,
69
+ "dark_blue": 18,
70
+ "blue3": 20,
71
+ "blue1": 21,
72
+ "dark_green": 22,
73
+ "deep_sky_blue4": 25,
74
+ "dodger_blue3": 26,
75
+ "dodger_blue2": 27,
76
+ "green4": 28,
77
+ "spring_green4": 29,
78
+ "turquoise4": 30,
79
+ "deep_sky_blue3": 32,
80
+ "dodger_blue1": 33,
81
+ "green3": 40,
82
+ "spring_green3": 41,
83
+ "dark_cyan": 36,
84
+ "light_sea_green": 37,
85
+ "deep_sky_blue2": 38,
86
+ "deep_sky_blue1": 39,
87
+ "spring_green2": 47,
88
+ "cyan3": 43,
89
+ "dark_turquoise": 44,
90
+ "turquoise2": 45,
91
+ "green1": 46,
92
+ "spring_green1": 48,
93
+ "medium_spring_green": 49,
94
+ "cyan2": 50,
95
+ "cyan1": 51,
96
+ "dark_red": 88,
97
+ "deep_pink4": 125,
98
+ "purple4": 55,
99
+ "purple3": 56,
100
+ "blue_violet": 57,
101
+ "orange4": 94,
102
+ "grey37": 59,
103
+ "gray37": 59,
104
+ "medium_purple4": 60,
105
+ "slate_blue3": 62,
106
+ "royal_blue1": 63,
107
+ "chartreuse4": 64,
108
+ "dark_sea_green4": 71,
109
+ "pale_turquoise4": 66,
110
+ "steel_blue": 67,
111
+ "steel_blue3": 68,
112
+ "cornflower_blue": 69,
113
+ "chartreuse3": 76,
114
+ "cadet_blue": 73,
115
+ "sky_blue3": 74,
116
+ "steel_blue1": 81,
117
+ "pale_green3": 114,
118
+ "sea_green3": 78,
119
+ "aquamarine3": 79,
120
+ "medium_turquoise": 80,
121
+ "chartreuse2": 112,
122
+ "sea_green2": 83,
123
+ "sea_green1": 85,
124
+ "aquamarine1": 122,
125
+ "dark_slate_gray2": 87,
126
+ "dark_magenta": 91,
127
+ "dark_violet": 128,
128
+ "purple": 129,
129
+ "light_pink4": 95,
130
+ "plum4": 96,
131
+ "medium_purple3": 98,
132
+ "slate_blue1": 99,
133
+ "yellow4": 106,
134
+ "wheat4": 101,
135
+ "grey53": 102,
136
+ "gray53": 102,
137
+ "light_slate_grey": 103,
138
+ "light_slate_gray": 103,
139
+ "medium_purple": 104,
140
+ "light_slate_blue": 105,
141
+ "dark_olive_green3": 149,
142
+ "dark_sea_green": 108,
143
+ "light_sky_blue3": 110,
144
+ "sky_blue2": 111,
145
+ "dark_sea_green3": 150,
146
+ "dark_slate_gray3": 116,
147
+ "sky_blue1": 117,
148
+ "chartreuse1": 118,
149
+ "light_green": 120,
150
+ "pale_green1": 156,
151
+ "dark_slate_gray1": 123,
152
+ "red3": 160,
153
+ "medium_violet_red": 126,
154
+ "magenta3": 164,
155
+ "dark_orange3": 166,
156
+ "indian_red": 167,
157
+ "hot_pink3": 168,
158
+ "medium_orchid3": 133,
159
+ "medium_orchid": 134,
160
+ "medium_purple2": 140,
161
+ "dark_goldenrod": 136,
162
+ "light_salmon3": 173,
163
+ "rosy_brown": 138,
164
+ "grey63": 139,
165
+ "gray63": 139,
166
+ "medium_purple1": 141,
167
+ "gold3": 178,
168
+ "dark_khaki": 143,
169
+ "navajo_white3": 144,
170
+ "grey69": 145,
171
+ "gray69": 145,
172
+ "light_steel_blue3": 146,
173
+ "light_steel_blue": 147,
174
+ "yellow3": 184,
175
+ "dark_sea_green2": 157,
176
+ "light_cyan3": 152,
177
+ "light_sky_blue1": 153,
178
+ "green_yellow": 154,
179
+ "dark_olive_green2": 155,
180
+ "dark_sea_green1": 193,
181
+ "pale_turquoise1": 159,
182
+ "deep_pink3": 162,
183
+ "magenta2": 200,
184
+ "hot_pink2": 169,
185
+ "orchid": 170,
186
+ "medium_orchid1": 207,
187
+ "orange3": 172,
188
+ "light_pink3": 174,
189
+ "pink3": 175,
190
+ "plum3": 176,
191
+ "violet": 177,
192
+ "light_goldenrod3": 179,
193
+ "tan": 180,
194
+ "misty_rose3": 181,
195
+ "thistle3": 182,
196
+ "plum2": 183,
197
+ "khaki3": 185,
198
+ "light_goldenrod2": 222,
199
+ "light_yellow3": 187,
200
+ "grey84": 188,
201
+ "gray84": 188,
202
+ "light_steel_blue1": 189,
203
+ "yellow2": 190,
204
+ "dark_olive_green1": 192,
205
+ "honeydew2": 194,
206
+ "light_cyan1": 195,
207
+ "red1": 196,
208
+ "deep_pink2": 197,
209
+ "deep_pink1": 199,
210
+ "magenta1": 201,
211
+ "orange_red1": 202,
212
+ "indian_red1": 204,
213
+ "hot_pink": 206,
214
+ "dark_orange": 208,
215
+ "salmon1": 209,
216
+ "light_coral": 210,
217
+ "pale_violet_red1": 211,
218
+ "orchid2": 212,
219
+ "orchid1": 213,
220
+ "orange1": 214,
221
+ "sandy_brown": 215,
222
+ "light_salmon1": 216,
223
+ "light_pink1": 217,
224
+ "pink1": 218,
225
+ "plum1": 219,
226
+ "gold1": 220,
227
+ "navajo_white1": 223,
228
+ "misty_rose1": 224,
229
+ "thistle1": 225,
230
+ "yellow1": 226,
231
+ "light_goldenrod1": 227,
232
+ "khaki1": 228,
233
+ "wheat1": 229,
234
+ "cornsilk1": 230,
235
+ "grey100": 231,
236
+ "gray100": 231,
237
+ "grey3": 232,
238
+ "gray3": 232,
239
+ "grey7": 233,
240
+ "gray7": 233,
241
+ "grey11": 234,
242
+ "gray11": 234,
243
+ "grey15": 235,
244
+ "gray15": 235,
245
+ "grey19": 236,
246
+ "gray19": 236,
247
+ "grey23": 237,
248
+ "gray23": 237,
249
+ "grey27": 238,
250
+ "gray27": 238,
251
+ "grey30": 239,
252
+ "gray30": 239,
253
+ "grey35": 240,
254
+ "gray35": 240,
255
+ "grey39": 241,
256
+ "gray39": 241,
257
+ "grey42": 242,
258
+ "gray42": 242,
259
+ "grey46": 243,
260
+ "gray46": 243,
261
+ "grey50": 244,
262
+ "gray50": 244,
263
+ "grey54": 245,
264
+ "gray54": 245,
265
+ "grey58": 246,
266
+ "gray58": 246,
267
+ "grey62": 247,
268
+ "gray62": 247,
269
+ "grey66": 248,
270
+ "gray66": 248,
271
+ "grey70": 249,
272
+ "gray70": 249,
273
+ "grey74": 250,
274
+ "gray74": 250,
275
+ "grey78": 251,
276
+ "gray78": 251,
277
+ "grey82": 252,
278
+ "gray82": 252,
279
+ "grey85": 253,
280
+ "gray85": 253,
281
+ "grey89": 254,
282
+ "gray89": 254,
283
+ "grey93": 255,
284
+ "gray93": 255,
285
+ }
286
+
287
+
288
+ class ColorParseError(Exception):
289
+ """The color could not be parsed."""
290
+
291
+
292
+ RE_COLOR = re.compile(
293
+ r"""^
294
+ \#([0-9a-f]{6})$|
295
+ color\(([0-9]{1,3})\)$|
296
+ rgb\(([\d\s,]+)\)$
297
+ """,
298
+ re.VERBOSE,
299
+ )
300
+
301
+
302
+ @rich_repr
303
+ class Color(NamedTuple):
304
+ """Terminal color definition."""
305
+
306
+ name: str
307
+ """The name of the color (typically the input to Color.parse)."""
308
+ type: ColorType
309
+ """The type of the color."""
310
+ number: Optional[int] = None
311
+ """The color number, if a standard color, or None."""
312
+ triplet: Optional[ColorTriplet] = None
313
+ """A triplet of color components, if an RGB color."""
314
+
315
+ def __rich__(self) -> "Text":
316
+ """Displays the actual color if Rich printed."""
317
+ from .style import Style
318
+ from .text import Text
319
+
320
+ return Text.assemble(
321
+ f"<color {self.name!r} ({self.type.name.lower()})",
322
+ ("⬤", Style(color=self)),
323
+ " >",
324
+ )
325
+
326
+ def __rich_repr__(self) -> Result:
327
+ yield self.name
328
+ yield self.type
329
+ yield "number", self.number, None
330
+ yield "triplet", self.triplet, None
331
+
332
+ @property
333
+ def system(self) -> ColorSystem:
334
+ """Get the native color system for this color."""
335
+ if self.type == ColorType.DEFAULT:
336
+ return ColorSystem.STANDARD
337
+ return ColorSystem(int(self.type))
338
+
339
+ @property
340
+ def is_system_defined(self) -> bool:
341
+ """Check if the color is ultimately defined by the system."""
342
+ return self.system not in (ColorSystem.EIGHT_BIT, ColorSystem.TRUECOLOR)
343
+
344
+ @property
345
+ def is_default(self) -> bool:
346
+ """Check if the color is a default color."""
347
+ return self.type == ColorType.DEFAULT
348
+
349
+ def get_truecolor(
350
+ self, theme: Optional["TerminalTheme"] = None, foreground: bool = True
351
+ ) -> ColorTriplet:
352
+ """Get an equivalent color triplet for this color.
353
+
354
+ Args:
355
+ theme (TerminalTheme, optional): Optional terminal theme, or None to use default. Defaults to None.
356
+ foreground (bool, optional): True for a foreground color, or False for background. Defaults to True.
357
+
358
+ Returns:
359
+ ColorTriplet: A color triplet containing RGB components.
360
+ """
361
+
362
+ if theme is None:
363
+ theme = DEFAULT_TERMINAL_THEME
364
+ if self.type == ColorType.TRUECOLOR:
365
+ assert self.triplet is not None
366
+ return self.triplet
367
+ elif self.type == ColorType.EIGHT_BIT:
368
+ assert self.number is not None
369
+ return EIGHT_BIT_PALETTE[self.number]
370
+ elif self.type == ColorType.STANDARD:
371
+ assert self.number is not None
372
+ return theme.ansi_colors[self.number]
373
+ elif self.type == ColorType.WINDOWS:
374
+ assert self.number is not None
375
+ return WINDOWS_PALETTE[self.number]
376
+ else: # self.type == ColorType.DEFAULT:
377
+ assert self.number is None
378
+ return theme.foreground_color if foreground else theme.background_color
379
+
380
+ @classmethod
381
+ def from_ansi(cls, number: int) -> "Color":
382
+ """Create a Color number from it's 8-bit ansi number.
383
+
384
+ Args:
385
+ number (int): A number between 0-255 inclusive.
386
+
387
+ Returns:
388
+ Color: A new Color instance.
389
+ """
390
+ return cls(
391
+ name=f"color({number})",
392
+ type=(ColorType.STANDARD if number < 16 else ColorType.EIGHT_BIT),
393
+ number=number,
394
+ )
395
+
396
+ @classmethod
397
+ def from_triplet(cls, triplet: "ColorTriplet") -> "Color":
398
+ """Create a truecolor RGB color from a triplet of values.
399
+
400
+ Args:
401
+ triplet (ColorTriplet): A color triplet containing red, green and blue components.
402
+
403
+ Returns:
404
+ Color: A new color object.
405
+ """
406
+ return cls(name=triplet.hex, type=ColorType.TRUECOLOR, triplet=triplet)
407
+
408
+ @classmethod
409
+ def from_rgb(cls, red: float, green: float, blue: float) -> "Color":
410
+ """Create a truecolor from three color components in the range(0->255).
411
+
412
+ Args:
413
+ red (float): Red component in range 0-255.
414
+ green (float): Green component in range 0-255.
415
+ blue (float): Blue component in range 0-255.
416
+
417
+ Returns:
418
+ Color: A new color object.
419
+ """
420
+ return cls.from_triplet(ColorTriplet(int(red), int(green), int(blue)))
421
+
422
+ @classmethod
423
+ def default(cls) -> "Color":
424
+ """Get a Color instance representing the default color.
425
+
426
+ Returns:
427
+ Color: Default color.
428
+ """
429
+ return cls(name="default", type=ColorType.DEFAULT)
430
+
431
+ @classmethod
432
+ @lru_cache(maxsize=1024)
433
+ def parse(cls, color: str) -> "Color":
434
+ """Parse a color definition."""
435
+ original_color = color
436
+ color = color.lower().strip()
437
+
438
+ if color == "default":
439
+ return cls(color, type=ColorType.DEFAULT)
440
+
441
+ color_number = ANSI_COLOR_NAMES.get(color)
442
+ if color_number is not None:
443
+ return cls(
444
+ color,
445
+ type=(ColorType.STANDARD if color_number < 16 else ColorType.EIGHT_BIT),
446
+ number=color_number,
447
+ )
448
+
449
+ color_match = RE_COLOR.match(color)
450
+ if color_match is None:
451
+ raise ColorParseError(f"{original_color!r} is not a valid color")
452
+
453
+ color_24, color_8, color_rgb = color_match.groups()
454
+ if color_24:
455
+ triplet = ColorTriplet(
456
+ int(color_24[0:2], 16), int(color_24[2:4], 16), int(color_24[4:6], 16)
457
+ )
458
+ return cls(color, ColorType.TRUECOLOR, triplet=triplet)
459
+
460
+ elif color_8:
461
+ number = int(color_8)
462
+ if number > 255:
463
+ raise ColorParseError(f"color number must be <= 255 in {color!r}")
464
+ return cls(
465
+ color,
466
+ type=(ColorType.STANDARD if number < 16 else ColorType.EIGHT_BIT),
467
+ number=number,
468
+ )
469
+
470
+ else: # color_rgb:
471
+ components = color_rgb.split(",")
472
+ if len(components) != 3:
473
+ raise ColorParseError(
474
+ f"expected three components in {original_color!r}"
475
+ )
476
+ red, green, blue = components
477
+ triplet = ColorTriplet(int(red), int(green), int(blue))
478
+ if not all(component <= 255 for component in triplet):
479
+ raise ColorParseError(
480
+ f"color components must be <= 255 in {original_color!r}"
481
+ )
482
+ return cls(color, ColorType.TRUECOLOR, triplet=triplet)
483
+
484
+ @lru_cache(maxsize=1024)
485
+ def get_ansi_codes(self, foreground: bool = True) -> Tuple[str, ...]:
486
+ """Get the ANSI escape codes for this color."""
487
+ _type = self.type
488
+ if _type == ColorType.DEFAULT:
489
+ return ("39" if foreground else "49",)
490
+
491
+ elif _type == ColorType.WINDOWS:
492
+ number = self.number
493
+ assert number is not None
494
+ fore, back = (30, 40) if number < 8 else (82, 92)
495
+ return (str(fore + number if foreground else back + number),)
496
+
497
+ elif _type == ColorType.STANDARD:
498
+ number = self.number
499
+ assert number is not None
500
+ fore, back = (30, 40) if number < 8 else (82, 92)
501
+ return (str(fore + number if foreground else back + number),)
502
+
503
+ elif _type == ColorType.EIGHT_BIT:
504
+ assert self.number is not None
505
+ return ("38" if foreground else "48", "5", str(self.number))
506
+
507
+ else: # self.standard == ColorStandard.TRUECOLOR:
508
+ assert self.triplet is not None
509
+ red, green, blue = self.triplet
510
+ return ("38" if foreground else "48", "2", str(red), str(green), str(blue))
511
+
512
+ @lru_cache(maxsize=1024)
513
+ def downgrade(self, system: ColorSystem) -> "Color":
514
+ """Downgrade a color system to a system with fewer colors."""
515
+
516
+ if self.type in (ColorType.DEFAULT, system):
517
+ return self
518
+ # Convert to 8-bit color from truecolor color
519
+ if system == ColorSystem.EIGHT_BIT and self.system == ColorSystem.TRUECOLOR:
520
+ assert self.triplet is not None
521
+ _h, l, s = rgb_to_hls(*self.triplet.normalized)
522
+ # If saturation is under 15% assume it is grayscale
523
+ if s < 0.15:
524
+ gray = round(l * 25.0)
525
+ if gray == 0:
526
+ color_number = 16
527
+ elif gray == 25:
528
+ color_number = 231
529
+ else:
530
+ color_number = 231 + gray
531
+ return Color(self.name, ColorType.EIGHT_BIT, number=color_number)
532
+
533
+ red, green, blue = self.triplet
534
+ six_red = red / 95 if red < 95 else 1 + (red - 95) / 40
535
+ six_green = green / 95 if green < 95 else 1 + (green - 95) / 40
536
+ six_blue = blue / 95 if blue < 95 else 1 + (blue - 95) / 40
537
+
538
+ color_number = (
539
+ 16 + 36 * round(six_red) + 6 * round(six_green) + round(six_blue)
540
+ )
541
+ return Color(self.name, ColorType.EIGHT_BIT, number=color_number)
542
+
543
+ # Convert to standard from truecolor or 8-bit
544
+ elif system == ColorSystem.STANDARD:
545
+ if self.system == ColorSystem.TRUECOLOR:
546
+ assert self.triplet is not None
547
+ triplet = self.triplet
548
+ else: # self.system == ColorSystem.EIGHT_BIT
549
+ assert self.number is not None
550
+ triplet = ColorTriplet(*EIGHT_BIT_PALETTE[self.number])
551
+
552
+ color_number = STANDARD_PALETTE.match(triplet)
553
+ return Color(self.name, ColorType.STANDARD, number=color_number)
554
+
555
+ elif system == ColorSystem.WINDOWS:
556
+ if self.system == ColorSystem.TRUECOLOR:
557
+ assert self.triplet is not None
558
+ triplet = self.triplet
559
+ else: # self.system == ColorSystem.EIGHT_BIT
560
+ assert self.number is not None
561
+ if self.number < 16:
562
+ return Color(self.name, ColorType.WINDOWS, number=self.number)
563
+ triplet = ColorTriplet(*EIGHT_BIT_PALETTE[self.number])
564
+
565
+ color_number = WINDOWS_PALETTE.match(triplet)
566
+ return Color(self.name, ColorType.WINDOWS, number=color_number)
567
+
568
+ return self
569
+
570
+
571
+ def parse_rgb_hex(hex_color: str) -> ColorTriplet:
572
+ """Parse six hex characters in to RGB triplet."""
573
+ assert len(hex_color) == 6, "must be 6 characters"
574
+ color = ColorTriplet(
575
+ int(hex_color[0:2], 16), int(hex_color[2:4], 16), int(hex_color[4:6], 16)
576
+ )
577
+ return color
578
+
579
+
580
+ def blend_rgb(
581
+ color1: ColorTriplet, color2: ColorTriplet, cross_fade: float = 0.5
582
+ ) -> ColorTriplet:
583
+ """Blend one RGB color in to another."""
584
+ r1, g1, b1 = color1
585
+ r2, g2, b2 = color2
586
+ new_color = ColorTriplet(
587
+ int(r1 + (r2 - r1) * cross_fade),
588
+ int(g1 + (g2 - g1) * cross_fade),
589
+ int(b1 + (b2 - b1) * cross_fade),
590
+ )
591
+ return new_color
592
+
593
+
594
+ if __name__ == "__main__": # pragma: no cover
595
+ from .console import Console
596
+ from .table import Table
597
+ from .text import Text
598
+
599
+ console = Console()
600
+
601
+ table = Table(show_footer=False, show_edge=True)
602
+ table.add_column("Color", width=10, overflow="ellipsis")
603
+ table.add_column("Number", justify="right", style="yellow")
604
+ table.add_column("Name", style="green")
605
+ table.add_column("Hex", style="blue")
606
+ table.add_column("RGB", style="magenta")
607
+
608
+ colors = sorted((v, k) for k, v in ANSI_COLOR_NAMES.items())
609
+ for color_number, name in colors:
610
+ if "grey" in name:
611
+ continue
612
+ color_cell = Text(" " * 10, style=f"on {name}")
613
+ if color_number < 16:
614
+ table.add_row(color_cell, f"{color_number}", Text(f'"{name}"'))
615
+ else:
616
+ color = EIGHT_BIT_PALETTE[color_number] # type: ignore[has-type]
617
+ table.add_row(
618
+ color_cell, str(color_number), Text(f'"{name}"'), color.hex, color.rgb
619
+ )
620
+
621
+ console.print(table)
llava/lib/python3.10/site-packages/pip/_vendor/rich/color_triplet.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import NamedTuple, Tuple
2
+
3
+
4
+ class ColorTriplet(NamedTuple):
5
+ """The red, green, and blue components of a color."""
6
+
7
+ red: int
8
+ """Red component in 0 to 255 range."""
9
+ green: int
10
+ """Green component in 0 to 255 range."""
11
+ blue: int
12
+ """Blue component in 0 to 255 range."""
13
+
14
+ @property
15
+ def hex(self) -> str:
16
+ """get the color triplet in CSS style."""
17
+ red, green, blue = self
18
+ return f"#{red:02x}{green:02x}{blue:02x}"
19
+
20
+ @property
21
+ def rgb(self) -> str:
22
+ """The color in RGB format.
23
+
24
+ Returns:
25
+ str: An rgb color, e.g. ``"rgb(100,23,255)"``.
26
+ """
27
+ red, green, blue = self
28
+ return f"rgb({red},{green},{blue})"
29
+
30
+ @property
31
+ def normalized(self) -> Tuple[float, float, float]:
32
+ """Convert components into floats between 0 and 1.
33
+
34
+ Returns:
35
+ Tuple[float, float, float]: A tuple of three normalized colour components.
36
+ """
37
+ red, green, blue = self
38
+ return red / 255.0, green / 255.0, blue / 255.0
llava/lib/python3.10/site-packages/pip/_vendor/rich/columns.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import defaultdict
2
+ from itertools import chain
3
+ from operator import itemgetter
4
+ from typing import Dict, Iterable, List, Optional, Tuple
5
+
6
+ from .align import Align, AlignMethod
7
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
8
+ from .constrain import Constrain
9
+ from .measure import Measurement
10
+ from .padding import Padding, PaddingDimensions
11
+ from .table import Table
12
+ from .text import TextType
13
+ from .jupyter import JupyterMixin
14
+
15
+
16
+ class Columns(JupyterMixin):
17
+ """Display renderables in neat columns.
18
+
19
+ Args:
20
+ renderables (Iterable[RenderableType]): Any number of Rich renderables (including str).
21
+ width (int, optional): The desired width of the columns, or None to auto detect. Defaults to None.
22
+ padding (PaddingDimensions, optional): Optional padding around cells. Defaults to (0, 1).
23
+ expand (bool, optional): Expand columns to full width. Defaults to False.
24
+ equal (bool, optional): Arrange in to equal sized columns. Defaults to False.
25
+ column_first (bool, optional): Align items from top to bottom (rather than left to right). Defaults to False.
26
+ right_to_left (bool, optional): Start column from right hand side. Defaults to False.
27
+ align (str, optional): Align value ("left", "right", or "center") or None for default. Defaults to None.
28
+ title (TextType, optional): Optional title for Columns.
29
+ """
30
+
31
+ def __init__(
32
+ self,
33
+ renderables: Optional[Iterable[RenderableType]] = None,
34
+ padding: PaddingDimensions = (0, 1),
35
+ *,
36
+ width: Optional[int] = None,
37
+ expand: bool = False,
38
+ equal: bool = False,
39
+ column_first: bool = False,
40
+ right_to_left: bool = False,
41
+ align: Optional[AlignMethod] = None,
42
+ title: Optional[TextType] = None,
43
+ ) -> None:
44
+ self.renderables = list(renderables or [])
45
+ self.width = width
46
+ self.padding = padding
47
+ self.expand = expand
48
+ self.equal = equal
49
+ self.column_first = column_first
50
+ self.right_to_left = right_to_left
51
+ self.align: Optional[AlignMethod] = align
52
+ self.title = title
53
+
54
+ def add_renderable(self, renderable: RenderableType) -> None:
55
+ """Add a renderable to the columns.
56
+
57
+ Args:
58
+ renderable (RenderableType): Any renderable object.
59
+ """
60
+ self.renderables.append(renderable)
61
+
62
+ def __rich_console__(
63
+ self, console: Console, options: ConsoleOptions
64
+ ) -> RenderResult:
65
+ render_str = console.render_str
66
+ renderables = [
67
+ render_str(renderable) if isinstance(renderable, str) else renderable
68
+ for renderable in self.renderables
69
+ ]
70
+ if not renderables:
71
+ return
72
+ _top, right, _bottom, left = Padding.unpack(self.padding)
73
+ width_padding = max(left, right)
74
+ max_width = options.max_width
75
+ widths: Dict[int, int] = defaultdict(int)
76
+ column_count = len(renderables)
77
+
78
+ get_measurement = Measurement.get
79
+ renderable_widths = [
80
+ get_measurement(console, options, renderable).maximum
81
+ for renderable in renderables
82
+ ]
83
+ if self.equal:
84
+ renderable_widths = [max(renderable_widths)] * len(renderable_widths)
85
+
86
+ def iter_renderables(
87
+ column_count: int,
88
+ ) -> Iterable[Tuple[int, Optional[RenderableType]]]:
89
+ item_count = len(renderables)
90
+ if self.column_first:
91
+ width_renderables = list(zip(renderable_widths, renderables))
92
+
93
+ column_lengths: List[int] = [item_count // column_count] * column_count
94
+ for col_no in range(item_count % column_count):
95
+ column_lengths[col_no] += 1
96
+
97
+ row_count = (item_count + column_count - 1) // column_count
98
+ cells = [[-1] * column_count for _ in range(row_count)]
99
+ row = col = 0
100
+ for index in range(item_count):
101
+ cells[row][col] = index
102
+ column_lengths[col] -= 1
103
+ if column_lengths[col]:
104
+ row += 1
105
+ else:
106
+ col += 1
107
+ row = 0
108
+ for index in chain.from_iterable(cells):
109
+ if index == -1:
110
+ break
111
+ yield width_renderables[index]
112
+ else:
113
+ yield from zip(renderable_widths, renderables)
114
+ # Pad odd elements with spaces
115
+ if item_count % column_count:
116
+ for _ in range(column_count - (item_count % column_count)):
117
+ yield 0, None
118
+
119
+ table = Table.grid(padding=self.padding, collapse_padding=True, pad_edge=False)
120
+ table.expand = self.expand
121
+ table.title = self.title
122
+
123
+ if self.width is not None:
124
+ column_count = (max_width) // (self.width + width_padding)
125
+ for _ in range(column_count):
126
+ table.add_column(width=self.width)
127
+ else:
128
+ while column_count > 1:
129
+ widths.clear()
130
+ column_no = 0
131
+ for renderable_width, _ in iter_renderables(column_count):
132
+ widths[column_no] = max(widths[column_no], renderable_width)
133
+ total_width = sum(widths.values()) + width_padding * (
134
+ len(widths) - 1
135
+ )
136
+ if total_width > max_width:
137
+ column_count = len(widths) - 1
138
+ break
139
+ else:
140
+ column_no = (column_no + 1) % column_count
141
+ else:
142
+ break
143
+
144
+ get_renderable = itemgetter(1)
145
+ _renderables = [
146
+ get_renderable(_renderable)
147
+ for _renderable in iter_renderables(column_count)
148
+ ]
149
+ if self.equal:
150
+ _renderables = [
151
+ None
152
+ if renderable is None
153
+ else Constrain(renderable, renderable_widths[0])
154
+ for renderable in _renderables
155
+ ]
156
+ if self.align:
157
+ align = self.align
158
+ _Align = Align
159
+ _renderables = [
160
+ None if renderable is None else _Align(renderable, align)
161
+ for renderable in _renderables
162
+ ]
163
+
164
+ right_to_left = self.right_to_left
165
+ add_row = table.add_row
166
+ for start in range(0, len(_renderables), column_count):
167
+ row = _renderables[start : start + column_count]
168
+ if right_to_left:
169
+ row = row[::-1]
170
+ add_row(*row)
171
+ yield table
172
+
173
+
174
+ if __name__ == "__main__": # pragma: no cover
175
+ import os
176
+
177
+ console = Console()
178
+
179
+ files = [f"{i} {s}" for i, s in enumerate(sorted(os.listdir()))]
180
+ columns = Columns(files, padding=(0, 1), expand=False, equal=False)
181
+ console.print(columns)
182
+ console.rule()
183
+ columns.column_first = True
184
+ console.print(columns)
185
+ columns.right_to_left = True
186
+ console.rule()
187
+ console.print(columns)
llava/lib/python3.10/site-packages/pip/_vendor/rich/emoji.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from typing import TYPE_CHECKING, Optional, Union
3
+
4
+ from .jupyter import JupyterMixin
5
+ from .segment import Segment
6
+ from .style import Style
7
+ from ._emoji_codes import EMOJI
8
+ from ._emoji_replace import _emoji_replace
9
+
10
+ if sys.version_info >= (3, 8):
11
+ from typing import Literal
12
+ else:
13
+ from pip._vendor.typing_extensions import Literal # pragma: no cover
14
+
15
+
16
+ if TYPE_CHECKING:
17
+ from .console import Console, ConsoleOptions, RenderResult
18
+
19
+
20
+ EmojiVariant = Literal["emoji", "text"]
21
+
22
+
23
+ class NoEmoji(Exception):
24
+ """No emoji by that name."""
25
+
26
+
27
+ class Emoji(JupyterMixin):
28
+ __slots__ = ["name", "style", "_char", "variant"]
29
+
30
+ VARIANTS = {"text": "\uFE0E", "emoji": "\uFE0F"}
31
+
32
+ def __init__(
33
+ self,
34
+ name: str,
35
+ style: Union[str, Style] = "none",
36
+ variant: Optional[EmojiVariant] = None,
37
+ ) -> None:
38
+ """A single emoji character.
39
+
40
+ Args:
41
+ name (str): Name of emoji.
42
+ style (Union[str, Style], optional): Optional style. Defaults to None.
43
+
44
+ Raises:
45
+ NoEmoji: If the emoji doesn't exist.
46
+ """
47
+ self.name = name
48
+ self.style = style
49
+ self.variant = variant
50
+ try:
51
+ self._char = EMOJI[name]
52
+ except KeyError:
53
+ raise NoEmoji(f"No emoji called {name!r}")
54
+ if variant is not None:
55
+ self._char += self.VARIANTS.get(variant, "")
56
+
57
+ @classmethod
58
+ def replace(cls, text: str) -> str:
59
+ """Replace emoji markup with corresponding unicode characters.
60
+
61
+ Args:
62
+ text (str): A string with emojis codes, e.g. "Hello :smiley:!"
63
+
64
+ Returns:
65
+ str: A string with emoji codes replaces with actual emoji.
66
+ """
67
+ return _emoji_replace(text)
68
+
69
+ def __repr__(self) -> str:
70
+ return f"<emoji {self.name!r}>"
71
+
72
+ def __str__(self) -> str:
73
+ return self._char
74
+
75
+ def __rich_console__(
76
+ self, console: "Console", options: "ConsoleOptions"
77
+ ) -> "RenderResult":
78
+ yield Segment(self._char, console.get_style(self.style))
79
+
80
+
81
+ if __name__ == "__main__": # pragma: no cover
82
+ import sys
83
+
84
+ from pip._vendor.rich.columns import Columns
85
+ from pip._vendor.rich.console import Console
86
+
87
+ console = Console(record=True)
88
+
89
+ columns = Columns(
90
+ (f":{name}: {name}" for name in sorted(EMOJI.keys()) if "\u200D" not in name),
91
+ column_first=True,
92
+ )
93
+
94
+ console.print(columns)
95
+ if len(sys.argv) > 1:
96
+ console.save_html(sys.argv[1])
llava/lib/python3.10/site-packages/pip/_vendor/rich/errors.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class ConsoleError(Exception):
2
+ """An error in console operation."""
3
+
4
+
5
+ class StyleError(Exception):
6
+ """An error in styles."""
7
+
8
+
9
+ class StyleSyntaxError(ConsoleError):
10
+ """Style was badly formatted."""
11
+
12
+
13
+ class MissingStyle(StyleError):
14
+ """No such style."""
15
+
16
+
17
+ class StyleStackError(ConsoleError):
18
+ """Style stack is invalid."""
19
+
20
+
21
+ class NotRenderableError(ConsoleError):
22
+ """Object is not renderable."""
23
+
24
+
25
+ class MarkupError(ConsoleError):
26
+ """Markup was badly formatted."""
27
+
28
+
29
+ class LiveError(ConsoleError):
30
+ """Error related to Live display."""
31
+
32
+
33
+ class NoAltScreen(ConsoleError):
34
+ """Alt screen mode was required."""
llava/lib/python3.10/site-packages/pip/_vendor/rich/jupyter.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence
2
+
3
+ if TYPE_CHECKING:
4
+ from pip._vendor.rich.console import ConsoleRenderable
5
+
6
+ from . import get_console
7
+ from .segment import Segment
8
+ from .terminal_theme import DEFAULT_TERMINAL_THEME
9
+
10
+ if TYPE_CHECKING:
11
+ from pip._vendor.rich.console import ConsoleRenderable
12
+
13
+ JUPYTER_HTML_FORMAT = """\
14
+ <pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">{code}</pre>
15
+ """
16
+
17
+
18
+ class JupyterRenderable:
19
+ """A shim to write html to Jupyter notebook."""
20
+
21
+ def __init__(self, html: str, text: str) -> None:
22
+ self.html = html
23
+ self.text = text
24
+
25
+ def _repr_mimebundle_(
26
+ self, include: Sequence[str], exclude: Sequence[str], **kwargs: Any
27
+ ) -> Dict[str, str]:
28
+ data = {"text/plain": self.text, "text/html": self.html}
29
+ if include:
30
+ data = {k: v for (k, v) in data.items() if k in include}
31
+ if exclude:
32
+ data = {k: v for (k, v) in data.items() if k not in exclude}
33
+ return data
34
+
35
+
36
+ class JupyterMixin:
37
+ """Add to an Rich renderable to make it render in Jupyter notebook."""
38
+
39
+ __slots__ = ()
40
+
41
+ def _repr_mimebundle_(
42
+ self: "ConsoleRenderable",
43
+ include: Sequence[str],
44
+ exclude: Sequence[str],
45
+ **kwargs: Any,
46
+ ) -> Dict[str, str]:
47
+ console = get_console()
48
+ segments = list(console.render(self, console.options))
49
+ html = _render_segments(segments)
50
+ text = console._render_buffer(segments)
51
+ data = {"text/plain": text, "text/html": html}
52
+ if include:
53
+ data = {k: v for (k, v) in data.items() if k in include}
54
+ if exclude:
55
+ data = {k: v for (k, v) in data.items() if k not in exclude}
56
+ return data
57
+
58
+
59
+ def _render_segments(segments: Iterable[Segment]) -> str:
60
+ def escape(text: str) -> str:
61
+ """Escape html."""
62
+ return text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
63
+
64
+ fragments: List[str] = []
65
+ append_fragment = fragments.append
66
+ theme = DEFAULT_TERMINAL_THEME
67
+ for text, style, control in Segment.simplify(segments):
68
+ if control:
69
+ continue
70
+ text = escape(text)
71
+ if style:
72
+ rule = style.get_html_style(theme)
73
+ text = f'<span style="{rule}">{text}</span>' if rule else text
74
+ if style.link:
75
+ text = f'<a href="{style.link}" target="_blank">{text}</a>'
76
+ append_fragment(text)
77
+
78
+ code = "".join(fragments)
79
+ html = JUPYTER_HTML_FORMAT.format(code=code)
80
+
81
+ return html
82
+
83
+
84
+ def display(segments: Iterable[Segment], text: str) -> None:
85
+ """Render segments to Jupyter."""
86
+ html = _render_segments(segments)
87
+ jupyter_renderable = JupyterRenderable(html, text)
88
+ try:
89
+ from IPython.display import display as ipython_display
90
+
91
+ ipython_display(jupyter_renderable)
92
+ except ModuleNotFoundError:
93
+ # Handle the case where the Console has force_jupyter=True,
94
+ # but IPython is not installed.
95
+ pass
96
+
97
+
98
+ def print(*args: Any, **kwargs: Any) -> None:
99
+ """Proxy for Console print."""
100
+ console = get_console()
101
+ return console.print(*args, **kwargs)
llava/lib/python3.10/site-packages/pip/_vendor/rich/layout.py ADDED
@@ -0,0 +1,442 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ from itertools import islice
3
+ from operator import itemgetter
4
+ from threading import RLock
5
+ from typing import (
6
+ TYPE_CHECKING,
7
+ Dict,
8
+ Iterable,
9
+ List,
10
+ NamedTuple,
11
+ Optional,
12
+ Sequence,
13
+ Tuple,
14
+ Union,
15
+ )
16
+
17
+ from ._ratio import ratio_resolve
18
+ from .align import Align
19
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
20
+ from .highlighter import ReprHighlighter
21
+ from .panel import Panel
22
+ from .pretty import Pretty
23
+ from .region import Region
24
+ from .repr import Result, rich_repr
25
+ from .segment import Segment
26
+ from .style import StyleType
27
+
28
+ if TYPE_CHECKING:
29
+ from pip._vendor.rich.tree import Tree
30
+
31
+
32
+ class LayoutRender(NamedTuple):
33
+ """An individual layout render."""
34
+
35
+ region: Region
36
+ render: List[List[Segment]]
37
+
38
+
39
+ RegionMap = Dict["Layout", Region]
40
+ RenderMap = Dict["Layout", LayoutRender]
41
+
42
+
43
+ class LayoutError(Exception):
44
+ """Layout related error."""
45
+
46
+
47
+ class NoSplitter(LayoutError):
48
+ """Requested splitter does not exist."""
49
+
50
+
51
+ class _Placeholder:
52
+ """An internal renderable used as a Layout placeholder."""
53
+
54
+ highlighter = ReprHighlighter()
55
+
56
+ def __init__(self, layout: "Layout", style: StyleType = "") -> None:
57
+ self.layout = layout
58
+ self.style = style
59
+
60
+ def __rich_console__(
61
+ self, console: Console, options: ConsoleOptions
62
+ ) -> RenderResult:
63
+ width = options.max_width
64
+ height = options.height or options.size.height
65
+ layout = self.layout
66
+ title = (
67
+ f"{layout.name!r} ({width} x {height})"
68
+ if layout.name
69
+ else f"({width} x {height})"
70
+ )
71
+ yield Panel(
72
+ Align.center(Pretty(layout), vertical="middle"),
73
+ style=self.style,
74
+ title=self.highlighter(title),
75
+ border_style="blue",
76
+ height=height,
77
+ )
78
+
79
+
80
+ class Splitter(ABC):
81
+ """Base class for a splitter."""
82
+
83
+ name: str = ""
84
+
85
+ @abstractmethod
86
+ def get_tree_icon(self) -> str:
87
+ """Get the icon (emoji) used in layout.tree"""
88
+
89
+ @abstractmethod
90
+ def divide(
91
+ self, children: Sequence["Layout"], region: Region
92
+ ) -> Iterable[Tuple["Layout", Region]]:
93
+ """Divide a region amongst several child layouts.
94
+
95
+ Args:
96
+ children (Sequence(Layout)): A number of child layouts.
97
+ region (Region): A rectangular region to divide.
98
+ """
99
+
100
+
101
+ class RowSplitter(Splitter):
102
+ """Split a layout region in to rows."""
103
+
104
+ name = "row"
105
+
106
+ def get_tree_icon(self) -> str:
107
+ return "[layout.tree.row]⬌"
108
+
109
+ def divide(
110
+ self, children: Sequence["Layout"], region: Region
111
+ ) -> Iterable[Tuple["Layout", Region]]:
112
+ x, y, width, height = region
113
+ render_widths = ratio_resolve(width, children)
114
+ offset = 0
115
+ _Region = Region
116
+ for child, child_width in zip(children, render_widths):
117
+ yield child, _Region(x + offset, y, child_width, height)
118
+ offset += child_width
119
+
120
+
121
+ class ColumnSplitter(Splitter):
122
+ """Split a layout region in to columns."""
123
+
124
+ name = "column"
125
+
126
+ def get_tree_icon(self) -> str:
127
+ return "[layout.tree.column]⬍"
128
+
129
+ def divide(
130
+ self, children: Sequence["Layout"], region: Region
131
+ ) -> Iterable[Tuple["Layout", Region]]:
132
+ x, y, width, height = region
133
+ render_heights = ratio_resolve(height, children)
134
+ offset = 0
135
+ _Region = Region
136
+ for child, child_height in zip(children, render_heights):
137
+ yield child, _Region(x, y + offset, width, child_height)
138
+ offset += child_height
139
+
140
+
141
+ @rich_repr
142
+ class Layout:
143
+ """A renderable to divide a fixed height in to rows or columns.
144
+
145
+ Args:
146
+ renderable (RenderableType, optional): Renderable content, or None for placeholder. Defaults to None.
147
+ name (str, optional): Optional identifier for Layout. Defaults to None.
148
+ size (int, optional): Optional fixed size of layout. Defaults to None.
149
+ minimum_size (int, optional): Minimum size of layout. Defaults to 1.
150
+ ratio (int, optional): Optional ratio for flexible layout. Defaults to 1.
151
+ visible (bool, optional): Visibility of layout. Defaults to True.
152
+ """
153
+
154
+ splitters = {"row": RowSplitter, "column": ColumnSplitter}
155
+
156
+ def __init__(
157
+ self,
158
+ renderable: Optional[RenderableType] = None,
159
+ *,
160
+ name: Optional[str] = None,
161
+ size: Optional[int] = None,
162
+ minimum_size: int = 1,
163
+ ratio: int = 1,
164
+ visible: bool = True,
165
+ ) -> None:
166
+ self._renderable = renderable or _Placeholder(self)
167
+ self.size = size
168
+ self.minimum_size = minimum_size
169
+ self.ratio = ratio
170
+ self.name = name
171
+ self.visible = visible
172
+ self.splitter: Splitter = self.splitters["column"]()
173
+ self._children: List[Layout] = []
174
+ self._render_map: RenderMap = {}
175
+ self._lock = RLock()
176
+
177
+ def __rich_repr__(self) -> Result:
178
+ yield "name", self.name, None
179
+ yield "size", self.size, None
180
+ yield "minimum_size", self.minimum_size, 1
181
+ yield "ratio", self.ratio, 1
182
+
183
+ @property
184
+ def renderable(self) -> RenderableType:
185
+ """Layout renderable."""
186
+ return self if self._children else self._renderable
187
+
188
+ @property
189
+ def children(self) -> List["Layout"]:
190
+ """Gets (visible) layout children."""
191
+ return [child for child in self._children if child.visible]
192
+
193
+ @property
194
+ def map(self) -> RenderMap:
195
+ """Get a map of the last render."""
196
+ return self._render_map
197
+
198
+ def get(self, name: str) -> Optional["Layout"]:
199
+ """Get a named layout, or None if it doesn't exist.
200
+
201
+ Args:
202
+ name (str): Name of layout.
203
+
204
+ Returns:
205
+ Optional[Layout]: Layout instance or None if no layout was found.
206
+ """
207
+ if self.name == name:
208
+ return self
209
+ else:
210
+ for child in self._children:
211
+ named_layout = child.get(name)
212
+ if named_layout is not None:
213
+ return named_layout
214
+ return None
215
+
216
+ def __getitem__(self, name: str) -> "Layout":
217
+ layout = self.get(name)
218
+ if layout is None:
219
+ raise KeyError(f"No layout with name {name!r}")
220
+ return layout
221
+
222
+ @property
223
+ def tree(self) -> "Tree":
224
+ """Get a tree renderable to show layout structure."""
225
+ from pip._vendor.rich.styled import Styled
226
+ from pip._vendor.rich.table import Table
227
+ from pip._vendor.rich.tree import Tree
228
+
229
+ def summary(layout: "Layout") -> Table:
230
+ icon = layout.splitter.get_tree_icon()
231
+
232
+ table = Table.grid(padding=(0, 1, 0, 0))
233
+
234
+ text: RenderableType = (
235
+ Pretty(layout) if layout.visible else Styled(Pretty(layout), "dim")
236
+ )
237
+ table.add_row(icon, text)
238
+ _summary = table
239
+ return _summary
240
+
241
+ layout = self
242
+ tree = Tree(
243
+ summary(layout),
244
+ guide_style=f"layout.tree.{layout.splitter.name}",
245
+ highlight=True,
246
+ )
247
+
248
+ def recurse(tree: "Tree", layout: "Layout") -> None:
249
+ for child in layout._children:
250
+ recurse(
251
+ tree.add(
252
+ summary(child),
253
+ guide_style=f"layout.tree.{child.splitter.name}",
254
+ ),
255
+ child,
256
+ )
257
+
258
+ recurse(tree, self)
259
+ return tree
260
+
261
+ def split(
262
+ self,
263
+ *layouts: Union["Layout", RenderableType],
264
+ splitter: Union[Splitter, str] = "column",
265
+ ) -> None:
266
+ """Split the layout in to multiple sub-layouts.
267
+
268
+ Args:
269
+ *layouts (Layout): Positional arguments should be (sub) Layout instances.
270
+ splitter (Union[Splitter, str]): Splitter instance or name of splitter.
271
+ """
272
+ _layouts = [
273
+ layout if isinstance(layout, Layout) else Layout(layout)
274
+ for layout in layouts
275
+ ]
276
+ try:
277
+ self.splitter = (
278
+ splitter
279
+ if isinstance(splitter, Splitter)
280
+ else self.splitters[splitter]()
281
+ )
282
+ except KeyError:
283
+ raise NoSplitter(f"No splitter called {splitter!r}")
284
+ self._children[:] = _layouts
285
+
286
+ def add_split(self, *layouts: Union["Layout", RenderableType]) -> None:
287
+ """Add a new layout(s) to existing split.
288
+
289
+ Args:
290
+ *layouts (Union[Layout, RenderableType]): Positional arguments should be renderables or (sub) Layout instances.
291
+
292
+ """
293
+ _layouts = (
294
+ layout if isinstance(layout, Layout) else Layout(layout)
295
+ for layout in layouts
296
+ )
297
+ self._children.extend(_layouts)
298
+
299
+ def split_row(self, *layouts: Union["Layout", RenderableType]) -> None:
300
+ """Split the layout in to a row (layouts side by side).
301
+
302
+ Args:
303
+ *layouts (Layout): Positional arguments should be (sub) Layout instances.
304
+ """
305
+ self.split(*layouts, splitter="row")
306
+
307
+ def split_column(self, *layouts: Union["Layout", RenderableType]) -> None:
308
+ """Split the layout in to a column (layouts stacked on top of each other).
309
+
310
+ Args:
311
+ *layouts (Layout): Positional arguments should be (sub) Layout instances.
312
+ """
313
+ self.split(*layouts, splitter="column")
314
+
315
+ def unsplit(self) -> None:
316
+ """Reset splits to initial state."""
317
+ del self._children[:]
318
+
319
+ def update(self, renderable: RenderableType) -> None:
320
+ """Update renderable.
321
+
322
+ Args:
323
+ renderable (RenderableType): New renderable object.
324
+ """
325
+ with self._lock:
326
+ self._renderable = renderable
327
+
328
+ def refresh_screen(self, console: "Console", layout_name: str) -> None:
329
+ """Refresh a sub-layout.
330
+
331
+ Args:
332
+ console (Console): Console instance where Layout is to be rendered.
333
+ layout_name (str): Name of layout.
334
+ """
335
+ with self._lock:
336
+ layout = self[layout_name]
337
+ region, _lines = self._render_map[layout]
338
+ (x, y, width, height) = region
339
+ lines = console.render_lines(
340
+ layout, console.options.update_dimensions(width, height)
341
+ )
342
+ self._render_map[layout] = LayoutRender(region, lines)
343
+ console.update_screen_lines(lines, x, y)
344
+
345
+ def _make_region_map(self, width: int, height: int) -> RegionMap:
346
+ """Create a dict that maps layout on to Region."""
347
+ stack: List[Tuple[Layout, Region]] = [(self, Region(0, 0, width, height))]
348
+ push = stack.append
349
+ pop = stack.pop
350
+ layout_regions: List[Tuple[Layout, Region]] = []
351
+ append_layout_region = layout_regions.append
352
+ while stack:
353
+ append_layout_region(pop())
354
+ layout, region = layout_regions[-1]
355
+ children = layout.children
356
+ if children:
357
+ for child_and_region in layout.splitter.divide(children, region):
358
+ push(child_and_region)
359
+
360
+ region_map = {
361
+ layout: region
362
+ for layout, region in sorted(layout_regions, key=itemgetter(1))
363
+ }
364
+ return region_map
365
+
366
+ def render(self, console: Console, options: ConsoleOptions) -> RenderMap:
367
+ """Render the sub_layouts.
368
+
369
+ Args:
370
+ console (Console): Console instance.
371
+ options (ConsoleOptions): Console options.
372
+
373
+ Returns:
374
+ RenderMap: A dict that maps Layout on to a tuple of Region, lines
375
+ """
376
+ render_width = options.max_width
377
+ render_height = options.height or console.height
378
+ region_map = self._make_region_map(render_width, render_height)
379
+ layout_regions = [
380
+ (layout, region)
381
+ for layout, region in region_map.items()
382
+ if not layout.children
383
+ ]
384
+ render_map: Dict["Layout", "LayoutRender"] = {}
385
+ render_lines = console.render_lines
386
+ update_dimensions = options.update_dimensions
387
+
388
+ for layout, region in layout_regions:
389
+ lines = render_lines(
390
+ layout.renderable, update_dimensions(region.width, region.height)
391
+ )
392
+ render_map[layout] = LayoutRender(region, lines)
393
+ return render_map
394
+
395
+ def __rich_console__(
396
+ self, console: Console, options: ConsoleOptions
397
+ ) -> RenderResult:
398
+ with self._lock:
399
+ width = options.max_width or console.width
400
+ height = options.height or console.height
401
+ render_map = self.render(console, options.update_dimensions(width, height))
402
+ self._render_map = render_map
403
+ layout_lines: List[List[Segment]] = [[] for _ in range(height)]
404
+ _islice = islice
405
+ for region, lines in render_map.values():
406
+ _x, y, _layout_width, layout_height = region
407
+ for row, line in zip(
408
+ _islice(layout_lines, y, y + layout_height), lines
409
+ ):
410
+ row.extend(line)
411
+
412
+ new_line = Segment.line()
413
+ for layout_row in layout_lines:
414
+ yield from layout_row
415
+ yield new_line
416
+
417
+
418
+ if __name__ == "__main__":
419
+ from pip._vendor.rich.console import Console
420
+
421
+ console = Console()
422
+ layout = Layout()
423
+
424
+ layout.split_column(
425
+ Layout(name="header", size=3),
426
+ Layout(ratio=1, name="main"),
427
+ Layout(size=10, name="footer"),
428
+ )
429
+
430
+ layout["main"].split_row(Layout(name="side"), Layout(name="body", ratio=2))
431
+
432
+ layout["body"].split_row(Layout(name="content", ratio=2), Layout(name="s2"))
433
+
434
+ layout["s2"].split_column(
435
+ Layout(name="top"), Layout(name="middle"), Layout(name="bottom")
436
+ )
437
+
438
+ layout["side"].split_column(Layout(layout.tree, name="left1"), Layout(name="left2"))
439
+
440
+ layout["content"].update("foo")
441
+
442
+ console.print(layout)
llava/lib/python3.10/site-packages/pip/_vendor/rich/live.py ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from threading import Event, RLock, Thread
3
+ from types import TracebackType
4
+ from typing import IO, Any, Callable, List, Optional, TextIO, Type, cast
5
+
6
+ from . import get_console
7
+ from .console import Console, ConsoleRenderable, RenderableType, RenderHook
8
+ from .control import Control
9
+ from .file_proxy import FileProxy
10
+ from .jupyter import JupyterMixin
11
+ from .live_render import LiveRender, VerticalOverflowMethod
12
+ from .screen import Screen
13
+ from .text import Text
14
+
15
+
16
+ class _RefreshThread(Thread):
17
+ """A thread that calls refresh() at regular intervals."""
18
+
19
+ def __init__(self, live: "Live", refresh_per_second: float) -> None:
20
+ self.live = live
21
+ self.refresh_per_second = refresh_per_second
22
+ self.done = Event()
23
+ super().__init__(daemon=True)
24
+
25
+ def stop(self) -> None:
26
+ self.done.set()
27
+
28
+ def run(self) -> None:
29
+ while not self.done.wait(1 / self.refresh_per_second):
30
+ with self.live._lock:
31
+ if not self.done.is_set():
32
+ self.live.refresh()
33
+
34
+
35
+ class Live(JupyterMixin, RenderHook):
36
+ """Renders an auto-updating live display of any given renderable.
37
+
38
+ Args:
39
+ renderable (RenderableType, optional): The renderable to live display. Defaults to displaying nothing.
40
+ console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout.
41
+ screen (bool, optional): Enable alternate screen mode. Defaults to False.
42
+ auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()` or `update()` with refresh flag. Defaults to True
43
+ refresh_per_second (float, optional): Number of times per second to refresh the live display. Defaults to 4.
44
+ transient (bool, optional): Clear the renderable on exit (has no effect when screen=True). Defaults to False.
45
+ redirect_stdout (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
46
+ redirect_stderr (bool, optional): Enable redirection of stderr. Defaults to True.
47
+ vertical_overflow (VerticalOverflowMethod, optional): How to handle renderable when it is too tall for the console. Defaults to "ellipsis".
48
+ get_renderable (Callable[[], RenderableType], optional): Optional callable to get renderable. Defaults to None.
49
+ """
50
+
51
+ def __init__(
52
+ self,
53
+ renderable: Optional[RenderableType] = None,
54
+ *,
55
+ console: Optional[Console] = None,
56
+ screen: bool = False,
57
+ auto_refresh: bool = True,
58
+ refresh_per_second: float = 4,
59
+ transient: bool = False,
60
+ redirect_stdout: bool = True,
61
+ redirect_stderr: bool = True,
62
+ vertical_overflow: VerticalOverflowMethod = "ellipsis",
63
+ get_renderable: Optional[Callable[[], RenderableType]] = None,
64
+ ) -> None:
65
+ assert refresh_per_second > 0, "refresh_per_second must be > 0"
66
+ self._renderable = renderable
67
+ self.console = console if console is not None else get_console()
68
+ self._screen = screen
69
+ self._alt_screen = False
70
+
71
+ self._redirect_stdout = redirect_stdout
72
+ self._redirect_stderr = redirect_stderr
73
+ self._restore_stdout: Optional[IO[str]] = None
74
+ self._restore_stderr: Optional[IO[str]] = None
75
+
76
+ self._lock = RLock()
77
+ self.ipy_widget: Optional[Any] = None
78
+ self.auto_refresh = auto_refresh
79
+ self._started: bool = False
80
+ self.transient = True if screen else transient
81
+
82
+ self._refresh_thread: Optional[_RefreshThread] = None
83
+ self.refresh_per_second = refresh_per_second
84
+
85
+ self.vertical_overflow = vertical_overflow
86
+ self._get_renderable = get_renderable
87
+ self._live_render = LiveRender(
88
+ self.get_renderable(), vertical_overflow=vertical_overflow
89
+ )
90
+
91
+ @property
92
+ def is_started(self) -> bool:
93
+ """Check if live display has been started."""
94
+ return self._started
95
+
96
+ def get_renderable(self) -> RenderableType:
97
+ renderable = (
98
+ self._get_renderable()
99
+ if self._get_renderable is not None
100
+ else self._renderable
101
+ )
102
+ return renderable or ""
103
+
104
+ def start(self, refresh: bool = False) -> None:
105
+ """Start live rendering display.
106
+
107
+ Args:
108
+ refresh (bool, optional): Also refresh. Defaults to False.
109
+ """
110
+ with self._lock:
111
+ if self._started:
112
+ return
113
+ self.console.set_live(self)
114
+ self._started = True
115
+ if self._screen:
116
+ self._alt_screen = self.console.set_alt_screen(True)
117
+ self.console.show_cursor(False)
118
+ self._enable_redirect_io()
119
+ self.console.push_render_hook(self)
120
+ if refresh:
121
+ try:
122
+ self.refresh()
123
+ except Exception:
124
+ # If refresh fails, we want to stop the redirection of sys.stderr,
125
+ # so the error stacktrace is properly displayed in the terminal.
126
+ # (or, if the code that calls Rich captures the exception and wants to display something,
127
+ # let this be displayed in the terminal).
128
+ self.stop()
129
+ raise
130
+ if self.auto_refresh:
131
+ self._refresh_thread = _RefreshThread(self, self.refresh_per_second)
132
+ self._refresh_thread.start()
133
+
134
+ def stop(self) -> None:
135
+ """Stop live rendering display."""
136
+ with self._lock:
137
+ if not self._started:
138
+ return
139
+ self.console.clear_live()
140
+ self._started = False
141
+
142
+ if self.auto_refresh and self._refresh_thread is not None:
143
+ self._refresh_thread.stop()
144
+ self._refresh_thread = None
145
+ # allow it to fully render on the last even if overflow
146
+ self.vertical_overflow = "visible"
147
+ with self.console:
148
+ try:
149
+ if not self._alt_screen and not self.console.is_jupyter:
150
+ self.refresh()
151
+ finally:
152
+ self._disable_redirect_io()
153
+ self.console.pop_render_hook()
154
+ if not self._alt_screen and self.console.is_terminal:
155
+ self.console.line()
156
+ self.console.show_cursor(True)
157
+ if self._alt_screen:
158
+ self.console.set_alt_screen(False)
159
+
160
+ if self.transient and not self._alt_screen:
161
+ self.console.control(self._live_render.restore_cursor())
162
+ if self.ipy_widget is not None and self.transient:
163
+ self.ipy_widget.close() # pragma: no cover
164
+
165
+ def __enter__(self) -> "Live":
166
+ self.start(refresh=self._renderable is not None)
167
+ return self
168
+
169
+ def __exit__(
170
+ self,
171
+ exc_type: Optional[Type[BaseException]],
172
+ exc_val: Optional[BaseException],
173
+ exc_tb: Optional[TracebackType],
174
+ ) -> None:
175
+ self.stop()
176
+
177
+ def _enable_redirect_io(self) -> None:
178
+ """Enable redirecting of stdout / stderr."""
179
+ if self.console.is_terminal or self.console.is_jupyter:
180
+ if self._redirect_stdout and not isinstance(sys.stdout, FileProxy):
181
+ self._restore_stdout = sys.stdout
182
+ sys.stdout = cast("TextIO", FileProxy(self.console, sys.stdout))
183
+ if self._redirect_stderr and not isinstance(sys.stderr, FileProxy):
184
+ self._restore_stderr = sys.stderr
185
+ sys.stderr = cast("TextIO", FileProxy(self.console, sys.stderr))
186
+
187
+ def _disable_redirect_io(self) -> None:
188
+ """Disable redirecting of stdout / stderr."""
189
+ if self._restore_stdout:
190
+ sys.stdout = cast("TextIO", self._restore_stdout)
191
+ self._restore_stdout = None
192
+ if self._restore_stderr:
193
+ sys.stderr = cast("TextIO", self._restore_stderr)
194
+ self._restore_stderr = None
195
+
196
+ @property
197
+ def renderable(self) -> RenderableType:
198
+ """Get the renderable that is being displayed
199
+
200
+ Returns:
201
+ RenderableType: Displayed renderable.
202
+ """
203
+ renderable = self.get_renderable()
204
+ return Screen(renderable) if self._alt_screen else renderable
205
+
206
+ def update(self, renderable: RenderableType, *, refresh: bool = False) -> None:
207
+ """Update the renderable that is being displayed
208
+
209
+ Args:
210
+ renderable (RenderableType): New renderable to use.
211
+ refresh (bool, optional): Refresh the display. Defaults to False.
212
+ """
213
+ if isinstance(renderable, str):
214
+ renderable = self.console.render_str(renderable)
215
+ with self._lock:
216
+ self._renderable = renderable
217
+ if refresh:
218
+ self.refresh()
219
+
220
+ def refresh(self) -> None:
221
+ """Update the display of the Live Render."""
222
+ with self._lock:
223
+ self._live_render.set_renderable(self.renderable)
224
+ if self.console.is_jupyter: # pragma: no cover
225
+ try:
226
+ from IPython.display import display
227
+ from ipywidgets import Output
228
+ except ImportError:
229
+ import warnings
230
+
231
+ warnings.warn('install "ipywidgets" for Jupyter support')
232
+ else:
233
+ if self.ipy_widget is None:
234
+ self.ipy_widget = Output()
235
+ display(self.ipy_widget)
236
+
237
+ with self.ipy_widget:
238
+ self.ipy_widget.clear_output(wait=True)
239
+ self.console.print(self._live_render.renderable)
240
+ elif self.console.is_terminal and not self.console.is_dumb_terminal:
241
+ with self.console:
242
+ self.console.print(Control())
243
+ elif (
244
+ not self._started and not self.transient
245
+ ): # if it is finished allow files or dumb-terminals to see final result
246
+ with self.console:
247
+ self.console.print(Control())
248
+
249
+ def process_renderables(
250
+ self, renderables: List[ConsoleRenderable]
251
+ ) -> List[ConsoleRenderable]:
252
+ """Process renderables to restore cursor and display progress."""
253
+ self._live_render.vertical_overflow = self.vertical_overflow
254
+ if self.console.is_interactive:
255
+ # lock needs acquiring as user can modify live_render renderable at any time unlike in Progress.
256
+ with self._lock:
257
+ reset = (
258
+ Control.home()
259
+ if self._alt_screen
260
+ else self._live_render.position_cursor()
261
+ )
262
+ renderables = [reset, *renderables, self._live_render]
263
+ elif (
264
+ not self._started and not self.transient
265
+ ): # if it is finished render the final output for files or dumb_terminals
266
+ renderables = [*renderables, self._live_render]
267
+
268
+ return renderables
269
+
270
+
271
+ if __name__ == "__main__": # pragma: no cover
272
+ import random
273
+ import time
274
+ from itertools import cycle
275
+ from typing import Dict, List, Tuple
276
+
277
+ from .align import Align
278
+ from .console import Console
279
+ from .live import Live as Live
280
+ from .panel import Panel
281
+ from .rule import Rule
282
+ from .syntax import Syntax
283
+ from .table import Table
284
+
285
+ console = Console()
286
+
287
+ syntax = Syntax(
288
+ '''def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
289
+ """Iterate and generate a tuple with a flag for last value."""
290
+ iter_values = iter(values)
291
+ try:
292
+ previous_value = next(iter_values)
293
+ except StopIteration:
294
+ return
295
+ for value in iter_values:
296
+ yield False, previous_value
297
+ previous_value = value
298
+ yield True, previous_value''',
299
+ "python",
300
+ line_numbers=True,
301
+ )
302
+
303
+ table = Table("foo", "bar", "baz")
304
+ table.add_row("1", "2", "3")
305
+
306
+ progress_renderables = [
307
+ "You can make the terminal shorter and taller to see the live table hide"
308
+ "Text may be printed while the progress bars are rendering.",
309
+ Panel("In fact, [i]any[/i] renderable will work"),
310
+ "Such as [magenta]tables[/]...",
311
+ table,
312
+ "Pretty printed structures...",
313
+ {"type": "example", "text": "Pretty printed"},
314
+ "Syntax...",
315
+ syntax,
316
+ Rule("Give it a try!"),
317
+ ]
318
+
319
+ examples = cycle(progress_renderables)
320
+
321
+ exchanges = [
322
+ "SGD",
323
+ "MYR",
324
+ "EUR",
325
+ "USD",
326
+ "AUD",
327
+ "JPY",
328
+ "CNH",
329
+ "HKD",
330
+ "CAD",
331
+ "INR",
332
+ "DKK",
333
+ "GBP",
334
+ "RUB",
335
+ "NZD",
336
+ "MXN",
337
+ "IDR",
338
+ "TWD",
339
+ "THB",
340
+ "VND",
341
+ ]
342
+ with Live(console=console) as live_table:
343
+ exchange_rate_dict: Dict[Tuple[str, str], float] = {}
344
+
345
+ for index in range(100):
346
+ select_exchange = exchanges[index % len(exchanges)]
347
+
348
+ for exchange in exchanges:
349
+ if exchange == select_exchange:
350
+ continue
351
+ time.sleep(0.4)
352
+ if random.randint(0, 10) < 1:
353
+ console.log(next(examples))
354
+ exchange_rate_dict[(select_exchange, exchange)] = 200 / (
355
+ (random.random() * 320) + 1
356
+ )
357
+ if len(exchange_rate_dict) > len(exchanges) - 1:
358
+ exchange_rate_dict.pop(list(exchange_rate_dict.keys())[0])
359
+ table = Table(title="Exchange Rates")
360
+
361
+ table.add_column("Source Currency")
362
+ table.add_column("Destination Currency")
363
+ table.add_column("Exchange Rate")
364
+
365
+ for (source, dest), exchange_rate in exchange_rate_dict.items():
366
+ table.add_row(
367
+ source,
368
+ dest,
369
+ Text(
370
+ f"{exchange_rate:.4f}",
371
+ style="red" if exchange_rate < 1.0 else "green",
372
+ ),
373
+ )
374
+
375
+ live_table.update(Align.center(table))
llava/lib/python3.10/site-packages/pip/_vendor/rich/live_render.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from typing import Optional, Tuple
3
+
4
+ if sys.version_info >= (3, 8):
5
+ from typing import Literal
6
+ else:
7
+ from pip._vendor.typing_extensions import Literal # pragma: no cover
8
+
9
+
10
+ from ._loop import loop_last
11
+ from .console import Console, ConsoleOptions, RenderableType, RenderResult
12
+ from .control import Control
13
+ from .segment import ControlType, Segment
14
+ from .style import StyleType
15
+ from .text import Text
16
+
17
+ VerticalOverflowMethod = Literal["crop", "ellipsis", "visible"]
18
+
19
+
20
+ class LiveRender:
21
+ """Creates a renderable that may be updated.
22
+
23
+ Args:
24
+ renderable (RenderableType): Any renderable object.
25
+ style (StyleType, optional): An optional style to apply to the renderable. Defaults to "".
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ renderable: RenderableType,
31
+ style: StyleType = "",
32
+ vertical_overflow: VerticalOverflowMethod = "ellipsis",
33
+ ) -> None:
34
+ self.renderable = renderable
35
+ self.style = style
36
+ self.vertical_overflow = vertical_overflow
37
+ self._shape: Optional[Tuple[int, int]] = None
38
+
39
+ def set_renderable(self, renderable: RenderableType) -> None:
40
+ """Set a new renderable.
41
+
42
+ Args:
43
+ renderable (RenderableType): Any renderable object, including str.
44
+ """
45
+ self.renderable = renderable
46
+
47
+ def position_cursor(self) -> Control:
48
+ """Get control codes to move cursor to beginning of live render.
49
+
50
+ Returns:
51
+ Control: A control instance that may be printed.
52
+ """
53
+ if self._shape is not None:
54
+ _, height = self._shape
55
+ return Control(
56
+ ControlType.CARRIAGE_RETURN,
57
+ (ControlType.ERASE_IN_LINE, 2),
58
+ *(
59
+ (
60
+ (ControlType.CURSOR_UP, 1),
61
+ (ControlType.ERASE_IN_LINE, 2),
62
+ )
63
+ * (height - 1)
64
+ )
65
+ )
66
+ return Control()
67
+
68
+ def restore_cursor(self) -> Control:
69
+ """Get control codes to clear the render and restore the cursor to its previous position.
70
+
71
+ Returns:
72
+ Control: A Control instance that may be printed.
73
+ """
74
+ if self._shape is not None:
75
+ _, height = self._shape
76
+ return Control(
77
+ ControlType.CARRIAGE_RETURN,
78
+ *((ControlType.CURSOR_UP, 1), (ControlType.ERASE_IN_LINE, 2)) * height
79
+ )
80
+ return Control()
81
+
82
+ def __rich_console__(
83
+ self, console: Console, options: ConsoleOptions
84
+ ) -> RenderResult:
85
+ renderable = self.renderable
86
+ style = console.get_style(self.style)
87
+ lines = console.render_lines(renderable, options, style=style, pad=False)
88
+ shape = Segment.get_shape(lines)
89
+
90
+ _, height = shape
91
+ if height > options.size.height:
92
+ if self.vertical_overflow == "crop":
93
+ lines = lines[: options.size.height]
94
+ shape = Segment.get_shape(lines)
95
+ elif self.vertical_overflow == "ellipsis":
96
+ lines = lines[: (options.size.height - 1)]
97
+ overflow_text = Text(
98
+ "...",
99
+ overflow="crop",
100
+ justify="center",
101
+ end="",
102
+ style="live.ellipsis",
103
+ )
104
+ lines.append(list(console.render(overflow_text)))
105
+ shape = Segment.get_shape(lines)
106
+ self._shape = shape
107
+
108
+ new_line = Segment.line()
109
+ for last, line in loop_last(lines):
110
+ yield from line
111
+ if not last:
112
+ yield new_line
llava/lib/python3.10/site-packages/pip/_vendor/rich/measure.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from operator import itemgetter
2
+ from typing import TYPE_CHECKING, Callable, NamedTuple, Optional, Sequence
3
+
4
+ from . import errors
5
+ from .protocol import is_renderable, rich_cast
6
+
7
+ if TYPE_CHECKING:
8
+ from .console import Console, ConsoleOptions, RenderableType
9
+
10
+
11
+ class Measurement(NamedTuple):
12
+ """Stores the minimum and maximum widths (in characters) required to render an object."""
13
+
14
+ minimum: int
15
+ """Minimum number of cells required to render."""
16
+ maximum: int
17
+ """Maximum number of cells required to render."""
18
+
19
+ @property
20
+ def span(self) -> int:
21
+ """Get difference between maximum and minimum."""
22
+ return self.maximum - self.minimum
23
+
24
+ def normalize(self) -> "Measurement":
25
+ """Get measurement that ensures that minimum <= maximum and minimum >= 0
26
+
27
+ Returns:
28
+ Measurement: A normalized measurement.
29
+ """
30
+ minimum, maximum = self
31
+ minimum = min(max(0, minimum), maximum)
32
+ return Measurement(max(0, minimum), max(0, max(minimum, maximum)))
33
+
34
+ def with_maximum(self, width: int) -> "Measurement":
35
+ """Get a RenderableWith where the widths are <= width.
36
+
37
+ Args:
38
+ width (int): Maximum desired width.
39
+
40
+ Returns:
41
+ Measurement: New Measurement object.
42
+ """
43
+ minimum, maximum = self
44
+ return Measurement(min(minimum, width), min(maximum, width))
45
+
46
+ def with_minimum(self, width: int) -> "Measurement":
47
+ """Get a RenderableWith where the widths are >= width.
48
+
49
+ Args:
50
+ width (int): Minimum desired width.
51
+
52
+ Returns:
53
+ Measurement: New Measurement object.
54
+ """
55
+ minimum, maximum = self
56
+ width = max(0, width)
57
+ return Measurement(max(minimum, width), max(maximum, width))
58
+
59
+ def clamp(
60
+ self, min_width: Optional[int] = None, max_width: Optional[int] = None
61
+ ) -> "Measurement":
62
+ """Clamp a measurement within the specified range.
63
+
64
+ Args:
65
+ min_width (int): Minimum desired width, or ``None`` for no minimum. Defaults to None.
66
+ max_width (int): Maximum desired width, or ``None`` for no maximum. Defaults to None.
67
+
68
+ Returns:
69
+ Measurement: New Measurement object.
70
+ """
71
+ measurement = self
72
+ if min_width is not None:
73
+ measurement = measurement.with_minimum(min_width)
74
+ if max_width is not None:
75
+ measurement = measurement.with_maximum(max_width)
76
+ return measurement
77
+
78
+ @classmethod
79
+ def get(
80
+ cls, console: "Console", options: "ConsoleOptions", renderable: "RenderableType"
81
+ ) -> "Measurement":
82
+ """Get a measurement for a renderable.
83
+
84
+ Args:
85
+ console (~rich.console.Console): Console instance.
86
+ options (~rich.console.ConsoleOptions): Console options.
87
+ renderable (RenderableType): An object that may be rendered with Rich.
88
+
89
+ Raises:
90
+ errors.NotRenderableError: If the object is not renderable.
91
+
92
+ Returns:
93
+ Measurement: Measurement object containing range of character widths required to render the object.
94
+ """
95
+ _max_width = options.max_width
96
+ if _max_width < 1:
97
+ return Measurement(0, 0)
98
+ if isinstance(renderable, str):
99
+ renderable = console.render_str(
100
+ renderable, markup=options.markup, highlight=False
101
+ )
102
+ renderable = rich_cast(renderable)
103
+ if is_renderable(renderable):
104
+ get_console_width: Optional[
105
+ Callable[["Console", "ConsoleOptions"], "Measurement"]
106
+ ] = getattr(renderable, "__rich_measure__", None)
107
+ if get_console_width is not None:
108
+ render_width = (
109
+ get_console_width(console, options)
110
+ .normalize()
111
+ .with_maximum(_max_width)
112
+ )
113
+ if render_width.maximum < 1:
114
+ return Measurement(0, 0)
115
+ return render_width.normalize()
116
+ else:
117
+ return Measurement(0, _max_width)
118
+ else:
119
+ raise errors.NotRenderableError(
120
+ f"Unable to get render width for {renderable!r}; "
121
+ "a str, Segment, or object with __rich_console__ method is required"
122
+ )
123
+
124
+
125
+ def measure_renderables(
126
+ console: "Console",
127
+ options: "ConsoleOptions",
128
+ renderables: Sequence["RenderableType"],
129
+ ) -> "Measurement":
130
+ """Get a measurement that would fit a number of renderables.
131
+
132
+ Args:
133
+ console (~rich.console.Console): Console instance.
134
+ options (~rich.console.ConsoleOptions): Console options.
135
+ renderables (Iterable[RenderableType]): One or more renderable objects.
136
+
137
+ Returns:
138
+ Measurement: Measurement object containing range of character widths required to
139
+ contain all given renderables.
140
+ """
141
+ if not renderables:
142
+ return Measurement(0, 0)
143
+ get_measurement = Measurement.get
144
+ measurements = [
145
+ get_measurement(console, options, renderable) for renderable in renderables
146
+ ]
147
+ measured_width = Measurement(
148
+ max(measurements, key=itemgetter(0)).minimum,
149
+ max(measurements, key=itemgetter(1)).maximum,
150
+ )
151
+ return measured_width
llava/lib/python3.10/site-packages/pip/_vendor/rich/pager.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+
5
+ class Pager(ABC):
6
+ """Base class for a pager."""
7
+
8
+ @abstractmethod
9
+ def show(self, content: str) -> None:
10
+ """Show content in pager.
11
+
12
+ Args:
13
+ content (str): Content to be displayed.
14
+ """
15
+
16
+
17
+ class SystemPager(Pager):
18
+ """Uses the pager installed on the system."""
19
+
20
+ def _pager(self, content: str) -> Any: #  pragma: no cover
21
+ return __import__("pydoc").pager(content)
22
+
23
+ def show(self, content: str) -> None:
24
+ """Use the same pager used by pydoc."""
25
+ self._pager(content)
26
+
27
+
28
+ if __name__ == "__main__": # pragma: no cover
29
+ from .__main__ import make_test_card
30
+ from .console import Console
31
+
32
+ console = Console()
33
+ with console.pager(styles=True):
34
+ console.print(make_test_card())
llava/lib/python3.10/site-packages/pip/_vendor/rich/pretty.py ADDED
@@ -0,0 +1,1016 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import builtins
2
+ import collections
3
+ import dataclasses
4
+ import inspect
5
+ import os
6
+ import reprlib
7
+ import sys
8
+ from array import array
9
+ from collections import Counter, UserDict, UserList, defaultdict, deque
10
+ from dataclasses import dataclass, fields, is_dataclass
11
+ from inspect import isclass
12
+ from itertools import islice
13
+ from types import MappingProxyType
14
+ from typing import (
15
+ TYPE_CHECKING,
16
+ Any,
17
+ Callable,
18
+ DefaultDict,
19
+ Deque,
20
+ Dict,
21
+ Iterable,
22
+ List,
23
+ Optional,
24
+ Sequence,
25
+ Set,
26
+ Tuple,
27
+ Union,
28
+ )
29
+
30
+ from pip._vendor.rich.repr import RichReprResult
31
+
32
+ try:
33
+ import attr as _attr_module
34
+
35
+ _has_attrs = hasattr(_attr_module, "ib")
36
+ except ImportError: # pragma: no cover
37
+ _has_attrs = False
38
+
39
+ from . import get_console
40
+ from ._loop import loop_last
41
+ from ._pick import pick_bool
42
+ from .abc import RichRenderable
43
+ from .cells import cell_len
44
+ from .highlighter import ReprHighlighter
45
+ from .jupyter import JupyterMixin, JupyterRenderable
46
+ from .measure import Measurement
47
+ from .text import Text
48
+
49
+ if TYPE_CHECKING:
50
+ from .console import (
51
+ Console,
52
+ ConsoleOptions,
53
+ HighlighterType,
54
+ JustifyMethod,
55
+ OverflowMethod,
56
+ RenderResult,
57
+ )
58
+
59
+
60
+ def _is_attr_object(obj: Any) -> bool:
61
+ """Check if an object was created with attrs module."""
62
+ return _has_attrs and _attr_module.has(type(obj))
63
+
64
+
65
+ def _get_attr_fields(obj: Any) -> Sequence["_attr_module.Attribute[Any]"]:
66
+ """Get fields for an attrs object."""
67
+ return _attr_module.fields(type(obj)) if _has_attrs else []
68
+
69
+
70
+ def _is_dataclass_repr(obj: object) -> bool:
71
+ """Check if an instance of a dataclass contains the default repr.
72
+
73
+ Args:
74
+ obj (object): A dataclass instance.
75
+
76
+ Returns:
77
+ bool: True if the default repr is used, False if there is a custom repr.
78
+ """
79
+ # Digging in to a lot of internals here
80
+ # Catching all exceptions in case something is missing on a non CPython implementation
81
+ try:
82
+ return obj.__repr__.__code__.co_filename in (
83
+ dataclasses.__file__,
84
+ reprlib.__file__,
85
+ )
86
+ except Exception: # pragma: no coverage
87
+ return False
88
+
89
+
90
+ _dummy_namedtuple = collections.namedtuple("_dummy_namedtuple", [])
91
+
92
+
93
+ def _has_default_namedtuple_repr(obj: object) -> bool:
94
+ """Check if an instance of namedtuple contains the default repr
95
+
96
+ Args:
97
+ obj (object): A namedtuple
98
+
99
+ Returns:
100
+ bool: True if the default repr is used, False if there's a custom repr.
101
+ """
102
+ obj_file = None
103
+ try:
104
+ obj_file = inspect.getfile(obj.__repr__)
105
+ except (OSError, TypeError):
106
+ # OSError handles case where object is defined in __main__ scope, e.g. REPL - no filename available.
107
+ # TypeError trapped defensively, in case of object without filename slips through.
108
+ pass
109
+ default_repr_file = inspect.getfile(_dummy_namedtuple.__repr__)
110
+ return obj_file == default_repr_file
111
+
112
+
113
+ def _ipy_display_hook(
114
+ value: Any,
115
+ console: Optional["Console"] = None,
116
+ overflow: "OverflowMethod" = "ignore",
117
+ crop: bool = False,
118
+ indent_guides: bool = False,
119
+ max_length: Optional[int] = None,
120
+ max_string: Optional[int] = None,
121
+ max_depth: Optional[int] = None,
122
+ expand_all: bool = False,
123
+ ) -> Union[str, None]:
124
+ # needed here to prevent circular import:
125
+ from .console import ConsoleRenderable
126
+
127
+ # always skip rich generated jupyter renderables or None values
128
+ if _safe_isinstance(value, JupyterRenderable) or value is None:
129
+ return None
130
+
131
+ console = console or get_console()
132
+
133
+ with console.capture() as capture:
134
+ # certain renderables should start on a new line
135
+ if _safe_isinstance(value, ConsoleRenderable):
136
+ console.line()
137
+ console.print(
138
+ (
139
+ value
140
+ if _safe_isinstance(value, RichRenderable)
141
+ else Pretty(
142
+ value,
143
+ overflow=overflow,
144
+ indent_guides=indent_guides,
145
+ max_length=max_length,
146
+ max_string=max_string,
147
+ max_depth=max_depth,
148
+ expand_all=expand_all,
149
+ margin=12,
150
+ )
151
+ ),
152
+ crop=crop,
153
+ new_line_start=True,
154
+ end="",
155
+ )
156
+ # strip trailing newline, not usually part of a text repr
157
+ # I'm not sure if this should be prevented at a lower level
158
+ return capture.get().rstrip("\n")
159
+
160
+
161
+ def _safe_isinstance(
162
+ obj: object, class_or_tuple: Union[type, Tuple[type, ...]]
163
+ ) -> bool:
164
+ """isinstance can fail in rare cases, for example types with no __class__"""
165
+ try:
166
+ return isinstance(obj, class_or_tuple)
167
+ except Exception:
168
+ return False
169
+
170
+
171
+ def install(
172
+ console: Optional["Console"] = None,
173
+ overflow: "OverflowMethod" = "ignore",
174
+ crop: bool = False,
175
+ indent_guides: bool = False,
176
+ max_length: Optional[int] = None,
177
+ max_string: Optional[int] = None,
178
+ max_depth: Optional[int] = None,
179
+ expand_all: bool = False,
180
+ ) -> None:
181
+ """Install automatic pretty printing in the Python REPL.
182
+
183
+ Args:
184
+ console (Console, optional): Console instance or ``None`` to use global console. Defaults to None.
185
+ overflow (Optional[OverflowMethod], optional): Overflow method. Defaults to "ignore".
186
+ crop (Optional[bool], optional): Enable cropping of long lines. Defaults to False.
187
+ indent_guides (bool, optional): Enable indentation guides. Defaults to False.
188
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
189
+ Defaults to None.
190
+ max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
191
+ max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None.
192
+ expand_all (bool, optional): Expand all containers. Defaults to False.
193
+ max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
194
+ """
195
+ from pip._vendor.rich import get_console
196
+
197
+ console = console or get_console()
198
+ assert console is not None
199
+
200
+ def display_hook(value: Any) -> None:
201
+ """Replacement sys.displayhook which prettifies objects with Rich."""
202
+ if value is not None:
203
+ assert console is not None
204
+ builtins._ = None # type: ignore[attr-defined]
205
+ console.print(
206
+ (
207
+ value
208
+ if _safe_isinstance(value, RichRenderable)
209
+ else Pretty(
210
+ value,
211
+ overflow=overflow,
212
+ indent_guides=indent_guides,
213
+ max_length=max_length,
214
+ max_string=max_string,
215
+ max_depth=max_depth,
216
+ expand_all=expand_all,
217
+ )
218
+ ),
219
+ crop=crop,
220
+ )
221
+ builtins._ = value # type: ignore[attr-defined]
222
+
223
+ try:
224
+ ip = get_ipython() # type: ignore[name-defined]
225
+ except NameError:
226
+ sys.displayhook = display_hook
227
+ else:
228
+ from IPython.core.formatters import BaseFormatter
229
+
230
+ class RichFormatter(BaseFormatter): # type: ignore[misc]
231
+ pprint: bool = True
232
+
233
+ def __call__(self, value: Any) -> Any:
234
+ if self.pprint:
235
+ return _ipy_display_hook(
236
+ value,
237
+ console=get_console(),
238
+ overflow=overflow,
239
+ indent_guides=indent_guides,
240
+ max_length=max_length,
241
+ max_string=max_string,
242
+ max_depth=max_depth,
243
+ expand_all=expand_all,
244
+ )
245
+ else:
246
+ return repr(value)
247
+
248
+ # replace plain text formatter with rich formatter
249
+ rich_formatter = RichFormatter()
250
+ ip.display_formatter.formatters["text/plain"] = rich_formatter
251
+
252
+
253
+ class Pretty(JupyterMixin):
254
+ """A rich renderable that pretty prints an object.
255
+
256
+ Args:
257
+ _object (Any): An object to pretty print.
258
+ highlighter (HighlighterType, optional): Highlighter object to apply to result, or None for ReprHighlighter. Defaults to None.
259
+ indent_size (int, optional): Number of spaces in indent. Defaults to 4.
260
+ justify (JustifyMethod, optional): Justify method, or None for default. Defaults to None.
261
+ overflow (OverflowMethod, optional): Overflow method, or None for default. Defaults to None.
262
+ no_wrap (Optional[bool], optional): Disable word wrapping. Defaults to False.
263
+ indent_guides (bool, optional): Enable indentation guides. Defaults to False.
264
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
265
+ Defaults to None.
266
+ max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
267
+ max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None.
268
+ expand_all (bool, optional): Expand all containers. Defaults to False.
269
+ margin (int, optional): Subtrace a margin from width to force containers to expand earlier. Defaults to 0.
270
+ insert_line (bool, optional): Insert a new line if the output has multiple new lines. Defaults to False.
271
+ """
272
+
273
+ def __init__(
274
+ self,
275
+ _object: Any,
276
+ highlighter: Optional["HighlighterType"] = None,
277
+ *,
278
+ indent_size: int = 4,
279
+ justify: Optional["JustifyMethod"] = None,
280
+ overflow: Optional["OverflowMethod"] = None,
281
+ no_wrap: Optional[bool] = False,
282
+ indent_guides: bool = False,
283
+ max_length: Optional[int] = None,
284
+ max_string: Optional[int] = None,
285
+ max_depth: Optional[int] = None,
286
+ expand_all: bool = False,
287
+ margin: int = 0,
288
+ insert_line: bool = False,
289
+ ) -> None:
290
+ self._object = _object
291
+ self.highlighter = highlighter or ReprHighlighter()
292
+ self.indent_size = indent_size
293
+ self.justify: Optional["JustifyMethod"] = justify
294
+ self.overflow: Optional["OverflowMethod"] = overflow
295
+ self.no_wrap = no_wrap
296
+ self.indent_guides = indent_guides
297
+ self.max_length = max_length
298
+ self.max_string = max_string
299
+ self.max_depth = max_depth
300
+ self.expand_all = expand_all
301
+ self.margin = margin
302
+ self.insert_line = insert_line
303
+
304
+ def __rich_console__(
305
+ self, console: "Console", options: "ConsoleOptions"
306
+ ) -> "RenderResult":
307
+ pretty_str = pretty_repr(
308
+ self._object,
309
+ max_width=options.max_width - self.margin,
310
+ indent_size=self.indent_size,
311
+ max_length=self.max_length,
312
+ max_string=self.max_string,
313
+ max_depth=self.max_depth,
314
+ expand_all=self.expand_all,
315
+ )
316
+ pretty_text = Text.from_ansi(
317
+ pretty_str,
318
+ justify=self.justify or options.justify,
319
+ overflow=self.overflow or options.overflow,
320
+ no_wrap=pick_bool(self.no_wrap, options.no_wrap),
321
+ style="pretty",
322
+ )
323
+ pretty_text = (
324
+ self.highlighter(pretty_text)
325
+ if pretty_text
326
+ else Text(
327
+ f"{type(self._object)}.__repr__ returned empty string",
328
+ style="dim italic",
329
+ )
330
+ )
331
+ if self.indent_guides and not options.ascii_only:
332
+ pretty_text = pretty_text.with_indent_guides(
333
+ self.indent_size, style="repr.indent"
334
+ )
335
+ if self.insert_line and "\n" in pretty_text:
336
+ yield ""
337
+ yield pretty_text
338
+
339
+ def __rich_measure__(
340
+ self, console: "Console", options: "ConsoleOptions"
341
+ ) -> "Measurement":
342
+ pretty_str = pretty_repr(
343
+ self._object,
344
+ max_width=options.max_width,
345
+ indent_size=self.indent_size,
346
+ max_length=self.max_length,
347
+ max_string=self.max_string,
348
+ max_depth=self.max_depth,
349
+ expand_all=self.expand_all,
350
+ )
351
+ text_width = (
352
+ max(cell_len(line) for line in pretty_str.splitlines()) if pretty_str else 0
353
+ )
354
+ return Measurement(text_width, text_width)
355
+
356
+
357
+ def _get_braces_for_defaultdict(_object: DefaultDict[Any, Any]) -> Tuple[str, str, str]:
358
+ return (
359
+ f"defaultdict({_object.default_factory!r}, {{",
360
+ "})",
361
+ f"defaultdict({_object.default_factory!r}, {{}})",
362
+ )
363
+
364
+
365
+ def _get_braces_for_deque(_object: Deque[Any]) -> Tuple[str, str, str]:
366
+ if _object.maxlen is None:
367
+ return ("deque([", "])", "deque()")
368
+ return (
369
+ "deque([",
370
+ f"], maxlen={_object.maxlen})",
371
+ f"deque(maxlen={_object.maxlen})",
372
+ )
373
+
374
+
375
+ def _get_braces_for_array(_object: "array[Any]") -> Tuple[str, str, str]:
376
+ return (f"array({_object.typecode!r}, [", "])", f"array({_object.typecode!r})")
377
+
378
+
379
+ _BRACES: Dict[type, Callable[[Any], Tuple[str, str, str]]] = {
380
+ os._Environ: lambda _object: ("environ({", "})", "environ({})"),
381
+ array: _get_braces_for_array,
382
+ defaultdict: _get_braces_for_defaultdict,
383
+ Counter: lambda _object: ("Counter({", "})", "Counter()"),
384
+ deque: _get_braces_for_deque,
385
+ dict: lambda _object: ("{", "}", "{}"),
386
+ UserDict: lambda _object: ("{", "}", "{}"),
387
+ frozenset: lambda _object: ("frozenset({", "})", "frozenset()"),
388
+ list: lambda _object: ("[", "]", "[]"),
389
+ UserList: lambda _object: ("[", "]", "[]"),
390
+ set: lambda _object: ("{", "}", "set()"),
391
+ tuple: lambda _object: ("(", ")", "()"),
392
+ MappingProxyType: lambda _object: ("mappingproxy({", "})", "mappingproxy({})"),
393
+ }
394
+ _CONTAINERS = tuple(_BRACES.keys())
395
+ _MAPPING_CONTAINERS = (dict, os._Environ, MappingProxyType, UserDict)
396
+
397
+
398
+ def is_expandable(obj: Any) -> bool:
399
+ """Check if an object may be expanded by pretty print."""
400
+ return (
401
+ _safe_isinstance(obj, _CONTAINERS)
402
+ or (is_dataclass(obj))
403
+ or (hasattr(obj, "__rich_repr__"))
404
+ or _is_attr_object(obj)
405
+ ) and not isclass(obj)
406
+
407
+
408
+ @dataclass
409
+ class Node:
410
+ """A node in a repr tree. May be atomic or a container."""
411
+
412
+ key_repr: str = ""
413
+ value_repr: str = ""
414
+ open_brace: str = ""
415
+ close_brace: str = ""
416
+ empty: str = ""
417
+ last: bool = False
418
+ is_tuple: bool = False
419
+ is_namedtuple: bool = False
420
+ children: Optional[List["Node"]] = None
421
+ key_separator: str = ": "
422
+ separator: str = ", "
423
+
424
+ def iter_tokens(self) -> Iterable[str]:
425
+ """Generate tokens for this node."""
426
+ if self.key_repr:
427
+ yield self.key_repr
428
+ yield self.key_separator
429
+ if self.value_repr:
430
+ yield self.value_repr
431
+ elif self.children is not None:
432
+ if self.children:
433
+ yield self.open_brace
434
+ if self.is_tuple and not self.is_namedtuple and len(self.children) == 1:
435
+ yield from self.children[0].iter_tokens()
436
+ yield ","
437
+ else:
438
+ for child in self.children:
439
+ yield from child.iter_tokens()
440
+ if not child.last:
441
+ yield self.separator
442
+ yield self.close_brace
443
+ else:
444
+ yield self.empty
445
+
446
+ def check_length(self, start_length: int, max_length: int) -> bool:
447
+ """Check the length fits within a limit.
448
+
449
+ Args:
450
+ start_length (int): Starting length of the line (indent, prefix, suffix).
451
+ max_length (int): Maximum length.
452
+
453
+ Returns:
454
+ bool: True if the node can be rendered within max length, otherwise False.
455
+ """
456
+ total_length = start_length
457
+ for token in self.iter_tokens():
458
+ total_length += cell_len(token)
459
+ if total_length > max_length:
460
+ return False
461
+ return True
462
+
463
+ def __str__(self) -> str:
464
+ repr_text = "".join(self.iter_tokens())
465
+ return repr_text
466
+
467
+ def render(
468
+ self, max_width: int = 80, indent_size: int = 4, expand_all: bool = False
469
+ ) -> str:
470
+ """Render the node to a pretty repr.
471
+
472
+ Args:
473
+ max_width (int, optional): Maximum width of the repr. Defaults to 80.
474
+ indent_size (int, optional): Size of indents. Defaults to 4.
475
+ expand_all (bool, optional): Expand all levels. Defaults to False.
476
+
477
+ Returns:
478
+ str: A repr string of the original object.
479
+ """
480
+ lines = [_Line(node=self, is_root=True)]
481
+ line_no = 0
482
+ while line_no < len(lines):
483
+ line = lines[line_no]
484
+ if line.expandable and not line.expanded:
485
+ if expand_all or not line.check_length(max_width):
486
+ lines[line_no : line_no + 1] = line.expand(indent_size)
487
+ line_no += 1
488
+
489
+ repr_str = "\n".join(str(line) for line in lines)
490
+ return repr_str
491
+
492
+
493
+ @dataclass
494
+ class _Line:
495
+ """A line in repr output."""
496
+
497
+ parent: Optional["_Line"] = None
498
+ is_root: bool = False
499
+ node: Optional[Node] = None
500
+ text: str = ""
501
+ suffix: str = ""
502
+ whitespace: str = ""
503
+ expanded: bool = False
504
+ last: bool = False
505
+
506
+ @property
507
+ def expandable(self) -> bool:
508
+ """Check if the line may be expanded."""
509
+ return bool(self.node is not None and self.node.children)
510
+
511
+ def check_length(self, max_length: int) -> bool:
512
+ """Check this line fits within a given number of cells."""
513
+ start_length = (
514
+ len(self.whitespace) + cell_len(self.text) + cell_len(self.suffix)
515
+ )
516
+ assert self.node is not None
517
+ return self.node.check_length(start_length, max_length)
518
+
519
+ def expand(self, indent_size: int) -> Iterable["_Line"]:
520
+ """Expand this line by adding children on their own line."""
521
+ node = self.node
522
+ assert node is not None
523
+ whitespace = self.whitespace
524
+ assert node.children
525
+ if node.key_repr:
526
+ new_line = yield _Line(
527
+ text=f"{node.key_repr}{node.key_separator}{node.open_brace}",
528
+ whitespace=whitespace,
529
+ )
530
+ else:
531
+ new_line = yield _Line(text=node.open_brace, whitespace=whitespace)
532
+ child_whitespace = self.whitespace + " " * indent_size
533
+ tuple_of_one = node.is_tuple and len(node.children) == 1
534
+ for last, child in loop_last(node.children):
535
+ separator = "," if tuple_of_one else node.separator
536
+ line = _Line(
537
+ parent=new_line,
538
+ node=child,
539
+ whitespace=child_whitespace,
540
+ suffix=separator,
541
+ last=last and not tuple_of_one,
542
+ )
543
+ yield line
544
+
545
+ yield _Line(
546
+ text=node.close_brace,
547
+ whitespace=whitespace,
548
+ suffix=self.suffix,
549
+ last=self.last,
550
+ )
551
+
552
+ def __str__(self) -> str:
553
+ if self.last:
554
+ return f"{self.whitespace}{self.text}{self.node or ''}"
555
+ else:
556
+ return (
557
+ f"{self.whitespace}{self.text}{self.node or ''}{self.suffix.rstrip()}"
558
+ )
559
+
560
+
561
+ def _is_namedtuple(obj: Any) -> bool:
562
+ """Checks if an object is most likely a namedtuple. It is possible
563
+ to craft an object that passes this check and isn't a namedtuple, but
564
+ there is only a minuscule chance of this happening unintentionally.
565
+
566
+ Args:
567
+ obj (Any): The object to test
568
+
569
+ Returns:
570
+ bool: True if the object is a namedtuple. False otherwise.
571
+ """
572
+ try:
573
+ fields = getattr(obj, "_fields", None)
574
+ except Exception:
575
+ # Being very defensive - if we cannot get the attr then its not a namedtuple
576
+ return False
577
+ return isinstance(obj, tuple) and isinstance(fields, tuple)
578
+
579
+
580
+ def traverse(
581
+ _object: Any,
582
+ max_length: Optional[int] = None,
583
+ max_string: Optional[int] = None,
584
+ max_depth: Optional[int] = None,
585
+ ) -> Node:
586
+ """Traverse object and generate a tree.
587
+
588
+ Args:
589
+ _object (Any): Object to be traversed.
590
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
591
+ Defaults to None.
592
+ max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
593
+ Defaults to None.
594
+ max_depth (int, optional): Maximum depth of data structures, or None for no maximum.
595
+ Defaults to None.
596
+
597
+ Returns:
598
+ Node: The root of a tree structure which can be used to render a pretty repr.
599
+ """
600
+
601
+ def to_repr(obj: Any) -> str:
602
+ """Get repr string for an object, but catch errors."""
603
+ if (
604
+ max_string is not None
605
+ and _safe_isinstance(obj, (bytes, str))
606
+ and len(obj) > max_string
607
+ ):
608
+ truncated = len(obj) - max_string
609
+ obj_repr = f"{obj[:max_string]!r}+{truncated}"
610
+ else:
611
+ try:
612
+ obj_repr = repr(obj)
613
+ except Exception as error:
614
+ obj_repr = f"<repr-error {str(error)!r}>"
615
+ return obj_repr
616
+
617
+ visited_ids: Set[int] = set()
618
+ push_visited = visited_ids.add
619
+ pop_visited = visited_ids.remove
620
+
621
+ def _traverse(obj: Any, root: bool = False, depth: int = 0) -> Node:
622
+ """Walk the object depth first."""
623
+
624
+ obj_id = id(obj)
625
+ if obj_id in visited_ids:
626
+ # Recursion detected
627
+ return Node(value_repr="...")
628
+
629
+ obj_type = type(obj)
630
+ children: List[Node]
631
+ reached_max_depth = max_depth is not None and depth >= max_depth
632
+
633
+ def iter_rich_args(rich_args: Any) -> Iterable[Union[Any, Tuple[str, Any]]]:
634
+ for arg in rich_args:
635
+ if _safe_isinstance(arg, tuple):
636
+ if len(arg) == 3:
637
+ key, child, default = arg
638
+ if default == child:
639
+ continue
640
+ yield key, child
641
+ elif len(arg) == 2:
642
+ key, child = arg
643
+ yield key, child
644
+ elif len(arg) == 1:
645
+ yield arg[0]
646
+ else:
647
+ yield arg
648
+
649
+ try:
650
+ fake_attributes = hasattr(
651
+ obj, "awehoi234_wdfjwljet234_234wdfoijsdfmmnxpi492"
652
+ )
653
+ except Exception:
654
+ fake_attributes = False
655
+
656
+ rich_repr_result: Optional[RichReprResult] = None
657
+ if not fake_attributes:
658
+ try:
659
+ if hasattr(obj, "__rich_repr__") and not isclass(obj):
660
+ rich_repr_result = obj.__rich_repr__()
661
+ except Exception:
662
+ pass
663
+
664
+ if rich_repr_result is not None:
665
+ push_visited(obj_id)
666
+ angular = getattr(obj.__rich_repr__, "angular", False)
667
+ args = list(iter_rich_args(rich_repr_result))
668
+ class_name = obj.__class__.__name__
669
+
670
+ if args:
671
+ children = []
672
+ append = children.append
673
+
674
+ if reached_max_depth:
675
+ if angular:
676
+ node = Node(value_repr=f"<{class_name}...>")
677
+ else:
678
+ node = Node(value_repr=f"{class_name}(...)")
679
+ else:
680
+ if angular:
681
+ node = Node(
682
+ open_brace=f"<{class_name} ",
683
+ close_brace=">",
684
+ children=children,
685
+ last=root,
686
+ separator=" ",
687
+ )
688
+ else:
689
+ node = Node(
690
+ open_brace=f"{class_name}(",
691
+ close_brace=")",
692
+ children=children,
693
+ last=root,
694
+ )
695
+ for last, arg in loop_last(args):
696
+ if _safe_isinstance(arg, tuple):
697
+ key, child = arg
698
+ child_node = _traverse(child, depth=depth + 1)
699
+ child_node.last = last
700
+ child_node.key_repr = key
701
+ child_node.key_separator = "="
702
+ append(child_node)
703
+ else:
704
+ child_node = _traverse(arg, depth=depth + 1)
705
+ child_node.last = last
706
+ append(child_node)
707
+ else:
708
+ node = Node(
709
+ value_repr=f"<{class_name}>" if angular else f"{class_name}()",
710
+ children=[],
711
+ last=root,
712
+ )
713
+ pop_visited(obj_id)
714
+ elif _is_attr_object(obj) and not fake_attributes:
715
+ push_visited(obj_id)
716
+ children = []
717
+ append = children.append
718
+
719
+ attr_fields = _get_attr_fields(obj)
720
+ if attr_fields:
721
+ if reached_max_depth:
722
+ node = Node(value_repr=f"{obj.__class__.__name__}(...)")
723
+ else:
724
+ node = Node(
725
+ open_brace=f"{obj.__class__.__name__}(",
726
+ close_brace=")",
727
+ children=children,
728
+ last=root,
729
+ )
730
+
731
+ def iter_attrs() -> (
732
+ Iterable[Tuple[str, Any, Optional[Callable[[Any], str]]]]
733
+ ):
734
+ """Iterate over attr fields and values."""
735
+ for attr in attr_fields:
736
+ if attr.repr:
737
+ try:
738
+ value = getattr(obj, attr.name)
739
+ except Exception as error:
740
+ # Can happen, albeit rarely
741
+ yield (attr.name, error, None)
742
+ else:
743
+ yield (
744
+ attr.name,
745
+ value,
746
+ attr.repr if callable(attr.repr) else None,
747
+ )
748
+
749
+ for last, (name, value, repr_callable) in loop_last(iter_attrs()):
750
+ if repr_callable:
751
+ child_node = Node(value_repr=str(repr_callable(value)))
752
+ else:
753
+ child_node = _traverse(value, depth=depth + 1)
754
+ child_node.last = last
755
+ child_node.key_repr = name
756
+ child_node.key_separator = "="
757
+ append(child_node)
758
+ else:
759
+ node = Node(
760
+ value_repr=f"{obj.__class__.__name__}()", children=[], last=root
761
+ )
762
+ pop_visited(obj_id)
763
+ elif (
764
+ is_dataclass(obj)
765
+ and not _safe_isinstance(obj, type)
766
+ and not fake_attributes
767
+ and _is_dataclass_repr(obj)
768
+ ):
769
+ push_visited(obj_id)
770
+ children = []
771
+ append = children.append
772
+ if reached_max_depth:
773
+ node = Node(value_repr=f"{obj.__class__.__name__}(...)")
774
+ else:
775
+ node = Node(
776
+ open_brace=f"{obj.__class__.__name__}(",
777
+ close_brace=")",
778
+ children=children,
779
+ last=root,
780
+ empty=f"{obj.__class__.__name__}()",
781
+ )
782
+
783
+ for last, field in loop_last(
784
+ field
785
+ for field in fields(obj)
786
+ if field.repr and hasattr(obj, field.name)
787
+ ):
788
+ child_node = _traverse(getattr(obj, field.name), depth=depth + 1)
789
+ child_node.key_repr = field.name
790
+ child_node.last = last
791
+ child_node.key_separator = "="
792
+ append(child_node)
793
+
794
+ pop_visited(obj_id)
795
+ elif _is_namedtuple(obj) and _has_default_namedtuple_repr(obj):
796
+ push_visited(obj_id)
797
+ class_name = obj.__class__.__name__
798
+ if reached_max_depth:
799
+ # If we've reached the max depth, we still show the class name, but not its contents
800
+ node = Node(
801
+ value_repr=f"{class_name}(...)",
802
+ )
803
+ else:
804
+ children = []
805
+ append = children.append
806
+ node = Node(
807
+ open_brace=f"{class_name}(",
808
+ close_brace=")",
809
+ children=children,
810
+ empty=f"{class_name}()",
811
+ )
812
+ for last, (key, value) in loop_last(obj._asdict().items()):
813
+ child_node = _traverse(value, depth=depth + 1)
814
+ child_node.key_repr = key
815
+ child_node.last = last
816
+ child_node.key_separator = "="
817
+ append(child_node)
818
+ pop_visited(obj_id)
819
+ elif _safe_isinstance(obj, _CONTAINERS):
820
+ for container_type in _CONTAINERS:
821
+ if _safe_isinstance(obj, container_type):
822
+ obj_type = container_type
823
+ break
824
+
825
+ push_visited(obj_id)
826
+
827
+ open_brace, close_brace, empty = _BRACES[obj_type](obj)
828
+
829
+ if reached_max_depth:
830
+ node = Node(value_repr=f"{open_brace}...{close_brace}")
831
+ elif obj_type.__repr__ != type(obj).__repr__:
832
+ node = Node(value_repr=to_repr(obj), last=root)
833
+ elif obj:
834
+ children = []
835
+ node = Node(
836
+ open_brace=open_brace,
837
+ close_brace=close_brace,
838
+ children=children,
839
+ last=root,
840
+ )
841
+ append = children.append
842
+ num_items = len(obj)
843
+ last_item_index = num_items - 1
844
+
845
+ if _safe_isinstance(obj, _MAPPING_CONTAINERS):
846
+ iter_items = iter(obj.items())
847
+ if max_length is not None:
848
+ iter_items = islice(iter_items, max_length)
849
+ for index, (key, child) in enumerate(iter_items):
850
+ child_node = _traverse(child, depth=depth + 1)
851
+ child_node.key_repr = to_repr(key)
852
+ child_node.last = index == last_item_index
853
+ append(child_node)
854
+ else:
855
+ iter_values = iter(obj)
856
+ if max_length is not None:
857
+ iter_values = islice(iter_values, max_length)
858
+ for index, child in enumerate(iter_values):
859
+ child_node = _traverse(child, depth=depth + 1)
860
+ child_node.last = index == last_item_index
861
+ append(child_node)
862
+ if max_length is not None and num_items > max_length:
863
+ append(Node(value_repr=f"... +{num_items - max_length}", last=True))
864
+ else:
865
+ node = Node(empty=empty, children=[], last=root)
866
+
867
+ pop_visited(obj_id)
868
+ else:
869
+ node = Node(value_repr=to_repr(obj), last=root)
870
+ node.is_tuple = type(obj) == tuple
871
+ node.is_namedtuple = _is_namedtuple(obj)
872
+ return node
873
+
874
+ node = _traverse(_object, root=True)
875
+ return node
876
+
877
+
878
+ def pretty_repr(
879
+ _object: Any,
880
+ *,
881
+ max_width: int = 80,
882
+ indent_size: int = 4,
883
+ max_length: Optional[int] = None,
884
+ max_string: Optional[int] = None,
885
+ max_depth: Optional[int] = None,
886
+ expand_all: bool = False,
887
+ ) -> str:
888
+ """Prettify repr string by expanding on to new lines to fit within a given width.
889
+
890
+ Args:
891
+ _object (Any): Object to repr.
892
+ max_width (int, optional): Desired maximum width of repr string. Defaults to 80.
893
+ indent_size (int, optional): Number of spaces to indent. Defaults to 4.
894
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
895
+ Defaults to None.
896
+ max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
897
+ Defaults to None.
898
+ max_depth (int, optional): Maximum depth of nested data structure, or None for no depth.
899
+ Defaults to None.
900
+ expand_all (bool, optional): Expand all containers regardless of available width. Defaults to False.
901
+
902
+ Returns:
903
+ str: A possibly multi-line representation of the object.
904
+ """
905
+
906
+ if _safe_isinstance(_object, Node):
907
+ node = _object
908
+ else:
909
+ node = traverse(
910
+ _object, max_length=max_length, max_string=max_string, max_depth=max_depth
911
+ )
912
+ repr_str: str = node.render(
913
+ max_width=max_width, indent_size=indent_size, expand_all=expand_all
914
+ )
915
+ return repr_str
916
+
917
+
918
+ def pprint(
919
+ _object: Any,
920
+ *,
921
+ console: Optional["Console"] = None,
922
+ indent_guides: bool = True,
923
+ max_length: Optional[int] = None,
924
+ max_string: Optional[int] = None,
925
+ max_depth: Optional[int] = None,
926
+ expand_all: bool = False,
927
+ ) -> None:
928
+ """A convenience function for pretty printing.
929
+
930
+ Args:
931
+ _object (Any): Object to pretty print.
932
+ console (Console, optional): Console instance, or None to use default. Defaults to None.
933
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
934
+ Defaults to None.
935
+ max_string (int, optional): Maximum length of strings before truncating, or None to disable. Defaults to None.
936
+ max_depth (int, optional): Maximum depth for nested data structures, or None for unlimited depth. Defaults to None.
937
+ indent_guides (bool, optional): Enable indentation guides. Defaults to True.
938
+ expand_all (bool, optional): Expand all containers. Defaults to False.
939
+ """
940
+ _console = get_console() if console is None else console
941
+ _console.print(
942
+ Pretty(
943
+ _object,
944
+ max_length=max_length,
945
+ max_string=max_string,
946
+ max_depth=max_depth,
947
+ indent_guides=indent_guides,
948
+ expand_all=expand_all,
949
+ overflow="ignore",
950
+ ),
951
+ soft_wrap=True,
952
+ )
953
+
954
+
955
+ if __name__ == "__main__": # pragma: no cover
956
+
957
+ class BrokenRepr:
958
+ def __repr__(self) -> str:
959
+ 1 / 0
960
+ return "this will fail"
961
+
962
+ from typing import NamedTuple
963
+
964
+ class StockKeepingUnit(NamedTuple):
965
+ name: str
966
+ description: str
967
+ price: float
968
+ category: str
969
+ reviews: List[str]
970
+
971
+ d = defaultdict(int)
972
+ d["foo"] = 5
973
+ data = {
974
+ "foo": [
975
+ 1,
976
+ "Hello World!",
977
+ 100.123,
978
+ 323.232,
979
+ 432324.0,
980
+ {5, 6, 7, (1, 2, 3, 4), 8},
981
+ ],
982
+ "bar": frozenset({1, 2, 3}),
983
+ "defaultdict": defaultdict(
984
+ list, {"crumble": ["apple", "rhubarb", "butter", "sugar", "flour"]}
985
+ ),
986
+ "counter": Counter(
987
+ [
988
+ "apple",
989
+ "orange",
990
+ "pear",
991
+ "kumquat",
992
+ "kumquat",
993
+ "durian" * 100,
994
+ ]
995
+ ),
996
+ "atomic": (False, True, None),
997
+ "namedtuple": StockKeepingUnit(
998
+ "Sparkling British Spring Water",
999
+ "Carbonated spring water",
1000
+ 0.9,
1001
+ "water",
1002
+ ["its amazing!", "its terrible!"],
1003
+ ),
1004
+ "Broken": BrokenRepr(),
1005
+ }
1006
+ data["foo"].append(data) # type: ignore[attr-defined]
1007
+
1008
+ from pip._vendor.rich import print
1009
+
1010
+ print(Pretty(data, indent_guides=True, max_string=20))
1011
+
1012
+ class Thing:
1013
+ def __repr__(self) -> str:
1014
+ return "Hello\x1b[38;5;239m World!"
1015
+
1016
+ print(Pretty(Thing()))
llava/lib/python3.10/site-packages/pip/_vendor/rich/region.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import NamedTuple
2
+
3
+
4
+ class Region(NamedTuple):
5
+ """Defines a rectangular region of the screen."""
6
+
7
+ x: int
8
+ y: int
9
+ width: int
10
+ height: int
llava/lib/python3.10/site-packages/pip/_vendor/rich/scope.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, Optional, Tuple
3
+
4
+ from .highlighter import ReprHighlighter
5
+ from .panel import Panel
6
+ from .pretty import Pretty
7
+ from .table import Table
8
+ from .text import Text, TextType
9
+
10
+ if TYPE_CHECKING:
11
+ from .console import ConsoleRenderable
12
+
13
+
14
+ def render_scope(
15
+ scope: "Mapping[str, Any]",
16
+ *,
17
+ title: Optional[TextType] = None,
18
+ sort_keys: bool = True,
19
+ indent_guides: bool = False,
20
+ max_length: Optional[int] = None,
21
+ max_string: Optional[int] = None,
22
+ ) -> "ConsoleRenderable":
23
+ """Render python variables in a given scope.
24
+
25
+ Args:
26
+ scope (Mapping): A mapping containing variable names and values.
27
+ title (str, optional): Optional title. Defaults to None.
28
+ sort_keys (bool, optional): Enable sorting of items. Defaults to True.
29
+ indent_guides (bool, optional): Enable indentation guides. Defaults to False.
30
+ max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
31
+ Defaults to None.
32
+ max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
33
+
34
+ Returns:
35
+ ConsoleRenderable: A renderable object.
36
+ """
37
+ highlighter = ReprHighlighter()
38
+ items_table = Table.grid(padding=(0, 1), expand=False)
39
+ items_table.add_column(justify="right")
40
+
41
+ def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
42
+ """Sort special variables first, then alphabetically."""
43
+ key, _ = item
44
+ return (not key.startswith("__"), key.lower())
45
+
46
+ items = sorted(scope.items(), key=sort_items) if sort_keys else scope.items()
47
+ for key, value in items:
48
+ key_text = Text.assemble(
49
+ (key, "scope.key.special" if key.startswith("__") else "scope.key"),
50
+ (" =", "scope.equals"),
51
+ )
52
+ items_table.add_row(
53
+ key_text,
54
+ Pretty(
55
+ value,
56
+ highlighter=highlighter,
57
+ indent_guides=indent_guides,
58
+ max_length=max_length,
59
+ max_string=max_string,
60
+ ),
61
+ )
62
+ return Panel.fit(
63
+ items_table,
64
+ title=title,
65
+ border_style="scope.border",
66
+ padding=(0, 1),
67
+ )
68
+
69
+
70
+ if __name__ == "__main__": # pragma: no cover
71
+ from pip._vendor.rich import print
72
+
73
+ print()
74
+
75
+ def test(foo: float, bar: float) -> None:
76
+ list_of_things = [1, 2, 3, None, 4, True, False, "Hello World"]
77
+ dict_of_things = {
78
+ "version": "1.1",
79
+ "method": "confirmFruitPurchase",
80
+ "params": [["apple", "orange", "mangoes", "pomelo"], 1.123],
81
+ "id": "194521489",
82
+ }
83
+ print(render_scope(locals(), title="[i]locals", sort_keys=False))
84
+
85
+ test(20.3423, 3.1427)
86
+ print()
llava/lib/python3.10/site-packages/pip/_vendor/rich/styled.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TYPE_CHECKING
2
+
3
+ from .measure import Measurement
4
+ from .segment import Segment
5
+ from .style import StyleType
6
+
7
+ if TYPE_CHECKING:
8
+ from .console import Console, ConsoleOptions, RenderResult, RenderableType
9
+
10
+
11
+ class Styled:
12
+ """Apply a style to a renderable.
13
+
14
+ Args:
15
+ renderable (RenderableType): Any renderable.
16
+ style (StyleType): A style to apply across the entire renderable.
17
+ """
18
+
19
+ def __init__(self, renderable: "RenderableType", style: "StyleType") -> None:
20
+ self.renderable = renderable
21
+ self.style = style
22
+
23
+ def __rich_console__(
24
+ self, console: "Console", options: "ConsoleOptions"
25
+ ) -> "RenderResult":
26
+ style = console.get_style(self.style)
27
+ rendered_segments = console.render(self.renderable, options)
28
+ segments = Segment.apply_style(rendered_segments, style)
29
+ return segments
30
+
31
+ def __rich_measure__(
32
+ self, console: "Console", options: "ConsoleOptions"
33
+ ) -> Measurement:
34
+ return Measurement.get(console, options, self.renderable)
35
+
36
+
37
+ if __name__ == "__main__": # pragma: no cover
38
+ from pip._vendor.rich import print
39
+ from pip._vendor.rich.panel import Panel
40
+
41
+ panel = Styled(Panel("hello"), "on blue")
42
+ print(panel)
minigpt2/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle.cpython-310.pyc ADDED
Binary file (37.9 kB). View file
 
minigpt2/lib/python3.10/site-packages/cloudpickle/cloudpickle_fast.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compatibility module.
2
+
3
+ It can be necessary to load files generated by previous versions of cloudpickle
4
+ that rely on symbols being defined under the `cloudpickle.cloudpickle_fast`
5
+ namespace.
6
+
7
+ See: tests/test_backward_compat.py
8
+ """
9
+
10
+ from . import cloudpickle
11
+
12
+
13
+ def __getattr__(name):
14
+ return getattr(cloudpickle, name)
minigpt2/lib/python3.10/site-packages/imageio/__init__.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2014-2020, imageio contributors
3
+ # imageio is distributed under the terms of the (new) BSD License.
4
+
5
+ # This docstring is used at the index of the documentation pages, and
6
+ # gets inserted into a slightly larger description (in setup.py) for
7
+ # the page on Pypi:
8
+ """
9
+ Imageio is a Python library that provides an easy interface to read and
10
+ write a wide range of image data, including animated images, volumetric
11
+ data, and scientific formats. It is cross-platform, runs on Python 3.9+,
12
+ and is easy to install.
13
+
14
+ Main website: https://imageio.readthedocs.io/
15
+ """
16
+
17
+ # flake8: noqa
18
+
19
+ __version__ = "2.36.1"
20
+
21
+ import warnings
22
+
23
+ # Load some bits from core
24
+ from .core import FormatManager, RETURN_BYTES
25
+
26
+ # Instantiate the old format manager
27
+ formats = FormatManager()
28
+ show_formats = formats.show
29
+
30
+ from . import v2
31
+ from . import v3
32
+ from . import plugins
33
+
34
+ # import config after core to avoid circular import
35
+ from . import config
36
+
37
+ # import all APIs into the top level (meta API)
38
+ from .v2 import (
39
+ imread as imread_v2,
40
+ mimread,
41
+ volread,
42
+ mvolread,
43
+ imwrite,
44
+ mimwrite,
45
+ volwrite,
46
+ mvolwrite,
47
+ # aliases
48
+ get_reader as read,
49
+ get_writer as save,
50
+ imwrite as imsave,
51
+ mimwrite as mimsave,
52
+ volwrite as volsave,
53
+ mvolwrite as mvolsave,
54
+ # misc
55
+ help,
56
+ get_reader,
57
+ get_writer,
58
+ )
59
+ from .v3 import (
60
+ imopen,
61
+ # imread, # Will take over once v3 is released
62
+ # imwrite, # Will take over once v3 is released
63
+ imiter,
64
+ )
65
+
66
+
67
+ def imread(uri, format=None, **kwargs):
68
+ """imread(uri, format=None, **kwargs)
69
+
70
+ Reads an image from the specified file. Returns a numpy array, which
71
+ comes with a dict of meta data at its 'meta' attribute.
72
+
73
+ Note that the image data is returned as-is, and may not always have
74
+ a dtype of uint8 (and thus may differ from what e.g. PIL returns).
75
+
76
+ Parameters
77
+ ----------
78
+ uri : {str, pathlib.Path, bytes, file}
79
+ The resource to load the image from, e.g. a filename, pathlib.Path,
80
+ http address or file object, see the docs for more info.
81
+ format : str
82
+ The format to use to read the file. By default imageio selects
83
+ the appropriate for you based on the filename and its contents.
84
+ kwargs : ...
85
+ Further keyword arguments are passed to the reader. See :func:`.help`
86
+ to see what arguments are available for a particular format.
87
+ """
88
+
89
+ warnings.warn(
90
+ "Starting with ImageIO v3 the behavior of this function will switch to that of"
91
+ " iio.v3.imread. To keep the current behavior (and make this warning disappear)"
92
+ " use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.",
93
+ DeprecationWarning,
94
+ stacklevel=2,
95
+ )
96
+
97
+ return imread_v2(uri, format=format, **kwargs)
98
+
99
+
100
+ __all__ = [
101
+ "v2",
102
+ "v3",
103
+ "config",
104
+ "plugins",
105
+ # v3 API
106
+ "imopen",
107
+ "imread",
108
+ "imwrite",
109
+ "imiter",
110
+ # v2 API
111
+ "mimread",
112
+ "volread",
113
+ "mvolread",
114
+ "imwrite",
115
+ "mimwrite",
116
+ "volwrite",
117
+ "mvolwrite",
118
+ # v2 aliases
119
+ "read",
120
+ "save",
121
+ "imsave",
122
+ "mimsave",
123
+ "volsave",
124
+ "mvolsave",
125
+ # functions to deprecate
126
+ "help",
127
+ "get_reader",
128
+ "get_writer",
129
+ "formats",
130
+ "show_formats",
131
+ ]
minigpt2/lib/python3.10/site-packages/imageio/__main__.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Console scripts and associated helper methods for imageio.
3
+ """
4
+
5
+ import argparse
6
+ import os
7
+ from os import path as op
8
+ import shutil
9
+ import sys
10
+
11
+
12
+ from . import plugins
13
+ from .core import util
14
+
15
+ # A list of plugins that require binaries from the imageio-binaries
16
+ # repository. These plugins must implement the `download` method.
17
+ PLUGINS_WITH_BINARIES = ["freeimage"]
18
+
19
+
20
+ def download_bin(plugin_names=["all"], package_dir=False):
21
+ """Download binary dependencies of plugins
22
+
23
+ This is a convenience method for downloading the binaries
24
+ (e.g. for freeimage) from the imageio-binaries
25
+ repository.
26
+
27
+ Parameters
28
+ ----------
29
+ plugin_names: list
30
+ A list of imageio plugin names. If it contains "all", all
31
+ binary dependencies are downloaded.
32
+ package_dir: bool
33
+ If set to `True`, the binaries will be downloaded to the
34
+ `resources` directory of the imageio package instead of
35
+ to the users application data directory. Note that this
36
+ might require administrative rights if imageio is installed
37
+ in a system directory.
38
+ """
39
+ if plugin_names.count("all"):
40
+ # Use all plugins
41
+ plugin_names = PLUGINS_WITH_BINARIES
42
+
43
+ plugin_names.sort()
44
+ print("Ascertaining binaries for: {}.".format(", ".join(plugin_names)))
45
+
46
+ if package_dir:
47
+ # Download the binaries to the `resources` directory
48
+ # of imageio. If imageio comes as an .egg, then a cache
49
+ # directory will be created by pkg_resources (requires setuptools).
50
+ # see `imageio.core.util.resource_dirs`
51
+ # and `imageio.core.utilresource_package_dir`
52
+ directory = util.resource_package_dir()
53
+ else:
54
+ directory = None
55
+
56
+ for plg in plugin_names:
57
+ if plg not in PLUGINS_WITH_BINARIES:
58
+ msg = "Plugin {} not registered for binary download!".format(plg)
59
+ raise Exception(msg)
60
+ mod = getattr(plugins, plg)
61
+ mod.download(directory=directory)
62
+
63
+
64
+ def download_bin_main():
65
+ """Argument-parsing wrapper for `download_bin`"""
66
+ description = "Download plugin binary dependencies"
67
+ phelp = (
68
+ "Plugin name for which to download the binary. "
69
+ + "If no argument is given, all binaries are downloaded."
70
+ )
71
+ dhelp = (
72
+ "Download the binaries to the package directory "
73
+ + "(default is the users application data directory). "
74
+ + "This might require administrative rights."
75
+ )
76
+ example_text = (
77
+ "examples:\n"
78
+ + " imageio_download_bin all\n"
79
+ + " imageio_download_bin freeimage\n"
80
+ )
81
+ parser = argparse.ArgumentParser(
82
+ description=description,
83
+ epilog=example_text,
84
+ formatter_class=argparse.RawDescriptionHelpFormatter,
85
+ )
86
+ parser.add_argument("plugin", type=str, nargs="*", default="all", help=phelp)
87
+ parser.add_argument(
88
+ "--package-dir",
89
+ dest="package_dir",
90
+ action="store_true",
91
+ default=False,
92
+ help=dhelp,
93
+ )
94
+ args = parser.parse_args()
95
+ download_bin(plugin_names=args.plugin, package_dir=args.package_dir)
96
+
97
+
98
+ def remove_bin(plugin_names=["all"]):
99
+ """Remove binary dependencies of plugins
100
+
101
+ This is a convenience method that removes all binaries
102
+ dependencies for plugins downloaded by imageio.
103
+
104
+ Notes
105
+ -----
106
+ It only makes sense to use this method if the binaries
107
+ are corrupt.
108
+ """
109
+ if plugin_names.count("all"):
110
+ # Use all plugins
111
+ plugin_names = PLUGINS_WITH_BINARIES
112
+
113
+ print("Removing binaries for: {}.".format(", ".join(plugin_names)))
114
+
115
+ rdirs = util.resource_dirs()
116
+
117
+ for plg in plugin_names:
118
+ if plg not in PLUGINS_WITH_BINARIES:
119
+ msg = "Plugin {} not registered for binary download!".format(plg)
120
+ raise Exception(msg)
121
+
122
+ not_removed = []
123
+ for rd in rdirs:
124
+ # plugin name is in subdirectories
125
+ for rsub in os.listdir(rd):
126
+ if rsub in plugin_names:
127
+ plgdir = op.join(rd, rsub)
128
+ try:
129
+ shutil.rmtree(plgdir)
130
+ except Exception:
131
+ not_removed.append(plgdir)
132
+ if not_removed:
133
+ nrs = ",".join(not_removed)
134
+ msg2 = (
135
+ "These plugins files could not be removed: {}\n".format(nrs)
136
+ + "Make sure they are not used by any program and try again."
137
+ )
138
+ raise Exception(msg2)
139
+
140
+
141
+ def remove_bin_main():
142
+ """Argument-parsing wrapper for `remove_bin`"""
143
+ description = "Remove plugin binary dependencies"
144
+ phelp = (
145
+ "Plugin name for which to remove the binary. "
146
+ + "If no argument is given, all binaries are removed."
147
+ )
148
+ example_text = (
149
+ "examples:\n"
150
+ + " imageio_remove_bin all\n"
151
+ + " imageio_remove_bin freeimage\n"
152
+ )
153
+ parser = argparse.ArgumentParser(
154
+ description=description,
155
+ epilog=example_text,
156
+ formatter_class=argparse.RawDescriptionHelpFormatter,
157
+ )
158
+ parser.add_argument("plugin", type=str, nargs="*", default="all", help=phelp)
159
+ args = parser.parse_args()
160
+ remove_bin(plugin_names=args.plugin)
161
+
162
+
163
+ if __name__ == "__main__":
164
+ if len(sys.argv) > 1 and sys.argv[1] == "download_bin":
165
+ download_bin_main()
166
+ elif len(sys.argv) > 1 and sys.argv[1] == "remove_bin":
167
+ remove_bin_main()
168
+ else:
169
+ raise RuntimeError("Invalid use of the imageio CLI")
minigpt2/lib/python3.10/site-packages/imageio/testing.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Distributed under the (new) BSD License. See LICENSE.txt for more info.
3
+
4
+ """ Functionality used for testing. This code itself is not covered in tests.
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ import pytest
10
+
11
+ # Get root dir
12
+ THIS_DIR = os.path.abspath(os.path.dirname(__file__))
13
+ ROOT_DIR = THIS_DIR
14
+ for i in range(9):
15
+ ROOT_DIR = os.path.dirname(ROOT_DIR)
16
+ if os.path.isfile(os.path.join(ROOT_DIR, ".gitignore")):
17
+ break
18
+
19
+
20
+ # Functions to use from invoke tasks
21
+
22
+
23
+ def test_unit(cov_report="term"):
24
+ """Run all unit tests. Returns exit code."""
25
+ orig_dir = os.getcwd()
26
+ os.chdir(ROOT_DIR)
27
+ try:
28
+ _clear_imageio()
29
+ _enable_faulthandler()
30
+ return pytest.main(
31
+ [
32
+ "-v",
33
+ "--cov",
34
+ "imageio",
35
+ "--cov-config",
36
+ ".coveragerc",
37
+ "--cov-report",
38
+ cov_report,
39
+ "tests",
40
+ ]
41
+ )
42
+ finally:
43
+ os.chdir(orig_dir)
44
+ import imageio
45
+
46
+ print("Tests were performed on", str(imageio))
47
+
48
+
49
+ # Requirements
50
+
51
+
52
+ def _enable_faulthandler():
53
+ """Enable faulthandler (if we can), so that we get tracebacks
54
+ on segfaults.
55
+ """
56
+ try:
57
+ import faulthandler
58
+
59
+ faulthandler.enable()
60
+ print("Faulthandler enabled")
61
+ except Exception:
62
+ print("Could not enable faulthandler")
63
+
64
+
65
+ def _clear_imageio():
66
+ # Remove ourselves from sys.modules to force an import
67
+ for key in list(sys.modules.keys()):
68
+ if key.startswith("imageio"):
69
+ del sys.modules[key]
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/RECORD ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pyzmq-26.2.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ pyzmq-26.2.0.dist-info/METADATA,sha256=JROLdFYkzcegD9Zv5VKHnJoK4nQT0-oauUWeC_pN1rE,6175
3
+ pyzmq-26.2.0.dist-info/RECORD,,
4
+ pyzmq-26.2.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pyzmq-26.2.0.dist-info/WHEEL,sha256=8kV0YVV0HBTJGwuieEzbjtb0-mjhxb_2bVt9yL8tSxo,118
6
+ pyzmq-26.2.0.dist-info/licenses/LICENSE.md,sha256=wM9fXAP41ncveicd8ctnEFRXi9PXlSfHL8Hyj4zHKno,1545
7
+ pyzmq-26.2.0.dist-info/licenses/licenses/LICENSE.libsodium.txt,sha256=l98WCSd4Sn_Dz0UaoISoYAKhk1EvBZn1WkbRXuHEGnY,823
8
+ pyzmq-26.2.0.dist-info/licenses/licenses/LICENSE.zeromq.txt,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
9
+ pyzmq.libs/libsodium-1b1f72d5.so.26.1.0,sha256=7eCIADEK9s6bT040FHuA6SVHrjfH5-xXGtlQnGr9pQA,1246721
10
+ pyzmq.libs/libzmq-a430b4ce.so.5.2.5,sha256=_r9QWP8IbvUhOni0tYXkwObJOuj89BHqxhbH3nB0Ssc,970897
11
+ zmq/__init__.pxd,sha256=P2y5B_9nDB_0RD7hxbXpVm4Jia1rKclTnnUVrSbF4lE,63
12
+ zmq/__init__.py,sha256=0zUxdN9mC6mBJAOkBfsI4em8roHbvH0afHQTYsMFjXA,2232
13
+ zmq/__init__.pyi,sha256=4JJGGKu9IVsRVES3jNr2_MrHXA9CW6rjAiZqLGaKmq8,960
14
+ zmq/__pycache__/__init__.cpython-310.pyc,,
15
+ zmq/__pycache__/_future.cpython-310.pyc,,
16
+ zmq/__pycache__/_typing.cpython-310.pyc,,
17
+ zmq/__pycache__/asyncio.cpython-310.pyc,,
18
+ zmq/__pycache__/constants.cpython-310.pyc,,
19
+ zmq/__pycache__/decorators.cpython-310.pyc,,
20
+ zmq/__pycache__/error.cpython-310.pyc,,
21
+ zmq/_future.py,sha256=pjxXU88k3QhdEbKpET5pppzXfh_Ku8Gkvhg16HhxcPA,24919
22
+ zmq/_typing.py,sha256=iTmWMo_xE7PQ9FRA4I_5gpj2YSL0C29vTz_2H-Tvtio,720
23
+ zmq/asyncio.py,sha256=SrWQGEHVdmssDQtQAbPgDqZgmOQuohY5Tc4xZp_PJQ4,6266
24
+ zmq/auth/__init__.py,sha256=D0XJjPJgN0ZqSBLDrbLm3l3N5pMQt75pv8LyearhsM8,346
25
+ zmq/auth/__pycache__/__init__.cpython-310.pyc,,
26
+ zmq/auth/__pycache__/asyncio.cpython-310.pyc,,
27
+ zmq/auth/__pycache__/base.cpython-310.pyc,,
28
+ zmq/auth/__pycache__/certs.cpython-310.pyc,,
29
+ zmq/auth/__pycache__/ioloop.cpython-310.pyc,,
30
+ zmq/auth/__pycache__/thread.cpython-310.pyc,,
31
+ zmq/auth/asyncio.py,sha256=KLD0Kwev61dnImVhcLmEKr-PwTCqIyurWjs4SuH442A,1799
32
+ zmq/auth/base.py,sha256=OPTB58nTeYJL-bu9bHa4lXUCCMwzo7cwlhxRuHBjd0Y,16337
33
+ zmq/auth/certs.py,sha256=0lyPqG3o-ucI_UvCVpihxT10V9-hKJcyi5Us4trVGR0,4329
34
+ zmq/auth/ioloop.py,sha256=xXF6P8A-HZlXfIYMVv8BW8EI_H2PjrJFF3a6Ajvd1rI,1298
35
+ zmq/auth/thread.py,sha256=mv1NfTxJIydLhIkKdExPVDdWpcbczUDshIsYLUzhSkI,4103
36
+ zmq/backend/__init__.py,sha256=5PfcIfpIzxGIegOaHbO3dBilBzby3l0yKC0o_Qf1m3A,940
37
+ zmq/backend/__init__.pyi,sha256=NDw7Ahc8qjjQgW-MIqn_o4rWusK6slCCTpeyBpbXoZc,3379
38
+ zmq/backend/__pycache__/__init__.cpython-310.pyc,,
39
+ zmq/backend/__pycache__/select.cpython-310.pyc,,
40
+ zmq/backend/cffi/README.md,sha256=u7zNkS3dJALRPzpgPv5s4Q1tIkevm0BMzVpcwZD0PoM,95
41
+ zmq/backend/cffi/__init__.py,sha256=emCfRo-DxTG3mafsEBEpIX-GMFUUpajHpvSSpyB11w0,833
42
+ zmq/backend/cffi/__pycache__/__init__.cpython-310.pyc,,
43
+ zmq/backend/cffi/__pycache__/_poll.cpython-310.pyc,,
44
+ zmq/backend/cffi/__pycache__/context.cpython-310.pyc,,
45
+ zmq/backend/cffi/__pycache__/devices.cpython-310.pyc,,
46
+ zmq/backend/cffi/__pycache__/error.cpython-310.pyc,,
47
+ zmq/backend/cffi/__pycache__/message.cpython-310.pyc,,
48
+ zmq/backend/cffi/__pycache__/socket.cpython-310.pyc,,
49
+ zmq/backend/cffi/__pycache__/utils.cpython-310.pyc,,
50
+ zmq/backend/cffi/_cdefs.h,sha256=Ajw-Sxw5wv9zko0yBkqEi7TZc3nuESv1z1buwy1ppQc,2639
51
+ zmq/backend/cffi/_cffi_src.c,sha256=ADxHwdYLRjsRf8vuyOK8lbHiXTjgbfoiIwOjarFQ8ds,1314
52
+ zmq/backend/cffi/_poll.py,sha256=niEuO85_fLbRntELWu0k89qLicJPgnirX13fTnw0Irc,2884
53
+ zmq/backend/cffi/context.py,sha256=dKoVS0VJa0A1N3l9LYGRoYlRLmmHZigmnMhZyHsP-jA,1899
54
+ zmq/backend/cffi/devices.py,sha256=Fc19maZ2HA0qlcP7na26fBb--V9bibIJPoXvYmKnxvk,1572
55
+ zmq/backend/cffi/error.py,sha256=AO-QaesceSlKTWILjgzhr6PrffE8hQsPZFLbxQ3tIqE,380
56
+ zmq/backend/cffi/message.py,sha256=r6ob45NS_ZQh9oWo_n9ihBlO9ine-Odmt2BT2lXhPRc,6488
57
+ zmq/backend/cffi/socket.py,sha256=fD9JTFJRxW8l0mO8btJ-MHLXTm8juxIeH74X6vFL2Hc,11423
58
+ zmq/backend/cffi/utils.py,sha256=xePrYKHy0P7vr3s49t4nxz7vD9zCcfe_ALQ-kL3DZ_U,2086
59
+ zmq/backend/cython/__init__.pxd,sha256=iRgsrNY8-yEX3UL83jFHziSPaVibZx-qltTXcYVUM9Y,60
60
+ zmq/backend/cython/__init__.py,sha256=SMuE8GAtsmEMWNGrv-ZlQZcuTD3EVU838E1ViRHLDNI,322
61
+ zmq/backend/cython/__pycache__/__init__.cpython-310.pyc,,
62
+ zmq/backend/cython/__pycache__/_zmq.cpython-310.pyc,,
63
+ zmq/backend/cython/_externs.pxd,sha256=0EM00v73_7Bp_9Z4qcCuwe0IIgoPgatYgHX9wrjhbJE,339
64
+ zmq/backend/cython/_zmq.cpython-310-x86_64-linux-gnu.so,sha256=4mX9v1xh_eB9tW412sq-ww9GQLOuusIkwGHayS2-5I4,307601
65
+ zmq/backend/cython/_zmq.pxd,sha256=fv1mQ6DxnJghW5XgD45dOnokVVH1UDTV0Us5KYuBo28,2186
66
+ zmq/backend/cython/_zmq.py,sha256=PgojSlJb81xbwcetkdqi0l_d8jVeedxOyLTsGtbcLxk,58306
67
+ zmq/backend/cython/constant_enums.pxi,sha256=LNVbov9C6GBuJvWHnfpqUjmNT0x8alTeub885-o_mI0,7562
68
+ zmq/backend/cython/libzmq.pxd,sha256=ofccd3ZlZvJL7_Ud1gVPHTxl1PDO69UivxliA8QcD-w,4564
69
+ zmq/backend/select.py,sha256=GbXUnUC4fdbrz7GIxraLyXH8A9Mv0_2cFLURezv5yps,902
70
+ zmq/constants.py,sha256=xEyRW8hA1lLjDAnMjOWvmKAFQqZYzaTWO62dA7atnbM,28341
71
+ zmq/decorators.py,sha256=sLeTjxsNcnjKYCsyUsx5RyC0X2Sfqi355nvBDzLDxGY,5099
72
+ zmq/devices/__init__.py,sha256=ODgbZUVGiWBqsNYxKO-E4s3Q8ElZIHtqGhpqgDErDmw,730
73
+ zmq/devices/__pycache__/__init__.cpython-310.pyc,,
74
+ zmq/devices/__pycache__/basedevice.cpython-310.pyc,,
75
+ zmq/devices/__pycache__/monitoredqueue.cpython-310.pyc,,
76
+ zmq/devices/__pycache__/monitoredqueuedevice.cpython-310.pyc,,
77
+ zmq/devices/__pycache__/proxydevice.cpython-310.pyc,,
78
+ zmq/devices/__pycache__/proxysteerabledevice.cpython-310.pyc,,
79
+ zmq/devices/basedevice.py,sha256=dQ8VMBy48wobP6QNM0KlIK9Bslj-BMfQ_xy9_MJxyUQ,9562
80
+ zmq/devices/monitoredqueue.py,sha256=au2EN-fFLXDvVRFClAYS3q2Lb-KxW3keT9l82W5BKRo,1294
81
+ zmq/devices/monitoredqueuedevice.py,sha256=onjY-L74VC_YjppiC4C_voBgbuEtRhstdTaytxQe14I,1929
82
+ zmq/devices/proxydevice.py,sha256=MCB4j-65vyjSLytrzEWfB2q6YZLn_035Sxfns9j4yyQ,2843
83
+ zmq/devices/proxysteerabledevice.py,sha256=atHF4HRd7A_lQQV8q6eHzQ_BaT-Gv6D3EabnN1p67vQ,3206
84
+ zmq/error.py,sha256=-M7z_XG60v8aVawNfLvNgqKP7_9ip37TDDiQqLOu0VU,5307
85
+ zmq/eventloop/__init__.py,sha256=j5PpZdLAwLtwChrGCEZHJYJ6ZJoEzNBMlzY9r5K5iUw,103
86
+ zmq/eventloop/__pycache__/__init__.cpython-310.pyc,,
87
+ zmq/eventloop/__pycache__/_deprecated.cpython-310.pyc,,
88
+ zmq/eventloop/__pycache__/future.cpython-310.pyc,,
89
+ zmq/eventloop/__pycache__/ioloop.cpython-310.pyc,,
90
+ zmq/eventloop/__pycache__/zmqstream.cpython-310.pyc,,
91
+ zmq/eventloop/_deprecated.py,sha256=nTNbRXtCZ9PZXdR3m1YPlMqg01FB85RT4EeT4vNdu1A,6437
92
+ zmq/eventloop/future.py,sha256=lueaaPliVxJkvTaksnmAJkd09XZUfi4o0YnAQiFsciI,2612
93
+ zmq/eventloop/ioloop.py,sha256=pmFSoqjZUy40wbibneTYwyDfVy43a1Ffvzus3pdelU4,766
94
+ zmq/eventloop/zmqstream.py,sha256=YDAkwKgxfcwYEPh3V4DDO4ITJlaCPyQnvlYr_-e_6v4,23417
95
+ zmq/green/__init__.py,sha256=Vmg7Zv4rXt9dUbgy7pGx1a8igWFMqcIWRnRrzZq3Jx4,1367
96
+ zmq/green/__pycache__/__init__.cpython-310.pyc,,
97
+ zmq/green/__pycache__/core.cpython-310.pyc,,
98
+ zmq/green/__pycache__/device.cpython-310.pyc,,
99
+ zmq/green/__pycache__/poll.cpython-310.pyc,,
100
+ zmq/green/core.py,sha256=PsvDz2VEG-UsxfJPU4LocYs9_mja5nvD4jTPNCMD_sw,10808
101
+ zmq/green/device.py,sha256=HTtdyyENo8aOtpklkoDnfSVJKbM5Xh_-KMJZbImZgSQ,978
102
+ zmq/green/eventloop/__init__.py,sha256=N13sRnQlJDo2gD70qPNZP7uc_EEMAjE6hDa-SLhKj0s,68
103
+ zmq/green/eventloop/__pycache__/__init__.cpython-310.pyc,,
104
+ zmq/green/eventloop/__pycache__/ioloop.cpython-310.pyc,,
105
+ zmq/green/eventloop/__pycache__/zmqstream.cpython-310.pyc,,
106
+ zmq/green/eventloop/ioloop.py,sha256=rNJvPZsF-SZpXFEk7T8DXUE5yMFxltF5HE9qZkCmufc,43
107
+ zmq/green/eventloop/zmqstream.py,sha256=3LGGOp9Lx0OxrsiNNxt4jdzNAJvXZNMLdlOYcsrDz8c,291
108
+ zmq/green/poll.py,sha256=77Jpd7h-TJ0ZLE7vm1J7hfJfRCm3BI41cL5CYmUzH1A,2996
109
+ zmq/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
110
+ zmq/log/__main__.py,sha256=FsHekF9qqnfhDkGvl8zVWxUuckLxTqubxMr6GjuCyTA,4005
111
+ zmq/log/__pycache__/__init__.cpython-310.pyc,,
112
+ zmq/log/__pycache__/__main__.cpython-310.pyc,,
113
+ zmq/log/__pycache__/handlers.cpython-310.pyc,,
114
+ zmq/log/handlers.py,sha256=PLdJvzN3J6pg1Z4mied6RxwoKoW6VF8vz1mivTMl74Y,7228
115
+ zmq/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
116
+ zmq/ssh/__init__.py,sha256=2Wcr18a8hS5Qjwhn1p6SYb6NMDIi7Y48JRXg56iU0fI,29
117
+ zmq/ssh/__pycache__/__init__.cpython-310.pyc,,
118
+ zmq/ssh/__pycache__/forward.cpython-310.pyc,,
119
+ zmq/ssh/__pycache__/tunnel.cpython-310.pyc,,
120
+ zmq/ssh/forward.py,sha256=BOPGnDG1ZMR48W0ihgH0_Rw6zPb7X-prdlApCnQbJBQ,3280
121
+ zmq/ssh/tunnel.py,sha256=SCurCVb4WkKFZluqDKQzMkTsmlM0SHRNno5fUNRkrUk,13357
122
+ zmq/sugar/__init__.py,sha256=51CnYi_GR7SlZQq_mP6D29JZpi8cD76SxO-IB7Tjo6I,721
123
+ zmq/sugar/__init__.pyi,sha256=F_JYIucugCUuXik_FSVfzWXICyuH1yDzlshcZRb8bDU,219
124
+ zmq/sugar/__pycache__/__init__.cpython-310.pyc,,
125
+ zmq/sugar/__pycache__/attrsettr.cpython-310.pyc,,
126
+ zmq/sugar/__pycache__/context.cpython-310.pyc,,
127
+ zmq/sugar/__pycache__/frame.cpython-310.pyc,,
128
+ zmq/sugar/__pycache__/poll.cpython-310.pyc,,
129
+ zmq/sugar/__pycache__/socket.cpython-310.pyc,,
130
+ zmq/sugar/__pycache__/stopwatch.cpython-310.pyc,,
131
+ zmq/sugar/__pycache__/tracker.cpython-310.pyc,,
132
+ zmq/sugar/__pycache__/version.cpython-310.pyc,,
133
+ zmq/sugar/attrsettr.py,sha256=LL3MjUFm2TW4VYTsmv1FwEATM3Qw_MGT6s9fB1mBVek,2638
134
+ zmq/sugar/context.py,sha256=ZXC0GPAKIGMTQ0ueMuoeQy2bdS4EofrjyvdJ6Yq5d5c,14644
135
+ zmq/sugar/frame.py,sha256=2WBuRkwy7E1qa8AIQX4AUrcKbTVWbBWDFgj1k6d_y3Q,4257
136
+ zmq/sugar/poll.py,sha256=7qQnUTtQJL8IN5S2VeB0jheoqUKp37pM20yjt4Fv6P4,5752
137
+ zmq/sugar/socket.py,sha256=G4o_UHkVg9d7yFKoQa2Ml9L864kd3-Kd5WlZTT3imIM,34602
138
+ zmq/sugar/stopwatch.py,sha256=i1Cg96aPzsiHmUTAZEgSsiZ5qQJ7rw-pFgiIYJoJU1g,935
139
+ zmq/sugar/tracker.py,sha256=raZKyJc3SYxlY17uAQpIPkHUaNk7bt9cwtdYugLd8QQ,3603
140
+ zmq/sugar/version.py,sha256=W5_Chavc4teho-LozBemsN5XNnILpxTHCXMD7EmfX90,1620
141
+ zmq/tests/__init__.py,sha256=VRi-RCwApzUasI3ruVLmdRDTWF-iRE3lYxsnrDFrN6k,8004
142
+ zmq/tests/__pycache__/__init__.cpython-310.pyc,,
143
+ zmq/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
144
+ zmq/utils/__pycache__/__init__.cpython-310.pyc,,
145
+ zmq/utils/__pycache__/garbage.cpython-310.pyc,,
146
+ zmq/utils/__pycache__/interop.cpython-310.pyc,,
147
+ zmq/utils/__pycache__/jsonapi.cpython-310.pyc,,
148
+ zmq/utils/__pycache__/monitor.cpython-310.pyc,,
149
+ zmq/utils/__pycache__/strtypes.cpython-310.pyc,,
150
+ zmq/utils/__pycache__/win32.cpython-310.pyc,,
151
+ zmq/utils/__pycache__/z85.cpython-310.pyc,,
152
+ zmq/utils/buffers.pxd,sha256=rV7zDQ9ESlMH104whm83r01s8al4_AGFEQkMqiULShg,7031
153
+ zmq/utils/garbage.py,sha256=hfBcYNhJum7TcW4ktHJWa7CoNnDvSRFc4K5IK7IguWY,6124
154
+ zmq/utils/getpid_compat.h,sha256=emvckPfSlYeCoUNgfYTkAWC4ie-LXLRnXDNLlXxXaPI,116
155
+ zmq/utils/interop.py,sha256=l4AsLmDz3UHmuHjwc5EEZ61P_56HGVIVg88Lj4wnjPk,685
156
+ zmq/utils/ipcmaxlen.h,sha256=q-YGX5BECL_QpOzOx3oC_I8mcNCWbJJ6FnUrdKlG1fU,522
157
+ zmq/utils/jsonapi.py,sha256=2G1kMc3EW_Y4jSH_DwZzSti8lxzpRTx02kLrDokVDSA,1025
158
+ zmq/utils/monitor.py,sha256=ritTkUE8qGlWZjUZ3eflKOiI7WOJZFvmKNwG3d3YCzs,3310
159
+ zmq/utils/mutex.h,sha256=tX_0NUDDv9s91JDDFW7UQh2wvqqaKzL9EX7dJUnQfi4,1625
160
+ zmq/utils/pyversion_compat.h,sha256=4FkQ95UVmA_as9lBrIO7-wM5D0tEinVAlYmZls_SRT0,284
161
+ zmq/utils/strtypes.py,sha256=sd0-cJGuDntYAcBMO_uqWAwvsOJGp8WXudMz3nJRUUA,1376
162
+ zmq/utils/win32.py,sha256=aBQFhfZuNXvkHEtiYx5cqCAl3Mkl0qjsRzloIwR2K90,4940
163
+ zmq/utils/z85.py,sha256=AM_l4fxgzA823RETaKj1QR8ci3gto-FoqvRm4qzxDXI,1838
164
+ zmq/utils/zmq_compat.h,sha256=gsqk4EVjdWsatLrhxFAu2QHgUiQemuhqM-ZtVU4FSVE,3184
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/REQUESTED ADDED
File without changes
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 0.10.4
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-manylinux_2_28_x86_64
5
+
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/licenses/LICENSE.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2009-2012, Brian Granger, Min Ragan-Kelley
4
+
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ 3. Neither the name of the copyright holder nor the names of its
18
+ contributors may be used to endorse or promote products derived from
19
+ this software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/licenses/licenses/LICENSE.libsodium.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * ISC License
3
+ *
4
+ * Copyright (c) 2013-2023
5
+ * Frank Denis <j at pureftpd dot org>
6
+ *
7
+ * Permission to use, copy, modify, and/or distribute this software for any
8
+ * purpose with or without fee is hereby granted, provided that the above
9
+ * copyright notice and this permission notice appear in all copies.
10
+ *
11
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
+ */
minigpt2/lib/python3.10/site-packages/pyzmq-26.2.0.dist-info/licenses/licenses/LICENSE.zeromq.txt ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Mozilla Public License Version 2.0
2
+ ==================================
3
+
4
+ 1. Definitions
5
+ --------------
6
+
7
+ 1.1. "Contributor"
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
+
11
+ 1.2. "Contributor Version"
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
+
15
+ 1.3. "Contribution"
16
+ means Covered Software of a particular Contributor.
17
+
18
+ 1.4. "Covered Software"
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
+
24
+ 1.5. "Incompatible With Secondary Licenses"
25
+ means
26
+
27
+ (a) that the initial Contributor has attached the notice described
28
+ in Exhibit B to the Covered Software; or
29
+
30
+ (b) that the Covered Software was made available under the terms of
31
+ version 1.1 or earlier of the License, but not also under the
32
+ terms of a Secondary License.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+
52
+ (a) any file in Source Code Form that results from an addition to,
53
+ deletion from, or modification of the contents of Covered
54
+ Software; or
55
+
56
+ (b) any new file in Source Code Form that contains any Covered
57
+ Software.
58
+
59
+ 1.11. "Patent Claims" of a Contributor
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
+
67
+ 1.12. "Secondary License"
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
+
73
+ 1.13. "Source Code Form"
74
+ means the form of the work preferred for making modifications.
75
+
76
+ 1.14. "You" (or "Your")
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
+
86
+ 2. License Grants and Conditions
87
+ --------------------------------
88
+
89
+ 2.1. Grants
90
+
91
+ Each Contributor hereby grants You a world-wide, royalty-free,
92
+ non-exclusive license:
93
+
94
+ (a) under intellectual property rights (other than patent or trademark)
95
+ Licensable by such Contributor to use, reproduce, make available,
96
+ modify, display, perform, distribute, and otherwise exploit its
97
+ Contributions, either on an unmodified basis, with Modifications, or
98
+ as part of a Larger Work; and
99
+
100
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
101
+ for sale, have made, import, and otherwise transfer either its
102
+ Contributions or its Contributor Version.
103
+
104
+ 2.2. Effective Date
105
+
106
+ The licenses granted in Section 2.1 with respect to any Contribution
107
+ become effective for each Contribution on the date the Contributor first
108
+ distributes such Contribution.
109
+
110
+ 2.3. Limitations on Grant Scope
111
+
112
+ The licenses granted in this Section 2 are the only rights granted under
113
+ this License. No additional rights or licenses will be implied from the
114
+ distribution or licensing of Covered Software under this License.
115
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
+ Contributor:
117
+
118
+ (a) for any code that a Contributor has removed from Covered Software;
119
+ or
120
+
121
+ (b) for infringements caused by: (i) Your and any other third party's
122
+ modifications of Covered Software, or (ii) the combination of its
123
+ Contributions with other software (except as part of its Contributor
124
+ Version); or
125
+
126
+ (c) under Patent Claims infringed by Covered Software in the absence of
127
+ its Contributions.
128
+
129
+ This License does not grant any rights in the trademarks, service marks,
130
+ or logos of any Contributor (except as may be necessary to comply with
131
+ the notice requirements in Section 3.4).
132
+
133
+ 2.4. Subsequent Licenses
134
+
135
+ No Contributor makes additional grants as a result of Your choice to
136
+ distribute the Covered Software under a subsequent version of this
137
+ License (see Section 10.2) or under the terms of a Secondary License (if
138
+ permitted under the terms of Section 3.3).
139
+
140
+ 2.5. Representation
141
+
142
+ Each Contributor represents that the Contributor believes its
143
+ Contributions are its original creation(s) or it has sufficient rights
144
+ to grant the rights to its Contributions conveyed by this License.
145
+
146
+ 2.6. Fair Use
147
+
148
+ This License is not intended to limit any rights You have under
149
+ applicable copyright doctrines of fair use, fair dealing, or other
150
+ equivalents.
151
+
152
+ 2.7. Conditions
153
+
154
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
+ in Section 2.1.
156
+
157
+ 3. Responsibilities
158
+ -------------------
159
+
160
+ 3.1. Distribution of Source Form
161
+
162
+ All distribution of Covered Software in Source Code Form, including any
163
+ Modifications that You create or to which You contribute, must be under
164
+ the terms of this License. You must inform recipients that the Source
165
+ Code Form of the Covered Software is governed by the terms of this
166
+ License, and how they can obtain a copy of this License. You may not
167
+ attempt to alter or restrict the recipients' rights in the Source Code
168
+ Form.
169
+
170
+ 3.2. Distribution of Executable Form
171
+
172
+ If You distribute Covered Software in Executable Form then:
173
+
174
+ (a) such Covered Software must also be made available in Source Code
175
+ Form, as described in Section 3.1, and You must inform recipients of
176
+ the Executable Form how they can obtain a copy of such Source Code
177
+ Form by reasonable means in a timely manner, at a charge no more
178
+ than the cost of distribution to the recipient; and
179
+
180
+ (b) You may distribute such Executable Form under the terms of this
181
+ License, or sublicense it under different terms, provided that the
182
+ license for the Executable Form does not attempt to limit or alter
183
+ the recipients' rights in the Source Code Form under this License.
184
+
185
+ 3.3. Distribution of a Larger Work
186
+
187
+ You may create and distribute a Larger Work under terms of Your choice,
188
+ provided that You also comply with the requirements of this License for
189
+ the Covered Software. If the Larger Work is a combination of Covered
190
+ Software with a work governed by one or more Secondary Licenses, and the
191
+ Covered Software is not Incompatible With Secondary Licenses, this
192
+ License permits You to additionally distribute such Covered Software
193
+ under the terms of such Secondary License(s), so that the recipient of
194
+ the Larger Work may, at their option, further distribute the Covered
195
+ Software under the terms of either this License or such Secondary
196
+ License(s).
197
+
198
+ 3.4. Notices
199
+
200
+ You may not remove or alter the substance of any license notices
201
+ (including copyright notices, patent notices, disclaimers of warranty,
202
+ or limitations of liability) contained within the Source Code Form of
203
+ the Covered Software, except that You may alter any license notices to
204
+ the extent required to remedy known factual inaccuracies.
205
+
206
+ 3.5. Application of Additional Terms
207
+
208
+ You may choose to offer, and to charge a fee for, warranty, support,
209
+ indemnity or liability obligations to one or more recipients of Covered
210
+ Software. However, You may do so only on Your own behalf, and not on
211
+ behalf of any Contributor. You must make it absolutely clear that any
212
+ such warranty, support, indemnity, or liability obligation is offered by
213
+ You alone, and You hereby agree to indemnify every Contributor for any
214
+ liability incurred by such Contributor as a result of warranty, support,
215
+ indemnity or liability terms You offer. You may include additional
216
+ disclaimers of warranty and limitations of liability specific to any
217
+ jurisdiction.
218
+
219
+ 4. Inability to Comply Due to Statute or Regulation
220
+ ---------------------------------------------------
221
+
222
+ If it is impossible for You to comply with any of the terms of this
223
+ License with respect to some or all of the Covered Software due to
224
+ statute, judicial order, or regulation then You must: (a) comply with
225
+ the terms of this License to the maximum extent possible; and (b)
226
+ describe the limitations and the code they affect. Such description must
227
+ be placed in a text file included with all distributions of the Covered
228
+ Software under this License. Except to the extent prohibited by statute
229
+ or regulation, such description must be sufficiently detailed for a
230
+ recipient of ordinary skill to be able to understand it.
231
+
232
+ 5. Termination
233
+ --------------
234
+
235
+ 5.1. The rights granted under this License will terminate automatically
236
+ if You fail to comply with any of its terms. However, if You become
237
+ compliant, then the rights granted under this License from a particular
238
+ Contributor are reinstated (a) provisionally, unless and until such
239
+ Contributor explicitly and finally terminates Your grants, and (b) on an
240
+ ongoing basis, if such Contributor fails to notify You of the
241
+ non-compliance by some reasonable means prior to 60 days after You have
242
+ come back into compliance. Moreover, Your grants from a particular
243
+ Contributor are reinstated on an ongoing basis if such Contributor
244
+ notifies You of the non-compliance by some reasonable means, this is the
245
+ first time You have received notice of non-compliance with this License
246
+ from such Contributor, and You become compliant prior to 30 days after
247
+ Your receipt of the notice.
248
+
249
+ 5.2. If You initiate litigation against any entity by asserting a patent
250
+ infringement claim (excluding declaratory judgment actions,
251
+ counter-claims, and cross-claims) alleging that a Contributor Version
252
+ directly or indirectly infringes any patent, then the rights granted to
253
+ You by any and all Contributors for the Covered Software under Section
254
+ 2.1 of this License shall terminate.
255
+
256
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257
+ end user license agreements (excluding distributors and resellers) which
258
+ have been validly granted by You or Your distributors under this License
259
+ prior to termination shall survive termination.
260
+
261
+ ************************************************************************
262
+ * *
263
+ * 6. Disclaimer of Warranty *
264
+ * ------------------------- *
265
+ * *
266
+ * Covered Software is provided under this License on an "as is" *
267
+ * basis, without warranty of any kind, either expressed, implied, or *
268
+ * statutory, including, without limitation, warranties that the *
269
+ * Covered Software is free of defects, merchantable, fit for a *
270
+ * particular purpose or non-infringing. The entire risk as to the *
271
+ * quality and performance of the Covered Software is with You. *
272
+ * Should any Covered Software prove defective in any respect, You *
273
+ * (not any Contributor) assume the cost of any necessary servicing, *
274
+ * repair, or correction. This disclaimer of warranty constitutes an *
275
+ * essential part of this License. No use of any Covered Software is *
276
+ * authorized under this License except under this disclaimer. *
277
+ * *
278
+ ************************************************************************
279
+
280
+ ************************************************************************
281
+ * *
282
+ * 7. Limitation of Liability *
283
+ * -------------------------- *
284
+ * *
285
+ * Under no circumstances and under no legal theory, whether tort *
286
+ * (including negligence), contract, or otherwise, shall any *
287
+ * Contributor, or anyone who distributes Covered Software as *
288
+ * permitted above, be liable to You for any direct, indirect, *
289
+ * special, incidental, or consequential damages of any character *
290
+ * including, without limitation, damages for lost profits, loss of *
291
+ * goodwill, work stoppage, computer failure or malfunction, or any *
292
+ * and all other commercial damages or losses, even if such party *
293
+ * shall have been informed of the possibility of such damages. This *
294
+ * limitation of liability shall not apply to liability for death or *
295
+ * personal injury resulting from such party's negligence to the *
296
+ * extent applicable law prohibits such limitation. Some *
297
+ * jurisdictions do not allow the exclusion or limitation of *
298
+ * incidental or consequential damages, so this exclusion and *
299
+ * limitation may not apply to You. *
300
+ * *
301
+ ************************************************************************
302
+
303
+ 8. Litigation
304
+ -------------
305
+
306
+ Any litigation relating to this License may be brought only in the
307
+ courts of a jurisdiction where the defendant maintains its principal
308
+ place of business and such litigation shall be governed by laws of that
309
+ jurisdiction, without reference to its conflict-of-law provisions.
310
+ Nothing in this Section shall prevent a party's ability to bring
311
+ cross-claims or counter-claims.
312
+
313
+ 9. Miscellaneous
314
+ ----------------
315
+
316
+ This License represents the complete agreement concerning the subject
317
+ matter hereof. If any provision of this License is held to be
318
+ unenforceable, such provision shall be reformed only to the extent
319
+ necessary to make it enforceable. Any law or regulation which provides
320
+ that the language of a contract shall be construed against the drafter
321
+ shall not be used to construe this License against a Contributor.
322
+
323
+ 10. Versions of the License
324
+ ---------------------------
325
+
326
+ 10.1. New Versions
327
+
328
+ Mozilla Foundation is the license steward. Except as provided in Section
329
+ 10.3, no one other than the license steward has the right to modify or
330
+ publish new versions of this License. Each version will be given a
331
+ distinguishing version number.
332
+
333
+ 10.2. Effect of New Versions
334
+
335
+ You may distribute the Covered Software under the terms of the version
336
+ of the License under which You originally received the Covered Software,
337
+ or under the terms of any subsequent version published by the license
338
+ steward.
339
+
340
+ 10.3. Modified Versions
341
+
342
+ If you create software not governed by this License, and you want to
343
+ create a new license for such software, you may create and use a
344
+ modified version of this License if you rename the license and remove
345
+ any references to the name of the license steward (except to note that
346
+ such modified license differs from this License).
347
+
348
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
349
+ Licenses
350
+
351
+ If You choose to distribute Source Code Form that is Incompatible With
352
+ Secondary Licenses under the terms of this version of the License, the
353
+ notice described in Exhibit B of this License must be attached.
354
+
355
+ Exhibit A - Source Code Form License Notice
356
+ -------------------------------------------
357
+
358
+ This Source Code Form is subject to the terms of the Mozilla Public
359
+ License, v. 2.0. If a copy of the MPL was not distributed with this
360
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
361
+
362
+ If it is not possible or desirable to put the notice in a particular
363
+ file, then You may include the notice in a location (such as a LICENSE
364
+ file in a relevant directory) where a recipient would be likely to look
365
+ for such a notice.
366
+
367
+ You may add additional accurate notices of copyright ownership.
368
+
369
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
+ ---------------------------------------------------------
371
+
372
+ This Source Code Form is "Incompatible With Secondary Licenses", as
373
+ defined by the Mozilla Public License, v. 2.0.
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2022 OpenAI, Shantanu Jain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/METADATA ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: tiktoken
3
+ Version: 0.7.0
4
+ Summary: tiktoken is a fast BPE tokeniser for use with OpenAI's models
5
+ Author: Shantanu Jain
6
+ Author-email: shantanu@openai.com
7
+ License: MIT License
8
+
9
+ Copyright (c) 2022 OpenAI, Shantanu Jain
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Project-URL: homepage, https://github.com/openai/tiktoken
30
+ Project-URL: repository, https://github.com/openai/tiktoken
31
+ Project-URL: changelog, https://github.com/openai/tiktoken/blob/main/CHANGELOG.md
32
+ Requires-Python: >=3.8
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: regex >=2022.1.18
36
+ Requires-Dist: requests >=2.26.0
37
+ Provides-Extra: blobfile
38
+ Requires-Dist: blobfile >=2 ; extra == 'blobfile'
39
+
40
+ # ⏳ tiktoken
41
+
42
+ tiktoken is a fast [BPE](https://en.wikipedia.org/wiki/Byte_pair_encoding) tokeniser for use with
43
+ OpenAI's models.
44
+
45
+ ```python
46
+ import tiktoken
47
+ enc = tiktoken.get_encoding("cl100k_base")
48
+ assert enc.decode(enc.encode("hello world")) == "hello world"
49
+
50
+ # To get the tokeniser corresponding to a specific model in the OpenAI API:
51
+ enc = tiktoken.encoding_for_model("gpt-4")
52
+ ```
53
+
54
+ The open source version of `tiktoken` can be installed from PyPI:
55
+ ```
56
+ pip install tiktoken
57
+ ```
58
+
59
+ The tokeniser API is documented in `tiktoken/core.py`.
60
+
61
+ Example code using `tiktoken` can be found in the
62
+ [OpenAI Cookbook](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb).
63
+
64
+
65
+ ## Performance
66
+
67
+ `tiktoken` is between 3-6x faster than a comparable open source tokeniser:
68
+
69
+ ![image](https://raw.githubusercontent.com/openai/tiktoken/main/perf.svg)
70
+
71
+ Performance measured on 1GB of text using the GPT-2 tokeniser, using `GPT2TokenizerFast` from
72
+ `tokenizers==0.13.2`, `transformers==4.24.0` and `tiktoken==0.2.0`.
73
+
74
+
75
+ ## Getting help
76
+
77
+ Please post questions in the [issue tracker](https://github.com/openai/tiktoken/issues).
78
+
79
+ If you work at OpenAI, make sure to check the internal documentation or feel free to contact
80
+ @shantanu.
81
+
82
+ ## What is BPE anyway?
83
+
84
+ Language models don't see text like you and I, instead they see a sequence of numbers (known as tokens).
85
+ Byte pair encoding (BPE) is a way of converting text into tokens. It has a couple desirable
86
+ properties:
87
+ 1) It's reversible and lossless, so you can convert tokens back into the original text
88
+ 2) It works on arbitrary text, even text that is not in the tokeniser's training data
89
+ 3) It compresses the text: the token sequence is shorter than the bytes corresponding to the
90
+ original text. On average, in practice, each token corresponds to about 4 bytes.
91
+ 4) It attempts to let the model see common subwords. For instance, "ing" is a common subword in
92
+ English, so BPE encodings will often split "encoding" into tokens like "encod" and "ing"
93
+ (instead of e.g. "enc" and "oding"). Because the model will then see the "ing" token again and
94
+ again in different contexts, it helps models generalise and better understand grammar.
95
+
96
+ `tiktoken` contains an educational submodule that is friendlier if you want to learn more about
97
+ the details of BPE, including code that helps visualise the BPE procedure:
98
+ ```python
99
+ from tiktoken._educational import *
100
+
101
+ # Train a BPE tokeniser on a small amount of text
102
+ enc = train_simple_encoding()
103
+
104
+ # Visualise how the GPT-4 encoder encodes text
105
+ enc = SimpleBytePairEncoding.from_tiktoken("cl100k_base")
106
+ enc.encode("hello world aaaaaaaaaaaa")
107
+ ```
108
+
109
+
110
+ ## Extending tiktoken
111
+
112
+ You may wish to extend `tiktoken` to support new encodings. There are two ways to do this.
113
+
114
+
115
+ **Create your `Encoding` object exactly the way you want and simply pass it around.**
116
+
117
+ ```python
118
+ cl100k_base = tiktoken.get_encoding("cl100k_base")
119
+
120
+ # In production, load the arguments directly instead of accessing private attributes
121
+ # See openai_public.py for examples of arguments for specific encodings
122
+ enc = tiktoken.Encoding(
123
+ # If you're changing the set of special tokens, make sure to use a different name
124
+ # It should be clear from the name what behaviour to expect.
125
+ name="cl100k_im",
126
+ pat_str=cl100k_base._pat_str,
127
+ mergeable_ranks=cl100k_base._mergeable_ranks,
128
+ special_tokens={
129
+ **cl100k_base._special_tokens,
130
+ "<|im_start|>": 100264,
131
+ "<|im_end|>": 100265,
132
+ }
133
+ )
134
+ ```
135
+
136
+ **Use the `tiktoken_ext` plugin mechanism to register your `Encoding` objects with `tiktoken`.**
137
+
138
+ This is only useful if you need `tiktoken.get_encoding` to find your encoding, otherwise prefer
139
+ option 1.
140
+
141
+ To do this, you'll need to create a namespace package under `tiktoken_ext`.
142
+
143
+ Layout your project like this, making sure to omit the `tiktoken_ext/__init__.py` file:
144
+ ```
145
+ my_tiktoken_extension
146
+ ├── tiktoken_ext
147
+ │   └── my_encodings.py
148
+ └── setup.py
149
+ ```
150
+
151
+ `my_encodings.py` should be a module that contains a variable named `ENCODING_CONSTRUCTORS`.
152
+ This is a dictionary from an encoding name to a function that takes no arguments and returns
153
+ arguments that can be passed to `tiktoken.Encoding` to construct that encoding. For an example, see
154
+ `tiktoken_ext/openai_public.py`. For precise details, see `tiktoken/registry.py`.
155
+
156
+ Your `setup.py` should look something like this:
157
+ ```python
158
+ from setuptools import setup, find_namespace_packages
159
+
160
+ setup(
161
+ name="my_tiktoken_extension",
162
+ packages=find_namespace_packages(include=['tiktoken_ext*']),
163
+ install_requires=["tiktoken"],
164
+ ...
165
+ )
166
+ ```
167
+
168
+ Then simply `pip install ./my_tiktoken_extension` and you should be able to use your
169
+ custom encodings! Make sure **not** to use an editable install.
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/RECORD ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tiktoken-0.7.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ tiktoken-0.7.0.dist-info/LICENSE,sha256=QYy0mbQ2Eo1lPXmUEzOlQ3t74uqSE9zC8E0V1dLFHYY,1078
3
+ tiktoken-0.7.0.dist-info/METADATA,sha256=06FiLYxR04FjaYa53wsIdDvuJtP_FBaU0d4DnUcRpYg,6631
4
+ tiktoken-0.7.0.dist-info/RECORD,,
5
+ tiktoken-0.7.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ tiktoken-0.7.0.dist-info/WHEEL,sha256=CzQQWV-lNyM92gr3iaBk8dvO35YDHRxgzkZ-dxumUIM,152
7
+ tiktoken-0.7.0.dist-info/top_level.txt,sha256=54G5MceQnuD7EXvp7jzGxDDapA1iOwsh77jhCN9WKkc,22
8
+ tiktoken/__init__.py,sha256=FNmz8KgZfaG62vRgMMkTL9jj0a2AI7JGV1b-RZ29_tY,322
9
+ tiktoken/__pycache__/__init__.cpython-310.pyc,,
10
+ tiktoken/__pycache__/_educational.cpython-310.pyc,,
11
+ tiktoken/__pycache__/core.cpython-310.pyc,,
12
+ tiktoken/__pycache__/load.cpython-310.pyc,,
13
+ tiktoken/__pycache__/model.cpython-310.pyc,,
14
+ tiktoken/__pycache__/registry.cpython-310.pyc,,
15
+ tiktoken/_educational.py,sha256=l_bTeohxYJ2RHrXDFT2QfRF7aD89S38VFZndzZTI_cM,8234
16
+ tiktoken/_tiktoken.cpython-310-x86_64-linux-gnu.so,sha256=M4aPWFqCCHSS2T98pmHsQM_5DFEU5ePuFAl9GMHobpo,3202496
17
+ tiktoken/core.py,sha256=MlhBCfE5WLR1i8rokHqYz7u4GdTF_dfpnSuOwmtHj2A,16123
18
+ tiktoken/load.py,sha256=YDbOfHhKn1MEWn9cWc1cVqDxZNwpGifWnuvfEcKeJ4w,5351
19
+ tiktoken/model.py,sha256=fCcuegWlKwFFmD1crVXHxFQBlBV6BGWCfwYTIhUcADs,3647
20
+ tiktoken/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ tiktoken/registry.py,sha256=ksP_k8jlqLyefL1sr5OAc-yOK0McOFaHZM4oF8KQdYg,2811
22
+ tiktoken_ext/__pycache__/openai_public.cpython-310.pyc,,
23
+ tiktoken_ext/openai_public.py,sha256=3gckU-7LqtjkwKbVp5M6ZktECFdr7Tw5Ii8aDiFQKto,4634
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/REQUESTED ADDED
File without changes
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/WHEEL ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-manylinux_2_17_x86_64
5
+ Tag: cp310-cp310-manylinux2014_x86_64
6
+
minigpt2/lib/python3.10/site-packages/tiktoken-0.7.0.dist-info/top_level.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tiktoken
2
+ tiktoken_ext
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_convert_weight_to_int4pack_cpu_dispatch.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace cpu {
19
+
20
+ TORCH_API at::Tensor _convert_weight_to_int4pack(const at::Tensor & self, int64_t innerKTiles);
21
+
22
+ } // namespace cpu
23
+ } // namespace at
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_efficient_attention_backward_native.h ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from NativeFunction.h
4
+
5
+ #include <c10/core/Scalar.h>
6
+ #include <c10/core/Storage.h>
7
+ #include <c10/core/TensorOptions.h>
8
+ #include <c10/util/Deprecated.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/core/QScheme.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <tuple>
14
+ #include <vector>
15
+
16
+
17
+ namespace at {
18
+ namespace native {
19
+ TORCH_API ::std::tuple<at::Tensor,at::Tensor,at::Tensor,at::Tensor> _efficient_attention_backward(const at::Tensor & grad_out_, const at::Tensor & query, const at::Tensor & key, const at::Tensor & value, const ::std::optional<at::Tensor> & bias, const at::Tensor & out, const ::std::optional<at::Tensor> & cu_seqlens_q, const ::std::optional<at::Tensor> & cu_seqlens_k, int64_t max_seqlen_q, int64_t max_seqlen_k, const at::Tensor & logsumexp, double dropout_p, const at::Tensor & philox_seed, const at::Tensor & philox_offset, int64_t custom_mask_type, bool bias_requires_grad, ::std::optional<double> scale=::std::nullopt, ::std::optional<int64_t> num_splits_key=::std::nullopt, ::std::optional<int64_t> window_size=::std::nullopt, bool shared_storage_dqdkdv=false);
20
+ } // namespace native
21
+ } // namespace at
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_fft_c2c_native.h ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from NativeFunction.h
4
+
5
+ #include <c10/core/Scalar.h>
6
+ #include <c10/core/Storage.h>
7
+ #include <c10/core/TensorOptions.h>
8
+ #include <c10/util/Deprecated.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/core/QScheme.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <tuple>
14
+ #include <vector>
15
+
16
+
17
+ namespace at {
18
+ namespace native {
19
+ TORCH_API at::Tensor _fft_c2c_mkl(const at::Tensor & self, at::IntArrayRef dim, int64_t normalization, bool forward);
20
+ TORCH_API at::Tensor & _fft_c2c_mkl_out(const at::Tensor & self, at::IntArrayRef dim, int64_t normalization, bool forward, at::Tensor & out);
21
+ TORCH_API at::Tensor _fft_c2c_cufft(const at::Tensor & self, at::IntArrayRef dim, int64_t normalization, bool forward);
22
+ TORCH_API at::Tensor & _fft_c2c_cufft_out(const at::Tensor & self, at::IntArrayRef dim, int64_t normalization, bool forward, at::Tensor & out);
23
+ } // namespace native
24
+ } // namespace at
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_fill_mem_eff_dropout_mask_meta_dispatch.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace meta {
19
+
20
+ TORCH_API at::Tensor & _fill_mem_eff_dropout_mask_(at::Tensor & self, double dropout_p, int64_t seed, int64_t offset);
21
+
22
+ } // namespace meta
23
+ } // namespace at
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_pin_memory_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace compositeexplicitautograd {
19
+
20
+ TORCH_API at::Tensor & _pin_memory_out(at::Tensor & out, const at::Tensor & self, ::std::optional<at::Device> device=::std::nullopt);
21
+ TORCH_API at::Tensor & _pin_memory_outf(const at::Tensor & self, ::std::optional<at::Device> device, at::Tensor & out);
22
+
23
+ } // namespace compositeexplicitautograd
24
+ } // namespace at
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_sobol_engine_scramble_ops.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from Operator.h
4
+
5
+ #include <tuple>
6
+ #include <vector>
7
+
8
+ // Forward declarations of any types needed in the operator signatures.
9
+ // We can't directly include these classes because it will cause circular include dependencies.
10
+ // This file is included by TensorBody.h, which defines the Tensor class.
11
+ #include <ATen/core/ATen_fwd.h>
12
+
13
+ namespace at {
14
+ namespace _ops {
15
+
16
+
17
+ struct TORCH_API _sobol_engine_scramble_ {
18
+ using schema = at::Tensor & (at::Tensor &, const at::Tensor &, int64_t);
19
+ using ptr_schema = schema*;
20
+ // See Note [static constexpr char* members for windows NVCC]
21
+ STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_sobol_engine_scramble_")
22
+ STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
23
+ STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_sobol_engine_scramble_(Tensor(a!) self, Tensor ltm, int dimension) -> Tensor(a!)")
24
+ static at::Tensor & call(at::Tensor & self, const at::Tensor & ltm, int64_t dimension);
25
+ static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const at::Tensor & ltm, int64_t dimension);
26
+ };
27
+
28
+ }} // namespace at::_ops
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_softmax_backward_data_meta_dispatch.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace meta {
19
+
20
+ TORCH_API at::Tensor _softmax_backward_data(const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, at::ScalarType input_dtype);
21
+ TORCH_API at::Tensor & _softmax_backward_data_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, at::ScalarType input_dtype);
22
+ TORCH_API at::Tensor & _softmax_backward_data_outf(const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, at::ScalarType input_dtype, at::Tensor & grad_input);
23
+
24
+ } // namespace meta
25
+ } // namespace at
parrot/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_semi_structured_apply_dense_native.h ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from NativeFunction.h
4
+
5
+ #include <c10/core/Scalar.h>
6
+ #include <c10/core/Storage.h>
7
+ #include <c10/core/TensorOptions.h>
8
+ #include <c10/util/Deprecated.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/core/QScheme.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <tuple>
14
+ #include <vector>
15
+
16
+
17
+ namespace at {
18
+ namespace native {
19
+ TORCH_API at::Tensor _sparse_semi_structured_apply_dense(const at::Tensor & input, const at::Tensor & thread_masks);
20
+ } // namespace native
21
+ } // namespace at