Skip to content

Commit 7e80276

Browse files
committed
update 1.8.0
1 parent 83bf55f commit 7e80276

10 files changed

Lines changed: 170 additions & 161 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
new, instead of flags, you can also once use the literal `"before"` and once `"after"`, which corresponds to all non-flagged values before or after all flagged values
2121
* changed the default `default_color` for all `Console` class input methods to `None`
2222
* the method `Console.restricted_input()` now returns an empty string instead of `None` if the user didn't input anything
23-
* fixed several small bugs for `Console.restricted_input()` regarding the ANSI formatting of the input prompt and the input text in the console
2423
* completely rewrote `Console.restricted_input()`, so now it's actually usable, and renamed it to just `Console.input()`
2524
* removed method `Console.pwd_input()`, since you can now simply use `Console.input(mask_char="*")` instead, which does the exact same thing
2625
* removed the CLI command `xx-help`, since it was redundant because there's already the CLI command `xulbux-help`
2726
* removed the `xx_` from all the library modules since it's redundant, and without it the imports look more professional and cleaner
2827
* renamed the previously internal module `_consts_` to `consts` and made it accessible via `from xulbux.base.consts import …`, since you should be able to use library constants without them being "internal"
28+
* the constants form inside the `consts` module are now all uppercase (*except the class methods*), to make clear that they're constants
2929
* removed the wildcard imports from the `__init__.py` file, so now you can only access the main classes directly with `from xulbux import …` and for the rest you have to import the specific module first
3030

3131
## 29.07.2025 `v1.7.3`

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ pip install --upgrade xulbux
3131

3232
<br>
3333

34+
## CLI Commands
35+
36+
When the library is installed, the following commands are available in the console:
37+
| Command | Description |
38+
| :--------------- | :----------------------------------------------- |
39+
| `xulbux-help` | shows some information about the library |
40+
41+
<br>
42+
3443
## Usage
3544

3645
Import the full library under the alias `xx`, so its constants, classes, methods, and types are accessible with `xx.CONSTANT.value`, `xx.Class.method()`, `xx.type()`:
@@ -39,12 +48,12 @@ import xulbux as xx
3948
```
4049
So you don't have to import the full library under an alias, you can also import only certain parts of the library's contents:
4150
```python
42-
# CONSTANTS
43-
from xulbux import COLOR, CHARS, ANSI
44-
# Classes
51+
# LIBRARY CONSTANTS
52+
from xulbux.base.consts import COLOR, CHARS, ANSI
53+
# Main Classes
4554
from xulbux import Code, Color, Console, ...
46-
# types
47-
from xulbux import rgba, hsla, hexa
55+
# module specific imports
56+
from xulbux.color import rgba, hsla, hexa
4857
```
4958

5059
<br>
@@ -71,26 +80,30 @@ from xulbux import rgba, hsla, hexa
7180

7281
## Example Usage
7382

74-
This is what it could look like using this library for a simple but very nice looking color converter:
83+
This is what it could look like using this library for a simple but ultra good-looking color converter:
7584
```python
76-
from xulbux import COLOR # CONSTANTS
77-
from xulbux import FormatCodes, Console # Classes
78-
from xulbux import hexa # types
85+
from xulbux.base.consts import COLOR, CHARS
86+
from xulbux.color import hexa
87+
from xulbux import Console
7988

8089

8190
def main() -> None:
8291

