chromatic-python 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,421 @@
1
+ __all__ = [
2
+ 'CSI',
3
+ 'Color',
4
+ 'ColorStr',
5
+ 'SgrParameter',
6
+ 'SgrSequence',
7
+ 'ansicolor24Bit',
8
+ 'ansicolor4Bit',
9
+ 'ansicolor8Bit',
10
+ 'colorbytes',
11
+ 'get_ansi_type',
12
+ 'hsl_gradient',
13
+ 'randcolor',
14
+ 'rgb2ansi_color_esc',
15
+ 'rgb_luma_transform',
16
+ 'SGR_RESET',
17
+ 'DEFAULT_ANSI',
18
+ ]
19
+
20
+ from collections.abc import Buffer, Callable, Iterable, Iterator, Mapping, Sequence
21
+ from enum import IntEnum
22
+ from types import MappingProxyType
23
+ from typing import (
24
+ Final, Literal, overload, Self, SupportsIndex, SupportsInt, TypedDict, TypeVar,
25
+ Union, Unpack
26
+ )
27
+
28
+ from chromatic._typing import (
29
+ Ansi24BitAlias, Ansi4BitAlias, Ansi8BitAlias, AnsiColorAlias, ColorDictKeys, Float3Tuple,
30
+ Int3Tuple, RGBVectorLike, TupleOf3
31
+ )
32
+
33
+ AnsiColorFormat = ansicolor4Bit | ansicolor8Bit | ansicolor24Bit
34
+ AnsiColorParam = AnsiColorAlias | AnsiColorType
35
+ AnsiColorType = type[AnsiColorFormat]
36
+
37
+ type _CSpecDict = Mapping[ColorDictKeys, _CSpecScalar]
38
+ type _CSpecKVPair = tuple[ColorDictKeys, _CSpecScalar]
39
+ type _CSpecScalar = Union[int, Color, RGBVectorLike]
40
+ type _CSpecTuplePair = Union[tuple[_CSpecScalar, _CSpecScalar], tuple[_CSpecKVPair, _CSpecKVPair]]
41
+ type _CSpecType = Union[
42
+ SgrSequence, str, bytes, _CSpecScalar, _CSpecTuplePair, _CSpecKVPair, _CSpecDict]
43
+ type _RgbCoercible = Union[Color, SupportsInt]
44
+ type _RgbMapping[_KT: Union[ColorDictKeys, str], _VT: _RgbCoercible] = Mapping[_KT, _VT]
45
+
46
+
47
+ @overload
48
+ def get_ansi_type[_T: AnsiColorType](typ: _T) -> _T: ...
49
+
50
+
51
+ @overload
52
+ def get_ansi_type(typ: Ansi4BitAlias) -> type[ansicolor4Bit]: ...
53
+
54
+
55
+ @overload
56
+ def get_ansi_type(typ: Ansi8BitAlias) -> type[ansicolor8Bit]: ...
57
+
58
+
59
+ @overload
60
+ def get_ansi_type(typ: Ansi24BitAlias) -> type[ansicolor24Bit]: ...
61
+
62
+
63
+ def get_term_ansi_default() -> type[ansicolor8Bit | ansicolor4Bit]: ...
64
+
65
+
66
+ def hsl_gradient(start: Int3Tuple | Float3Tuple,
67
+ stop: Int3Tuple | Float3Tuple,
68
+ step: SupportsIndex,
69
+ num: SupportsIndex = None,
70
+ ncycles: int | float = float('inf'),
71
+ replace_idx: tuple[
72
+ SupportsIndex | Iterable[SupportsIndex], Iterator[Color]] = None,
73
+ dtype: type[Color] | Callable[[Int3Tuple], int] = Color): ...
74
+
75
+
76
+ def randcolor() -> Color: ...
77
+
78
+
79
+ def rgb2ansi_color_esc(ret_format: AnsiColorAlias | AnsiColorType,
80
+ mode: ColorDictKeys,
81
+ rgb: Int3Tuple) -> bytes: ...
82
+
83
+
84
+ def rgb_luma_transform(rgb: Int3Tuple,
85
+ start: SupportsIndex = None,
86
+ num: SupportsIndex = 50,
87
+ step: SupportsIndex = 1,
88
+ cycle: bool | Literal['wave'] = False,
89
+ ncycles: int | float = float('inf'),
90
+ gradient: Int3Tuple = None,
91
+ dtype: type[Color] = None) -> Iterator[Int3Tuple | int | Color]: ...
92
+
93
+
94
+ class ansicolor24Bit(colorbytes):
95
+ pass
96
+
97
+
98
+ class ansicolor4Bit(colorbytes):
99
+ pass
100
+
101
+
102
+ class ansicolor8Bit(colorbytes):
103
+ pass
104
+
105
+
106
+ class Color(int):
107
+
108
+ @classmethod
109
+ def from_rgb(cls, rgb: _RGBVectorLike) -> Self: ...
110
+
111
+ def __invert__(self) -> Color: ...
112
+
113
+ def __new__(cls, __x: _RgbCoercible) -> Color: ...
114
+
115
+ @property
116
+ def rgb(self) -> Int3Tuple: ...
117
+
118
+
119
+ class colorbytes(bytes):
120
+
121
+ @classmethod
122
+ def from_rgb(cls, __rgb: Union[_RgbMapping, _AnsiColor_co]) -> Self: ...
123
+
124
+ def __new__(cls, __ansi: Union[bytes, _AnsiColor_co]) -> AnsiColorFormat: ...
125
+
126
+ _rgb_dict_: dict[ColorDictKeys, Int3Tuple]
127
+
128
+ @property
129
+ def rgb_dict(self) -> MappingProxyType[ColorDictKeys, Int3Tuple]: ...
130
+
131
+
132
+ class ColorStr(str):
133
+
134
+ def _weak_var_update(self, **kwargs: Unpack[_ColorStrWeakVars]) -> ColorStr: ...
135
+
136
+ def ansi_partition(self) -> TupleOf3[str]: ...
137
+
138
+ def as_ansi_type(self, __ansi_type: AnsiColorParam) -> ColorStr: ...
139
+
140
+ def format(self, *args, **kwargs) -> ColorStr: ...
141
+
142
+ def recolor(self,
143
+ __value: ColorStr = None,
144
+ absolute: bool = False,
145
+ **kwargs: Unpack[_ColorDict]) -> ColorStr: ...
146
+
147
+ def replace(self, __old: str, __new: str, __count: SupportsIndex = -1) -> ColorStr: ...
148
+
149
+ def split(self, sep=None, maxsplit=-1) -> list[ColorStr]: ...
150
+
151
+ def update_sgr(self, *p: *tuple[Union[int, SgrParameter], ...]) -> ColorStr: ...
152
+
153
+ def __add__[_T: (str, ColorStr, SgrParameter)](self, other: _T) -> ColorStr: ...
154
+
155
+ def __and__(self, other: ColorStr) -> Union[ColorStr, Self]: ...
156
+
157
+ def __eq__(self, other) -> bool: ...
158
+
159
+ def __format__(self, format_spec: str = '') -> str: ...
160
+
161
+ def __getitem__(self, __key: Union[SupportsIndex, slice]) -> str: ...
162
+
163
+ def __hash__(self) -> int: ...
164
+
165
+ def __init__(self,
166
+ obj: object = None,
167
+ color_spec: Union[_ColorSpec, ColorStr] = None,
168
+ **kwargs: Unpack[_ColorStrKwargs]) -> None: ...
169
+
170
+ def __iter__(self) -> Iterator[ColorStr]: ...
171
+
172
+ def __len__(self) -> int: ...
173
+
174
+ def __matmul__(self, other: ColorStr) -> ColorStr: ...
175
+
176
+ def __mod__(self, __value) -> ColorStr: ...
177
+
178
+ def __mul__(self, __value: SupportsIndex) -> ColorStr: ...
179
+
180
+ def __invert__(self) -> ColorStr: ...
181
+
182
+ def __new__(cls,
183
+ obj: object = None,
184
+ color_spec: Union[_ColorSpec, ColorStr] = None,
185
+ **kwargs: Unpack[_ColorStrKwargs]) -> ColorStr: ...
186
+
187
+ def __sub__(self, other: Union[Color, ColorStr]) -> ColorStr: ...
188
+
189
+ _ansi_: bytes
190
+ _ansi_type_: type[AnsiColorFormat]
191
+ _base_str_: str
192
+ _color_dict_: MappingProxyType[ColorDictKeys, Color]
193
+ _no_reset_: bool
194
+ _sgr_: SgrSequence
195
+ _sgr_params_: list[SgrParamWrapper]
196
+
197
+ @property
198
+ def ansi(self) -> bytes: ...
199
+
200
+ @property
201
+ def ansi_format(self) -> AnsiColorType: ...
202
+
203
+ @property
204
+ def base_str(self) -> str: ...
205
+
206
+ @property
207
+ def bg(self) -> Color | None: ...
208
+
209
+ @property
210
+ def fg(self) -> Color | None: ...
211
+
212
+ @property
213
+ def no_reset(self) -> bool: ...
214
+
215
+ @property
216
+ def rgb_dict(self) -> dict[ColorDictKeys, Int3Tuple]: ...
217
+
218
+
219
+ class SgrParameter(IntEnum):
220
+ RESET = 0
221
+ BOLD = 1
222
+ FAINT = 2
223
+ ITALICS = 3
224
+ SINGLE_UNDERLINE = 4
225
+ SLOW_BLINK = 5
226
+ RAPID_BLINK = 6
227
+ NEGATIVE = 7
228
+ CONCEALED_CHARS = 8
229
+ CROSSED_OUT = 9
230
+ PRIMARY = 10
231
+ FIRST_ALT = 11
232
+ SECOND_ALT = 12
233
+ THIRD_ALT = 13
234
+ FOURTH_ALT = 14
235
+ FIFTH_ALT = 15
236
+ SIXTH_ALT = 16
237
+ SEVENTH_ALT = 17
238
+ EIGHTH_ALT = 18
239
+ NINTH_ALT = 19
240
+ GOTHIC = 20
241
+ DOUBLE_UNDERLINE = 21
242
+ RESET_BOLD_AND_FAINT = 22
243
+ RESET_ITALIC_AND_GOTHIC = 23
244
+ RESET_UNDERLINES = 24
245
+ RESET_BLINKING = 25
246
+ POSITIVE = 26
247
+ REVEALED_CHARS = 28
248
+ RESET_CROSSED_OUT = 29
249
+ BLACK_FG = 30
250
+ RED_FG = 31
251
+ GREEN_FG = 32
252
+ YELLOW_FG = 33
253
+ BLUE_FG = 34
254
+ MAGENTA_FG = 35
255
+ CYAN_FG = 36
256
+ WHITE_FG = 37
257
+ ANSI_256_SET_FG = 38
258
+ DEFAULT_FG_COLOR = 39
259
+ BLACK_BG = 40
260
+ RED_BG = 41
261
+ GREEN_BG = 42
262
+ YELLOW_BG = 43
263
+ BLUE_BG = 44
264
+ MAGENTA_BG = 45
265
+ CYAN_BG = 46
266
+ WHITE_BG = 47
267
+ ANSI_256_SET_BG = 48
268
+ DEFAULT_BG_COLOR = 49
269
+ FRAMED = 50
270
+ ENCIRCLED = 52
271
+ OVERLINED = 53
272
+ NOT_FRAMED_OR_CIRCLED = 54
273
+ IDEOGRAM_UNDER_OR_RIGHT = 55
274
+ IDEOGRAM_2UNDER_OR_2RIGHT = 60
275
+ IDEOGRAM_OVER_OR_LEFT = 61
276
+ IDEOGRAM_2OVER_OR_2LEFT = 62
277
+ CANCEL = 63
278
+ BLACK_BRIGHT_FG = 90
279
+ RED_BRIGHT_FG = 91
280
+ GREEN_BRIGHT_FG = 92
281
+ YELLOW_BRIGHT_FG = 93
282
+ BLUE_BRIGHT_FG = 94
283
+ MAGENTA_BRIGHT_FG = 95
284
+ CYAN_BRIGHT_FG = 96
285
+ WHITE_BRIGHT_FG = 97
286
+ BLACK_BRIGHT_BG = 100
287
+ RED_BRIGHT_BG = 101
288
+ GREEN_BRIGHT_BG = 102
289
+ YELLOW_BRIGHT_BG = 103
290
+ BLUE_BRIGHT_BG = 104
291
+ MAGENTA_BRIGHT_BG = 105
292
+ CYAN_BRIGHT_BG = 106
293
+ WHITE_BRIGHT_BG = 107
294
+
295
+
296
+ class SgrParamWrapper:
297
+
298
+ def is_color(self) -> bool: ...
299
+
300
+ def is_reset(self) -> bool: ...
301
+
302
+ def is_same_kind(self, other: ...) -> bool: ...
303
+
304
+ def __bytes__(self) -> bytes: ...
305
+
306
+ def __eq__(self, other: ...) -> bool: ...
307
+
308
+ def __hash__(self) -> int: ...
309
+
310
+ def __init__[_T: (bytes, AnsiColorFormat, SgrParamWrapper)](self, value: _T = b'') -> None: ...
311
+
312
+ _value_: Union[bytes, AnsiColorFormat]
313
+
314
+
315
+ class SgrSequence:
316
+
317
+ def append(self, __value: int) -> None: ...
318
+
319
+ def find(self, value: ...) -> int: ...
320
+
321
+ def get_color(self, __key: ColorDictKeys): ...
322
+
323
+ def index(self, value: ...) -> int: ...
324
+
325
+ def is_color(self) -> bool: ...
326
+
327
+ def is_reset(self) -> bool: ...
328
+
329
+ def pop(self, __index: SupportsIndex = -1) -> SgrParamWrapper: ...
330
+
331
+ def values(self) -> list[Union[bytes, AnsiColorFormat]]: ...
332
+
333
+ def __add__[_T: (SgrSequence, str)](self, other: _T) -> _T: ...
334
+
335
+ def __bool__(self) -> bool: ...
336
+
337
+ def __bytes__(self) -> bytes: ...
338
+
339
+ def __contains__(self, item: ...) -> bool: ...
340
+
341
+ def __copy__(self) -> SgrSequence: ...
342
+
343
+ def __deepcopy__(self) -> SgrSequence: ...
344
+
345
+ def __eq__(self, other: ...) -> bool: ...
346
+
347
+ def __getitem__(self, item): ...
348
+
349
+ def __init__[_T: (Buffer, int), _AnsiType: type[AnsiColorFormat]](
350
+ self,
351
+ __iter: Union[Sequence[_T], Sequence[SgrParamWrapper], SgrSequence] = None,
352
+ *,
353
+ ansi_type: _AnsiType = None) -> None: ...
354
+
355
+ def __iter__(self) -> Iterator[SgrParamWrapper]: ...
356
+
357
+ def __radd__[_T: (SgrSequence, str)](self, other: _T) -> _T: ...
358
+
359
+ def __str__(self) -> str: ...
360
+
361
+ __slots__ = '_bytes_', '_has_bright_colors_', '_rgb_dict_', '_sgr_params_'
362
+ _bytes_: Union[bytes, None]
363
+ _has_bright_colors_: bool
364
+ _rgb_dict_: dict[ColorDictKeys, Int3Tuple]
365
+ _sgr_params_: list[SgrParamWrapper]
366
+
367
+ @property
368
+ def bg(self) -> Int3Tuple | None: ...
369
+
370
+ @property
371
+ def fg(self) -> Int3Tuple | None: ...
372
+
373
+ @property
374
+ def has_bright_colors(self) -> bool: ...
375
+
376
+ @property
377
+ def rgb_dict(self) -> MappingProxyType[ColorDictKeys, Int3Tuple]: ...
378
+
379
+ # noinspection PyUnresolvedReferences
380
+ @rgb_dict.deleter
381
+ def rgb_dict(self) -> None: ...
382
+
383
+ # noinspection PyUnresolvedReferences
384
+ @rgb_dict.setter
385
+ def rgb_dict[_AnsiColorType: type[AnsiColorFormat]](
386
+ self,
387
+ __value: tuple[_AnsiColorType, dict[ColorDictKeys, Union[Color, None]]]
388
+ ) -> None: ...
389
+
390
+
391
+ class _ColorDict(TypedDict, total=False):
392
+ bg: Union[Color, AnsiColorFormat, None]
393
+ fg: Union[Color, AnsiColorFormat, None]
394
+
395
+
396
+ class _ColorStrKwargs(TypedDict, total=False):
397
+ ansi_type: Union[AnsiColorAlias, type[AnsiColorFormat], None]
398
+ no_reset: bool
399
+
400
+
401
+ class _ColorStrWeakVars(TypedDict, total=False):
402
+ _base_str_: str
403
+ _no_reset_: bool
404
+ _sgr_: SgrSequence
405
+
406
+
407
+ CSI: Final[bytes] = b'['
408
+ SGR_RESET: Final[str] = ''
409
+ DEFAULT_ANSI: Final[type[ansicolor8Bit | ansicolor4Bit]]
410
+ _ANSI16C_BRIGHT: Final[frozenset[int]]
411
+ _ANSI16C_I2KV: Final[dict[int, tuple[ColorDictKeys, Int3Tuple]]]
412
+ _ANSI16C_KV2I: Final[dict[tuple[Literal['fg', 'bg'], tuple[int, int, int]], int]]
413
+ _ANSI16C_STD: Final[frozenset[int]]
414
+ _ANSI256_B2KEY: Final[dict[bytes, str]]
415
+ _ANSI256_KEY2I: Final[dict[str, int]]
416
+ _ANSI_COLOR_TYPES: Final[frozenset[AnsiColorType]]
417
+ _ANSI_FORMAT_MAP: Final[dict[AnsiColorAlias | AnsiColorType, type[AnsiColorFormat]]]
418
+ _AnsiColor_co = TypeVar('_AnsiColor_co', bound=colorbytes, covariant=True)
419
+ _ColorSpec = TypeVar('_ColorSpec', bound=_CSpecType)
420
+ _RGBVectorLike = TypeVar('_RGBVectorLike', bound=RGBVectorLike)
421
+ _SGR_PARAM_VALUES: Final[frozenset[int]]