xulbux 1.7.1__py3-none-any.whl → 1.7.2__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.
Potentially problematic release.
This version of xulbux might be problematic. Click here for more details.
- xulbux/__init__.py +1 -1
- xulbux/_consts_.py +2 -4
- xulbux/xx_code.py +1 -1
- xulbux/xx_console.py +37 -27
- xulbux/xx_format_codes.py +51 -25
- {xulbux-1.7.1.dist-info → xulbux-1.7.2.dist-info}/METADATA +1 -1
- {xulbux-1.7.1.dist-info → xulbux-1.7.2.dist-info}/RECORD +11 -11
- {xulbux-1.7.1.dist-info → xulbux-1.7.2.dist-info}/WHEEL +0 -0
- {xulbux-1.7.1.dist-info → xulbux-1.7.2.dist-info}/entry_points.txt +0 -0
- {xulbux-1.7.1.dist-info → xulbux-1.7.2.dist-info}/licenses/LICENSE +0 -0
- {xulbux-1.7.1.dist-info → xulbux-1.7.2.dist-info}/top_level.txt +0 -0
xulbux/__init__.py
CHANGED
xulbux/_consts_.py
CHANGED
|
@@ -94,8 +94,6 @@ class ANSI:
|
|
|
94
94
|
"""The separator between ANSI escape sequence parts."""
|
|
95
95
|
END = end = "m"
|
|
96
96
|
"""The end of an ANSI escape sequence."""
|
|
97
|
-
default_color_modifiers: dict[str, str] = {"lighten": "+l", "darken": "-d"}
|
|
98
|
-
"""Characters to modify the lightness of the default color with."""
|
|
99
97
|
|
|
100
98
|
@classmethod
|
|
101
99
|
def seq(cls, parts: int = 1) -> FormattableString:
|
|
@@ -107,7 +105,7 @@ class ANSI:
|
|
|
107
105
|
seq_bg_color: FormattableString = CHAR + START + "48" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
|
|
108
106
|
"""The ANSI escape sequence for setting the background RGB color."""
|
|
109
107
|
|
|
110
|
-
color_map:
|
|
108
|
+
color_map: tuple[str, ...] = (
|
|
111
109
|
########### DEFAULT CONSOLE COLOR NAMES ############
|
|
112
110
|
"black",
|
|
113
111
|
"red",
|
|
@@ -117,7 +115,7 @@ class ANSI:
|
|
|
117
115
|
"magenta",
|
|
118
116
|
"cyan",
|
|
119
117
|
"white",
|
|
120
|
-
|
|
118
|
+
)
|
|
121
119
|
"""The console default color names."""
|
|
122
120
|
|
|
123
121
|
codes_map: dict[str | tuple[str, ...], int] = {
|
xulbux/xx_code.py
CHANGED
|
@@ -53,7 +53,7 @@ class Code:
|
|
|
53
53
|
return list(Data.remove_duplicates(funcs + nested_func_calls))
|
|
54
54
|
|
|
55
55
|
@staticmethod
|
|
56
|
-
def is_js(code: str, funcs: list = ["__", "$t", "$lang"]) -> bool:
|
|
56
|
+
def is_js(code: str, funcs: list[str] = ["__", "$t", "$lang"]) -> bool:
|
|
57
57
|
"""Will check if the code is very likely to be JavaScript."""
|
|
58
58
|
if not code or len(code.strip()) < 3:
|
|
59
59
|
return False
|
xulbux/xx_console.py
CHANGED
|
@@ -25,20 +25,29 @@ import os as _os
|
|
|
25
25
|
class _ConsoleWidth:
|
|
26
26
|
|
|
27
27
|
def __get__(self, obj, owner=None):
|
|
28
|
-
|
|
28
|
+
try:
|
|
29
|
+
return _os.get_terminal_size().columns
|
|
30
|
+
except OSError:
|
|
31
|
+
return 80
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
class _ConsoleHeight:
|
|
32
35
|
|
|
33
36
|
def __get__(self, obj, owner=None):
|
|
34
|
-
|
|
37
|
+
try:
|
|
38
|
+
return _os.get_terminal_size().lines
|
|
39
|
+
except OSError:
|
|
40
|
+
return 24
|
|
35
41
|
|
|
36
42
|
|
|
37
43
|
class _ConsoleSize:
|
|
38
44
|
|
|
39
45
|
def __get__(self, obj, owner=None):
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
try:
|
|
47
|
+
size = _os.get_terminal_size()
|
|
48
|
+
return (size.columns, size.lines)
|
|
49
|
+
except OSError:
|
|
50
|
+
return (80, 24)
|
|
42
51
|
|
|
43
52
|
|
|
44
53
|
class _ConsoleUser:
|
|
@@ -231,13 +240,13 @@ class Console:
|
|
|
231
240
|
exit_code: int = 0,
|
|
232
241
|
reset_ansi: bool = False,
|
|
233
242
|
) -> None:
|
|
234
|
-
"""Will print the `
|
|
243
|
+
"""Will print the `prompt` and then pause the program if `pause` is set
|
|
235
244
|
to `True` and after the pause, exit the program if `exit` is set to `True`."""
|
|
236
245
|
print(prompt, end="", flush=True)
|
|
237
246
|
if reset_ansi:
|
|
238
247
|
FormatCodes.print("[_]", end="")
|
|
239
248
|
if pause:
|
|
240
|
-
_keyboard.
|
|
249
|
+
_keyboard.read_key(suppress=True)
|
|
241
250
|
if exit:
|
|
242
251
|
_sys.exit(exit_code)
|
|
243
252
|
|
|
@@ -344,8 +353,8 @@ class Console:
|
|
|
344
353
|
format_linebreaks: bool = True,
|
|
345
354
|
start: str = "",
|
|
346
355
|
end: str = "\n",
|
|
347
|
-
title_bg_color: Rgba | Hexa = COLOR.yellow,
|
|
348
|
-
default_color: Rgba | Hexa = COLOR.text,
|
|
356
|
+
title_bg_color: Optional[Rgba | Hexa] = COLOR.yellow,
|
|
357
|
+
default_color: Optional[Rgba | Hexa] = COLOR.text,
|
|
349
358
|
pause: bool = False,
|
|
350
359
|
exit: bool = False,
|
|
351
360
|
) -> None:
|
|
@@ -362,8 +371,8 @@ class Console:
|
|
|
362
371
|
format_linebreaks: bool = True,
|
|
363
372
|
start: str = "",
|
|
364
373
|
end: str = "\n",
|
|
365
|
-
title_bg_color: Rgba | Hexa = COLOR.blue,
|
|
366
|
-
default_color: Rgba | Hexa = COLOR.text,
|
|
374
|
+
title_bg_color: Optional[Rgba | Hexa] = COLOR.blue,
|
|
375
|
+
default_color: Optional[Rgba | Hexa] = COLOR.text,
|
|
367
376
|
pause: bool = False,
|
|
368
377
|
exit: bool = False,
|
|
369
378
|
) -> None:
|
|
@@ -378,8 +387,8 @@ class Console:
|
|
|
378
387
|
format_linebreaks: bool = True,
|
|
379
388
|
start: str = "",
|
|
380
389
|
end: str = "\n",
|
|
381
|
-
title_bg_color: Rgba | Hexa = COLOR.teal,
|
|
382
|
-
default_color: Rgba | Hexa = COLOR.text,
|
|
390
|
+
title_bg_color: Optional[Rgba | Hexa] = COLOR.teal,
|
|
391
|
+
default_color: Optional[Rgba | Hexa] = COLOR.text,
|
|
383
392
|
pause: bool = False,
|
|
384
393
|
exit: bool = False,
|
|
385
394
|
) -> None:
|
|
@@ -394,8 +403,8 @@ class Console:
|
|
|
394
403
|
format_linebreaks: bool = True,
|
|
395
404
|
start: str = "",
|
|
396
405
|
end: str = "\n",
|
|
397
|
-
title_bg_color: Rgba | Hexa = COLOR.orange,
|
|
398
|
-
default_color: Rgba | Hexa = COLOR.text,
|
|
406
|
+
title_bg_color: Optional[Rgba | Hexa] = COLOR.orange,
|
|
407
|
+
default_color: Optional[Rgba | Hexa] = COLOR.text,
|
|
399
408
|
pause: bool = False,
|
|
400
409
|
exit: bool = False,
|
|
401
410
|
) -> None:
|
|
@@ -410,11 +419,11 @@ class Console:
|
|
|
410
419
|
format_linebreaks: bool = True,
|
|
411
420
|
start: str = "",
|
|
412
421
|
end: str = "\n",
|
|
413
|
-
title_bg_color: Rgba | Hexa = COLOR.red,
|
|
414
|
-
default_color: Rgba | Hexa = COLOR.text,
|
|
422
|
+
title_bg_color: Optional[Rgba | Hexa] = COLOR.red,
|
|
423
|
+
default_color: Optional[Rgba | Hexa] = COLOR.text,
|
|
415
424
|
pause: bool = False,
|
|
416
425
|
exit: bool = True,
|
|
417
|
-
reset_ansi=True,
|
|
426
|
+
reset_ansi: bool = True,
|
|
418
427
|
) -> None:
|
|
419
428
|
"""A preset for `log()`: `FAIL` log message with the options to pause
|
|
420
429
|
at the message and exit the program after the message was printed."""
|
|
@@ -427,11 +436,11 @@ class Console:
|
|
|
427
436
|
format_linebreaks: bool = True,
|
|
428
437
|
start: str = "",
|
|
429
438
|
end: str = "\n",
|
|
430
|
-
title_bg_color: Rgba | Hexa = COLOR.magenta,
|
|
431
|
-
default_color: Rgba | Hexa = COLOR.text,
|
|
439
|
+
title_bg_color: Optional[Rgba | Hexa] = COLOR.magenta,
|
|
440
|
+
default_color: Optional[Rgba | Hexa] = COLOR.text,
|
|
432
441
|
pause: bool = False,
|
|
433
442
|
exit: bool = True,
|
|
434
|
-
reset_ansi=True,
|
|
443
|
+
reset_ansi: bool = True,
|
|
435
444
|
) -> None:
|
|
436
445
|
"""A preset for `log()`: `EXIT` log message with the options to pause
|
|
437
446
|
at the message and exit the program after the message was printed."""
|
|
@@ -443,8 +452,8 @@ class Console:
|
|
|
443
452
|
*values: object,
|
|
444
453
|
start: str = "",
|
|
445
454
|
end: str = "\n",
|
|
446
|
-
box_bg_color: Rgba | Hexa = "green",
|
|
447
|
-
default_color: Rgba | Hexa =
|
|
455
|
+
box_bg_color: str | Rgba | Hexa = "green",
|
|
456
|
+
default_color: Optional[Rgba | Hexa] = None,
|
|
448
457
|
w_padding: int = 2,
|
|
449
458
|
w_full: bool = False,
|
|
450
459
|
) -> None:
|
|
@@ -494,6 +503,7 @@ class Console:
|
|
|
494
503
|
- `start` -⠀something to print before the log box is printed (e.g. `\\n`)
|
|
495
504
|
- `end` -⠀something to print after the log box is printed (e.g. `\\n`)
|
|
496
505
|
- `border_type` -⠀one of the predefined border character sets
|
|
506
|
+
- `border_style` -⠀the style of the border (special formatting codes)
|
|
497
507
|
- `default_color` -⠀the default text color of the `*values`
|
|
498
508
|
- `w_padding` -⠀the horizontal padding (in chars) to the box content
|
|
499
509
|
- `w_full` -⠀whether to make the box be the full console width or not
|
|
@@ -559,7 +569,7 @@ class Console:
|
|
|
559
569
|
prompt: object = "Do you want to continue?",
|
|
560
570
|
start="",
|
|
561
571
|
end="\n",
|
|
562
|
-
default_color: Rgba | Hexa = COLOR.cyan,
|
|
572
|
+
default_color: Optional[Rgba | Hexa] = COLOR.cyan,
|
|
563
573
|
default_is_yes: bool = True,
|
|
564
574
|
) -> bool:
|
|
565
575
|
"""Ask a yes/no question.\n
|
|
@@ -569,7 +579,7 @@ class Console:
|
|
|
569
579
|
confirmed = input(
|
|
570
580
|
FormatCodes.to_ansi(
|
|
571
581
|
f'{start} {str(prompt)} [_|dim](({"Y" if default_is_yes else "y"}/{"n" if default_is_yes else "N"}): )',
|
|
572
|
-
default_color,
|
|
582
|
+
default_color=default_color,
|
|
573
583
|
)
|
|
574
584
|
).strip().lower() in (("", "y", "yes") if default_is_yes else ("y", "yes"))
|
|
575
585
|
if end:
|
|
@@ -581,7 +591,7 @@ class Console:
|
|
|
581
591
|
prompt: object = "",
|
|
582
592
|
start="",
|
|
583
593
|
end="\n",
|
|
584
|
-
default_color: Rgba | Hexa = COLOR.cyan,
|
|
594
|
+
default_color: Optional[Rgba | Hexa] = COLOR.cyan,
|
|
585
595
|
show_keybindings=True,
|
|
586
596
|
input_prefix=" ⮡ ",
|
|
587
597
|
reset_ansi=True,
|
|
@@ -616,7 +626,7 @@ class Console:
|
|
|
616
626
|
prompt: object = "",
|
|
617
627
|
start="",
|
|
618
628
|
end="\n",
|
|
619
|
-
default_color: Rgba | Hexa = COLOR.cyan,
|
|
629
|
+
default_color: Optional[Rgba | Hexa] = COLOR.cyan,
|
|
620
630
|
allowed_chars: str = CHARS.all, # type: ignore[assignment]
|
|
621
631
|
min_len: Optional[int] = None,
|
|
622
632
|
max_len: Optional[int] = None,
|
|
@@ -720,7 +730,7 @@ class Console:
|
|
|
720
730
|
prompt: object = "Password: ",
|
|
721
731
|
start="",
|
|
722
732
|
end="\n",
|
|
723
|
-
default_color: Rgba | Hexa = COLOR.cyan,
|
|
733
|
+
default_color: Optional[Rgba | Hexa] = COLOR.cyan,
|
|
724
734
|
allowed_chars: str = CHARS.standard_ascii,
|
|
725
735
|
min_len: Optional[int] = None,
|
|
726
736
|
max_len: Optional[int] = None,
|
xulbux/xx_format_codes.py
CHANGED
|
@@ -133,10 +133,13 @@ the formatting code:
|
|
|
133
133
|
#### Additional Formatting Codes when a `default_color` is set
|
|
134
134
|
|
|
135
135
|
1. `[*]` resets everything, just like `[_]`, but the text color will remain in `default_color`
|
|
136
|
-
(
|
|
136
|
+
(if no `default_color` is set, it resets everything, exactly like `[_]`)
|
|
137
137
|
2. `[*color]` `[*c]` will reset the text color, just like `[_color]`, but then also make it `default_color`
|
|
138
|
+
(if no `default_color` is set, both are treated as invalid formatting codes)
|
|
138
139
|
3. `[default]` will just color the text in `default_color`
|
|
140
|
+
(if no `default_color` is set, it's treated as an invalid formatting code)
|
|
139
141
|
4. `[background:default]` `[BG:default]` will color the background in `default_color`
|
|
142
|
+
(if no `default_color` is set, both are treated as invalid formatting codes)\n
|
|
140
143
|
|
|
141
144
|
Unlike the standard console colors, the default color can be changed by using the following modifiers:
|
|
142
145
|
|
|
@@ -149,6 +152,7 @@ Unlike the standard console colors, the default color can be changed by using th
|
|
|
149
152
|
- `[ddd]` will darken the `default_color` text by `3 × brightness_steps`%
|
|
150
153
|
- ... etc.
|
|
151
154
|
Per default, you can also use `+` and `-` to get lighter and darker `default_color` versions.
|
|
155
|
+
All of these lighten/darken formatting codes are treated as invalid if no `default_color` is set.
|
|
152
156
|
"""
|
|
153
157
|
|
|
154
158
|
from ._consts_ import ANSI
|
|
@@ -165,6 +169,11 @@ import re as _re
|
|
|
165
169
|
|
|
166
170
|
_CONSOLE_ANSI_CONFIGURED: bool = False
|
|
167
171
|
|
|
172
|
+
_ANSI_SEQ_1: str = ANSI.seq(1)
|
|
173
|
+
_DEFAULT_COLOR_MODS: dict[str, str] = {
|
|
174
|
+
"lighten": "+l",
|
|
175
|
+
"darken": "-d",
|
|
176
|
+
}
|
|
168
177
|
_PREFIX: dict[str, set[str]] = {
|
|
169
178
|
"BG": {"background", "bg"},
|
|
170
179
|
"BR": {"bright", "br"},
|
|
@@ -190,7 +199,7 @@ _COMPILED: dict[str, Pattern] = { # PRECOMPILE REGULAR EXPRESSIONS
|
|
|
190
199
|
"modifier": _re.compile(
|
|
191
200
|
r"(?i)((?:BG\s*:)?)\s*("
|
|
192
201
|
+ "|".join(
|
|
193
|
-
[f"{_re.escape(m)}+" for m in
|
|
202
|
+
[f"{_re.escape(m)}+" for m in _DEFAULT_COLOR_MODS["lighten"] + _DEFAULT_COLOR_MODS["darken"]]
|
|
194
203
|
)
|
|
195
204
|
+ r")$"
|
|
196
205
|
),
|
|
@@ -247,6 +256,7 @@ class FormatCodes:
|
|
|
247
256
|
default_color: Optional[Rgba | Hexa] = None,
|
|
248
257
|
brightness_steps: int = 20,
|
|
249
258
|
_default_start: bool = True,
|
|
259
|
+
_validate_default: bool = True,
|
|
250
260
|
) -> str:
|
|
251
261
|
"""Convert the formatting codes inside a string to ANSI formatting.\n
|
|
252
262
|
-------------------------------------------------------------------------
|
|
@@ -254,16 +264,20 @@ class FormatCodes:
|
|
|
254
264
|
`xx_format_codes` module documentation."""
|
|
255
265
|
if not isinstance(string, str):
|
|
256
266
|
string = str(string)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
use_default, default_specified = False, default_color is not None
|
|
268
|
+
if _validate_default and default_specified:
|
|
269
|
+
if Color.is_valid_rgba(default_color, False):
|
|
270
|
+
use_default = True
|
|
271
|
+
elif Color.is_valid_hexa(default_color, False):
|
|
272
|
+
use_default, default_color = True, Color.to_rgba(default_color) # type: ignore[assignment]
|
|
261
273
|
else:
|
|
262
|
-
use_default =
|
|
263
|
-
default_color = cast(rgba, default_color)
|
|
274
|
+
use_default = default_specified
|
|
275
|
+
default_color = cast(Optional[rgba], default_color)
|
|
264
276
|
if use_default:
|
|
265
277
|
string = _COMPILED["*"].sub(r"[\1_|default\2]", string) # REPLACE `[…|*|…]` WITH `[…|_|default|…]`
|
|
266
|
-
string = _COMPILED["*color"].sub(
|
|
278
|
+
string = _COMPILED["*color"].sub(
|
|
279
|
+
r"[\1default\2]", string
|
|
280
|
+
) # REPLACE `[…|*color|…]` OR `[…|*c|…]` WITH `[…|default|…]`
|
|
267
281
|
else:
|
|
268
282
|
string = _COMPILED["*"].sub(r"[\1_\2]", string) # REPLACE `[…|*|…]` WITH `[…|_|…]`
|
|
269
283
|
|
|
@@ -277,11 +291,23 @@ class FormatCodes:
|
|
|
277
291
|
if formats_escaped := bool(_COMPILED["escape_char_cond"].match(match.group(0))):
|
|
278
292
|
_formats = formats = _COMPILED["escape_char"].sub(r"\1", formats) # REMOVE / OR \\
|
|
279
293
|
if auto_reset_txt and auto_reset_txt.count("[") > 0 and auto_reset_txt.count("]") > 0:
|
|
280
|
-
auto_reset_txt = FormatCodes.to_ansi(
|
|
294
|
+
auto_reset_txt = FormatCodes.to_ansi(
|
|
295
|
+
auto_reset_txt,
|
|
296
|
+
default_color,
|
|
297
|
+
brightness_steps,
|
|
298
|
+
_default_start=False,
|
|
299
|
+
_validate_default=False,
|
|
300
|
+
)
|
|
281
301
|
if not formats:
|
|
282
302
|
return match.group(0)
|
|
283
303
|
if formats.count("[") > 0 and formats.count("]") > 0:
|
|
284
|
-
formats = FormatCodes.to_ansi(
|
|
304
|
+
formats = FormatCodes.to_ansi(
|
|
305
|
+
formats,
|
|
306
|
+
default_color,
|
|
307
|
+
brightness_steps,
|
|
308
|
+
_default_start=False,
|
|
309
|
+
_validate_default=False,
|
|
310
|
+
)
|
|
285
311
|
format_keys = [k.strip() for k in formats.split("|") if k.strip()]
|
|
286
312
|
ansi_formats = [
|
|
287
313
|
r if (r := FormatCodes.__get_replacement(k, default_color, brightness_steps)) != k else f"[{k}]"
|
|
@@ -323,13 +349,13 @@ class FormatCodes:
|
|
|
323
349
|
else:
|
|
324
350
|
return (
|
|
325
351
|
"".join(ansi_formats) + (
|
|
326
|
-
f"({FormatCodes.to_ansi(auto_reset_txt, default_color, brightness_steps, False)})"
|
|
352
|
+
f"({FormatCodes.to_ansi(auto_reset_txt, default_color, brightness_steps, _default_start=False, _validate_default=False)})"
|
|
327
353
|
if auto_reset_escaped and auto_reset_txt else auto_reset_txt if auto_reset_txt else ""
|
|
328
354
|
) + ("" if auto_reset_escaped else "".join(ansi_resets))
|
|
329
355
|
)
|
|
330
356
|
|
|
331
357
|
string = "\n".join(_COMPILED["formatting"].sub(replace_keys, line) for line in string.split("\n"))
|
|
332
|
-
return (((FormatCodes.__get_default_ansi(default_color
|
|
358
|
+
return (((FormatCodes.__get_default_ansi(default_color) or "") if _default_start else "")
|
|
333
359
|
+ string) if default_color is not None else string
|
|
334
360
|
|
|
335
361
|
@staticmethod
|
|
@@ -399,19 +425,21 @@ class FormatCodes:
|
|
|
399
425
|
|
|
400
426
|
@staticmethod
|
|
401
427
|
def __get_default_ansi(
|
|
402
|
-
default_color:
|
|
428
|
+
default_color: rgba,
|
|
403
429
|
format_key: Optional[str] = None,
|
|
404
430
|
brightness_steps: Optional[int] = None,
|
|
405
|
-
_modifiers: tuple[str, str] = (
|
|
431
|
+
_modifiers: tuple[str, str] = (_DEFAULT_COLOR_MODS["lighten"], _DEFAULT_COLOR_MODS["darken"]),
|
|
406
432
|
) -> Optional[str]:
|
|
407
433
|
"""Get the `default_color` and lighter/darker versions of it as ANSI code."""
|
|
408
|
-
if not
|
|
434
|
+
if not isinstance(default_color, rgba):
|
|
435
|
+
return None
|
|
436
|
+
_default_color: tuple[int, int, int] = tuple(default_color)[:3]
|
|
437
|
+
if brightness_steps is None or (format_key and _COMPILED["bg?_default"].search(format_key)):
|
|
409
438
|
return (ANSI.seq_bg_color if format_key and _COMPILED["bg_default"].search(format_key) else ANSI.seq_color).format(
|
|
410
|
-
*
|
|
439
|
+
*_default_color
|
|
411
440
|
)
|
|
412
441
|
if format_key is None or not (format_key in _modifiers[0] or format_key in _modifiers[1]):
|
|
413
442
|
return None
|
|
414
|
-
assert format_key is not None
|
|
415
443
|
match = _COMPILED["modifier"].match(format_key)
|
|
416
444
|
if not match:
|
|
417
445
|
return None
|
|
@@ -422,7 +450,7 @@ class FormatCodes:
|
|
|
422
450
|
if adjust and adjust > 0:
|
|
423
451
|
modifiers = mod
|
|
424
452
|
break
|
|
425
|
-
new_rgb =
|
|
453
|
+
new_rgb = _default_color
|
|
426
454
|
if adjust == 0:
|
|
427
455
|
return None
|
|
428
456
|
elif modifiers in _modifiers[0]:
|
|
@@ -436,15 +464,13 @@ class FormatCodes:
|
|
|
436
464
|
"""Gives you the corresponding ANSI code for the given format key.
|
|
437
465
|
If `default_color` is not `None`, the text color will be `default_color` if all formats
|
|
438
466
|
are reset or you can get lighter or darker version of `default_color` (also as BG)"""
|
|
439
|
-
use_default = default_color and Color.is_valid_rgba(default_color, False)
|
|
440
|
-
_default_color = tuple(Color.to_rgba(default_color)) if default_color is not None else tuple()
|
|
441
467
|
_format_key, format_key = format_key, FormatCodes.__normalize_key(format_key) # NORMALIZE KEY AND SAVE ORIGINAL
|
|
442
|
-
if
|
|
443
|
-
|
|
444
|
-
|
|
468
|
+
if default_color and (new_default_color := FormatCodes.__get_default_ansi(default_color, format_key,
|
|
469
|
+
brightness_steps)):
|
|
470
|
+
return new_default_color
|
|
445
471
|
for map_key in ANSI.codes_map:
|
|
446
472
|
if (isinstance(map_key, tuple) and format_key in map_key) or format_key == map_key:
|
|
447
|
-
return
|
|
473
|
+
return _ANSI_SEQ_1.format(
|
|
448
474
|
next((
|
|
449
475
|
v for k, v in ANSI.codes_map.items() if format_key == k or (isinstance(k, tuple) and format_key in k)
|
|
450
476
|
), None)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xulbux
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.2
|
|
4
4
|
Summary: A Python library which includes lots of helpful classes, types and functions aiming to make common programming tasks simpler.
|
|
5
5
|
Author-email: XulbuX <xulbux.real@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
xulbux/__init__.py,sha256=
|
|
1
|
+
xulbux/__init__.py,sha256=vd8y5L0AwqnxqXm_IAJ5grbfm8ZkcSHJx36n1KUQTlc,815
|
|
2
2
|
xulbux/_cli_.py,sha256=J4vfJHLJEYxCZzA_VJUB46w2WGShfdYFoetsLG5PfKo,3428
|
|
3
|
-
xulbux/_consts_.py,sha256=
|
|
4
|
-
xulbux/xx_code.py,sha256=
|
|
3
|
+
xulbux/_consts_.py,sha256=4CLJE-YH3si2YQ-IHcjsT5PW0D7vGvm8ZH13rUoG5cE,6166
|
|
4
|
+
xulbux/xx_code.py,sha256=b8MJId-BmZOsBH38z-h055op7qIICdsTT3rFJ7SWkiE,6111
|
|
5
5
|
xulbux/xx_color.py,sha256=Thj7fFTc8x-VmYyULI3HQW0uCk9dIihwrGUwuXGn83s,49744
|
|
6
|
-
xulbux/xx_console.py,sha256=
|
|
6
|
+
xulbux/xx_console.py,sha256=c61EXVGQo_OL_MUWb4oXbIr6EKesm1v-FwxBIe47ZTg,34866
|
|
7
7
|
xulbux/xx_data.py,sha256=nEfVwK6-ILaL3K-bLezKpG1G7117CY5ZgC3BGwANrUE,30886
|
|
8
8
|
xulbux/xx_env_path.py,sha256=x56mKK4lSvU5yMCAs8k0RVIqXWUJcpcHYz5HoZ_RklM,4160
|
|
9
9
|
xulbux/xx_file.py,sha256=KerXOvKS93zIoAt36YTYuZboSmxVFVf2WcOrDcdwXfE,2627
|
|
10
|
-
xulbux/xx_format_codes.py,sha256
|
|
10
|
+
xulbux/xx_format_codes.py,sha256=-tSsgy1tRelmU5x5ZS7ujaiXntyRqk1sm759tyvVIyU,24698
|
|
11
11
|
xulbux/xx_json.py,sha256=V7vdfpvSe9wpktR_c8zG_Meix7x9IRmn66k5nB3HUyo,7457
|
|
12
12
|
xulbux/xx_path.py,sha256=lLAEVZrW0TAwCewlONFVQcQ_8tVn9LTJZVOZpeGvE5s,7673
|
|
13
13
|
xulbux/xx_regex.py,sha256=_BtMHRDNcD9zF4SL87dQuUVZcYGfZx9H5YNSDiEtzm8,8059
|
|
14
14
|
xulbux/xx_string.py,sha256=QaTo0TQ9m_2USNgQNaVw5ivQt-A1E-e5x8OpIB3xIlY,5561
|
|
15
15
|
xulbux/xx_system.py,sha256=Tsx4wgztUg46KloqcGeiFkarDoM3EgJLXw3XNxgHBmU,6460
|
|
16
|
-
xulbux-1.7.
|
|
17
|
-
xulbux-1.7.
|
|
18
|
-
xulbux-1.7.
|
|
19
|
-
xulbux-1.7.
|
|
20
|
-
xulbux-1.7.
|
|
21
|
-
xulbux-1.7.
|
|
16
|
+
xulbux-1.7.2.dist-info/licenses/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
|
|
17
|
+
xulbux-1.7.2.dist-info/METADATA,sha256=vlIkVkj97ZLjiFajkGrSZ5O0GDrzuIunJ1E1iqY-QTA,9209
|
|
18
|
+
xulbux-1.7.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
xulbux-1.7.2.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
|
|
20
|
+
xulbux-1.7.2.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
|
|
21
|
+
xulbux-1.7.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|