8392
# LET THE USER ENTER A HEXA COLOR IN ANY HEXA FORMAT
84-
input_clr = FormatCodes.input(
85-
"\n[b](Enter a HEXA color in any format) [dim](>) "
93+
input_clr = Console.input(
94+
"[b](Enter a HEXA color in any format) > ",
95+
start="\n",
96+
placeholder="#7075FF",
97+
max_len=7,
98+
allowed_chars=CHARS.HEX_DIGITS,
8699
)
87100

88101
# ANNOUNCE INDEXING THE INPUT COLOR
89102
Console.log(
90103
"INDEX",
91104
"Indexing the input HEXA color...",
92105
start="\n",
93-
title_bg_color=COLOR.blue,
106+
title_bg_color=COLOR.BLUE,
94107
)
95108

96109
try:
@@ -109,7 +122,7 @@ def main() -> None:
109122
Console.log(
110123
"CONVERT",
111124
"Converting the HEXA color into different types...",
112-
title_bg_color=COLOR.tangerine,
125+
title_bg_color=COLOR.TANGERINE,
113126
)
114127

115128
# CONVERT THE HEXA COLOR INTO THE TWO OTHER COLOR TYPES

src/xulbux/_cli_.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
def help_command():
88
"""Show some info about the library, with a brief explanation of how to use it."""
99
color = {
10-
"class": COLOR.tangerine,
11-
"const": COLOR.red,
12-
"func": COLOR.cyan,
13-
"import": COLOR.neongreen,
14-
"lib": COLOR.orange,
15-
"punctuators": COLOR.darkgray,
16-
"code_border": COLOR.gray,
10+
"class": COLOR.TANGERINE,
11+
"const": COLOR.RED,
12+
"func": COLOR.CYAN,
13+
"import": COLOR.NEON_GREEN,
14+
"lib": COLOR.ORANGE,
15+
"punctuators": COLOR.DARK_GRAY,
16+
"code_border": COLOR.GRAY,
1717
}
1818
FormatCodes.print(
1919
rf""" [_|b|#7075FF] __ __
2020
[b|#7075FF] _ __ __ __/ / / /_ __ ___ __
2121
[b|#7075FF] | |/ // / / / / / __ \/ / / | |/ /
2222
[b|#7075FF] > , </ /_/ / /_/ /_/ / /_/ /> , <
23-
[b|#7075FF]/_/|_|\____/\__/\____/\____//_/|_| [*|BG:{COLOR.gray}|#000] v[b]{__version__} [*]
23+
[b|#7075FF]/_/|_|\____/\__/\____/\____//_/|_| [*|BG:{COLOR.GRAY}|#000] v[b]{__version__} [*]
2424
25-
[i|{COLOR.coral}]A TON OF COOL FUNCTIONS, YOU NEED![*]
25+
[i|{COLOR.CORAL}]A TON OF COOL FUNCTIONS, YOU NEED![*]
2626
2727
[b|#FCFCFF]Usage:[*]
2828
[dim|{color['code_border']}](╭────────────────────────────────────────────────────╮)
29-
[dim|{color['code_border']}](│) [{color['punctuators']}]# CONSTANTS[*] [dim|{color['code_border']}](│)
30-
[dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['const']}]COLOR[{color['punctuators']}], [{color['const']}]CHARS[{color['punctuators']}], [{color['const']}]ANSI[*] [dim|{color['code_border']}](│)
31-
[dim|{color['code_border']}](│) [{color['punctuators']}]# Classes[*] [dim|{color['code_border']}](│)
29+
[dim|{color['code_border']}](│) [{color['punctuators']}]# LIBRARY CONSTANTS[*] [dim|{color['code_border']}](│)
30+
[dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux[{color['punctuators']}].[{color['lib']}]base[{color['punctuators']}].[{color['lib']}]consts [{color['import']}]import [{color['const']}]COLOR[{color['punctuators']}], [{color['const']}]CHARS[{color['punctuators']}], [{color['const']}]ANSI[*] [dim|{color['code_border']}](│)
31+
[dim|{color['code_border']}](│) [{color['punctuators']}]# Main Classes[*] [dim|{color['code_border']}](│)
3232
[dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['class']}]Code[{color['punctuators']}], [{color['class']}]Color[{color['punctuators']}], [{color['class']}]Console[{color['punctuators']}], ...[*] [dim|{color['code_border']}](│)
33-
[dim|{color['code_border']}](│) [{color['punctuators']}]# types[*] [dim|{color['code_border']}](│)
34-
[dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['func']}]rgba[{color['punctuators']}], [{color['func']}]hsla[{color['punctuators']}], [{color['func']}]hexa[*] [dim|{color['code_border']}](│)
33+
[dim|{color['code_border']}](│) [{color['punctuators']}]# module specific imports[*] [dim|{color['code_border']}](│)
34+
[dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux[{color['punctuators']}].[{color['lib']}]color [{color['import']}]import [{color['func']}]rgba[{color['punctuators']}], [{color['func']}]hsla[{color['punctuators']}], [{color['func']}]hexa[*] [dim|{color['code_border']}](│)
3535
[dim|{color['code_border']}](╰────────────────────────────────────────────────────╯)
3636
[b|#FCFCFF]Documentation:[*]
3737
[dim|{color['code_border']}](╭────────────────────────────────────────────────────╮)
@@ -40,7 +40,6 @@ def help_command():
4040
[dim|{color['code_border']}](╰────────────────────────────────────────────────────╯)
4141
[_]
4242
[dim](Press any key to exit...)
43-
""",
44-
default_color=COLOR.text
43+
"""
4544
)
4645
Console.pause_exit(pause=True)

src/xulbux/base/consts.py

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,83 @@
1-
from dataclasses import dataclass
21
from typing import TypeAlias
32

43

54
FormattableString: TypeAlias = str
65
"""A `str` object that is made to be formatted with the `.format()` method."""
76

87

9-
@dataclass
108
class COLOR:
11-
"""Color presets used in the `xulbux` library."""
12-
13-
text = "#A5D6FF"
14-
"""The default text color used in the `xulbux` library."""
15-
16-
white = "#F1F2FF"
17-
lightgray = "#B6B7C0"
18-
gray = "#7B7C8D"
19-
darkgray = "#67686C"
20-
black = "#202125"
21-
red = "#FF606A"
22-
coral = "#FF7069"
23-
orange = "#FF876A"
24-
tangerine = "#FF9962"
25-
gold = "#FFAF60"
26-
yellow = "#FFD260"
27-
lime = "#C9F16E"
28-
green = "#7EE787"
29-
neongreen = "#4CFF85"
30-
teal = "#50EAAF"
31-
cyan = "#3EDEE6"
32-
ice = "#77DBEF"
33-
lightblue = "#60AAFF"
34-
blue = "#8085FF"
35-
lavender = "#9B7DFF"
36-
purple = "#AD68FF"
37-
magenta = "#C860FF"
38-
pink = "#F162EF"
39-
rose = "#FF609F"
40-
41-
42-
class _AllTextCharacters:
43-
pass
44-
45-
46-
@dataclass
9+
"""Hexa color presets."""
10+
11+
WHITE = "#F1F2FF"
12+
LIGHT_GRAY = "#B6B7C0"
13+
GRAY = "#7B7C8D"
14+
DARK_GRAY = "#67686C"
15+
BLACK = "#202125"
16+
RED = "#FF606A"
17+
CORAL = "#FF7069"
18+
ORANGE = "#FF876A"
19+
TANGERINE = "#FF9962"
20+
GOLD = "#FFAF60"
21+
YELLOW = "#FFD260"
22+
LIME = "#C9F16E"
23+
GREEN = "#7EE787"
24+
NEON_GREEN = "#4CFF85"
25+
TEAL = "#50EAAF"
26+
CYAN = "#3EDEE6"
27+
ICE = "#77DBEF"
28+
LIGHT_BLUE = "#60AAFF"
29+
BLUE = "#8085FF"
30+
LAVENDER = "#9B7DFF"
31+
PURPLE = "#AD68FF"
32+
MAGENTA = "#C860FF"
33+
PINK = "#F162EF"
34+
ROSE = "#FF609F"
35+
36+
4737
class CHARS:
4838
"""Text character sets."""
4939

50-
all = _AllTextCharacters
40+
class _AllTextChars:
41+
pass
42+
43+
ALL = _AllTextChars
5144
"""Code to signal that all characters are allowed."""
5245

53-
digits: str = "0123456789"
46+
DIGITS = "0123456789"
5447
"""Digits: `0`-`9`"""
55-
float_digits: str = digits + "."
48+
FLOAT_DIGITS = DIGITS + "."
5649
"""Digits: `0`-`9` with decimal point `.`"""
57-
hex_digits: str = digits + "#abcdefABCDEF"
50+
HEX_DIGITS = DIGITS + "#abcdefABCDEF"
5851
"""Digits: `0`-`9` Letters: `a`-`f` `A`-`F` and a hashtag `#`"""
5952

60-
lowercase: str = "abcdefghijklmnopqrstuvwxyz"
53+
LOWERCASE = "abcdefghijklmnopqrstuvwxyz"
6154
"""Lowercase letters `a`-`z`"""
62-
lowercase_extended: str = lowercase + "äëïöüÿàèìòùáéíóúýâêîôûãñõåæç"
55+
LOWERCASE_EXTENDED = LOWERCASE + "äëïöüÿàèìòùáéíóúýâêîôûãñõåæç"
6356
"""Lowercase letters `a`-`z` with all lowercase diacritic letters."""
64-
uppercase: str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
57+
UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
6558
"""Uppercase letters `A`-`Z`"""
66-
uppercase_extended: str = uppercase + "ÄËÏÖÜÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÅÆÇß"
59+
UPPERCASE_EXTENDED = UPPERCASE + "ÄËÏÖÜÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÅÆÇß"
6760
"""Uppercase letters `A`-`Z` with all uppercase diacritic letters."""
6861

69-
letters: str = lowercase + uppercase
62+
LETTERS = LOWERCASE + UPPERCASE
7063
"""Lowercase and uppercase letters `a`-`z` and `A`-`Z`"""
71-
letters_extended: str = lowercase_extended + uppercase_extended
64+
LETTERS_EXTENDED = LOWERCASE_EXTENDED + UPPERCASE_EXTENDED
7265
"""Lowercase and uppercase letters `a`-`z` `A`-`Z` and all diacritic letters."""
7366

74-
special_ascii: str = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
67+
SPECIAL_ASCII = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
7568
"""All ASCII special characters."""
76-
special_ascii_extended: str = special_ascii + "ø£Ø×ƒªº¿®¬½¼¡«»░▒▓│┤©╣║╗╝¢¥┐└┴┬├─┼╚╔╩╦╠═╬¤ðÐı┘┌█▄¦▀µþÞ¯´≡­±‗¾¶§÷¸°¨·¹³²■ "
69+
SPECIAL_ASCII_EXTENDED = SPECIAL_ASCII + "ø£Ø×ƒªº¿®¬½¼¡«»░▒▓│┤©╣║╗╝¢¥┐└┴┬├─┼╚╔╩╦╠═╬¤ðÐı┘┌█▄¦▀µþÞ¯´≡­±‗¾¶§÷¸°¨·¹³²■ "
7770
"""All ASCII special characters with the extended ASCII special characters."""
78-
standard_ascii: str = special_ascii + digits + letters
71+
STANDARD_ASCII = SPECIAL_ASCII + DIGITS + LETTERS
7972
"""All standard ASCII characters."""
80-
full_ascii: str = special_ascii_extended + digits + letters_extended
73+
FULL_ASCII = SPECIAL_ASCII_EXTENDED + DIGITS + LETTERS_EXTENDED
8174
"""All characters in the ASCII table."""
8275

8376

8477
class ANSI:
85-
"""Constants and class-methods for use of ANSI escape codes."""
78+
"""Constants and methods for use of ANSI escape codes"""
8679

87-
escaped_char: str = "\\x1b"
80+
ESCAPED_CHAR = "\\x1b"
8881
"""The printable ANSI escape character."""
8982
CHAR = char = "\x1b"
9083
"""The ANSI escape character."""
@@ -100,12 +93,12 @@ def seq(cls, parts: int = 1) -> FormattableString:
10093
"""Generate an ANSI sequence with `parts` amount of placeholders."""
10194
return cls.CHAR + cls.START + cls.SEP.join(["{}" for _ in range(parts)]) + cls.END
10295

103-
seq_color: FormattableString = CHAR + START + "38" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
96+
SEQ_COLOR: FormattableString = CHAR + START + "38" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
10497
"""The ANSI escape sequence for setting the text RGB color."""
105-
seq_bg_color: FormattableString = CHAR + START + "48" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
98+
SEQ_BG_COLOR: FormattableString = CHAR + START + "48" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
10699
"""The ANSI escape sequence for setting the background RGB color."""
107100

108-
color_map: tuple[str, ...] = (
101+
COLOR_MAP: tuple[str, ...] = (
109102
########### DEFAULT CONSOLE COLOR NAMES ############
110103
"black",
111104
"red",
@@ -118,7 +111,7 @@ def seq(cls, parts: int = 1) -> FormattableString:
118111
)
119112
"""The console default color names."""
120113

121-
codes_map: dict[str | tuple[str, ...], int] = {
114+
CODES_MAP: dict[str | tuple[str, ...], int] = {
122115
################# SPECIFIC RESETS ##################
123116
"_": 0,
124117
("_bold", "_b"): 22,

0 commit comments

Comments
 (0)