xulbux 1.8.0__tar.gz → 1.8.2__tar.gz

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.

Files changed (39) hide show
  1. {xulbux-1.8.0/src/xulbux.egg-info → xulbux-1.8.2}/PKG-INFO +2 -2
  2. {xulbux-1.8.0 → xulbux-1.8.2}/pyproject.toml +7 -3
  3. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/__init__.py +17 -2
  4. xulbux-1.8.2/src/xulbux/base/consts.py +173 -0
  5. xulbux-1.8.2/src/xulbux/cli/help.py +73 -0
  6. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/color.py +12 -0
  7. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/console.py +327 -23
  8. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/format_codes.py +4 -3
  9. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/system.py +1 -1
  10. {xulbux-1.8.0 → xulbux-1.8.2/src/xulbux.egg-info}/PKG-INFO +2 -2
  11. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux.egg-info/SOURCES.txt +5 -2
  12. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_console.py +389 -2
  13. xulbux-1.8.2/tests/test_regex.py +305 -0
  14. xulbux-1.8.2/tests/test_system.py +87 -0
  15. xulbux-1.8.0/LICENSE +0 -21
  16. {xulbux-1.8.0 → xulbux-1.8.2}/README.md +0 -0
  17. {xulbux-1.8.0 → xulbux-1.8.2}/setup.cfg +0 -0
  18. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/code.py +0 -0
  19. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/data.py +0 -0
  20. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/env_path.py +0 -0
  21. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/file.py +0 -0
  22. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/json.py +0 -0
  23. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/path.py +0 -0
  24. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/regex.py +0 -0
  25. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux/string.py +0 -0
  26. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux.egg-info/dependency_links.txt +0 -0
  27. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux.egg-info/entry_points.txt +0 -0
  28. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux.egg-info/requires.txt +0 -0
  29. {xulbux-1.8.0 → xulbux-1.8.2}/src/xulbux.egg-info/top_level.txt +0 -0
  30. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_code.py +0 -0
  31. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_color.py +0 -0
  32. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_color_types.py +0 -0
  33. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_data.py +0 -0
  34. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_env_path.py +0 -0
  35. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_file.py +0 -0
  36. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_format_codes.py +0 -0
  37. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_json.py +0 -0
  38. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_path.py +0 -0
  39. {xulbux-1.8.0 → xulbux-1.8.2}/tests/test_string.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xulbux
3
- Version: 1.8.0
4
- Summary: A Python library which includes lots of helpful classes, types and functions aiming to make common programming tasks simpler.
3
+ Version: 1.8.2
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
  Maintainer-email: XulbuX <xulbux.real@gmail.com>
7
7
  License-Expression: MIT
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xulbux"
7
- version = "1.8.0"
7
+ version = "1.8.2"
8
8
  authors = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
9
9
  maintainers = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
10
- description = "A Python library which includes lots of helpful classes, types and functions aiming to make common programming tasks simpler."
10
+ description = "A Python library which includes lots of helpful classes, types, and functions aiming to make common programming tasks simpler."
11
11
  readme = "README.md"
12
12
  license = "MIT"
13
13
  license-files = ["LICEN[CS]E.*"]
@@ -143,9 +143,11 @@ extend-ignore = ["E203", "E266", "W503"]
143
143
  per-file-ignores = ["__init__.py:F403,F405"]
144
144
 
145
145
  [tool.setuptools]
146
- packages = ["xulbux"]
147
146
  package-dir = { "" = "src" }
148
147
 
148
+ [tool.setuptools.packages.find]
149
+ where = ["src"]
150
+
149
151
  [tool.pytest.ini_options]
150
152
  minversion = "7.0"
151
153
  addopts = "-ra -q"
@@ -161,5 +163,7 @@ testpaths = [
161
163
  "tests/test_format_codes.py",
162
164
  "tests/test_json.py",
163
165
  "tests/test_path.py",
166
+ "tests/test_regex.py",
164
167
  "tests/test_string.py",
168
+ "tests/test_system.py",
165
169
  ]
@@ -1,4 +1,4 @@
1
- __version__ = "1.8.0"
1
+ __version__ = "1.8.2"
2
2
 
3
3
  __author__ = "XulbuX"
4
4
  __email__ = "xulbux.real@gmail.com"
@@ -7,11 +7,26 @@ __copyright__ = "Copyright (c) 2024 XulbuX"
7
7
  __url__ = "https://github.com/XulbuX/PythonLibraryXulbuX"
8
8
  __description__ = "A Python library which includes lots of helpful classes, types, and functions aiming to make common programming tasks simpler."
9
9
 
10
- __all__ = ["Code", "Color", "Console", "Data", "EnvPath", "File", "FormatCodes", "Json", "Path", "Regex", "String", "System"]
10
+ __all__ = [
11
+ "Code",
12
+ "Color",
13
+ "Console",
14
+ "Data",
15
+ "EnvPath",
16
+ "File",
17
+ "FormatCodes",
18
+ "Json",
19
+ "Path",
20
+ "ProgressBar",
21
+ "Regex",
22
+ "String",
23
+ "System",
24
+ ]
11
25
 
12
26
  from .code import Code
13
27
  from .color import Color
14
28
  from .console import Console
29
+ from .console import ProgressBar
15
30
  from .data import Data
16
31
  from .env_path import EnvPath
17
32
  from .file import File
@@ -0,0 +1,173 @@
1
+ from typing import TypeAlias
2
+
3
+
4
+ FormattableString: TypeAlias = str
5
+ """A `str` object that is made to be formatted with the `.format()` method."""
6
+
7
+
8
+ class COLOR:
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
+
37
+ class CHARS:
38
+ """Text character sets."""
39
+
40
+ class _AllTextChars:
41
+ pass
42
+
43
+ ALL = _AllTextChars
44
+ """Code to signal that all characters are allowed."""
45
+
46
+ DIGITS = "0123456789"
47
+ """Digits: `0`-`9`"""
48
+ FLOAT_DIGITS = DIGITS + "."
49
+ """Digits: `0`-`9` with decimal point `.`"""
50
+ HEX_DIGITS = DIGITS + "#abcdefABCDEF"
51
+ """Digits: `0`-`9` Letters: `a`-`f` `A`-`F` and a hashtag `#`"""
52
+
53
+ LOWERCASE = "abcdefghijklmnopqrstuvwxyz"
54
+ """Lowercase letters `a`-`z`"""
55
+ LOWERCASE_EXTENDED = LOWERCASE + "äëïöüÿàèìòùáéíóúýâêîôûãñõåæç"
56
+ """Lowercase letters `a`-`z` with all lowercase diacritic letters."""
57
+ UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
58
+ """Uppercase letters `A`-`Z`"""
59
+ UPPERCASE_EXTENDED = UPPERCASE + "ÄËÏÖÜÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÅÆÇß"
60
+ """Uppercase letters `A`-`Z` with all uppercase diacritic letters."""
61
+
62
+ LETTERS = LOWERCASE + UPPERCASE
63
+ """Lowercase and uppercase letters `a`-`z` and `A`-`Z`"""
64
+ LETTERS_EXTENDED = LOWERCASE_EXTENDED + UPPERCASE_EXTENDED
65
+ """Lowercase and uppercase letters `a`-`z` `A`-`Z` and all diacritic letters."""
66
+
67
+ SPECIAL_ASCII = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
68
+ """All ASCII special characters."""
69
+ SPECIAL_ASCII_EXTENDED = SPECIAL_ASCII + "ø£Ø×ƒªº¿®¬½¼¡«»░▒▓│┤©╣║╗╝¢¥┐└┴┬├─┼╚╔╩╦╠═╬¤ðÐı┘┌█▄¦▀µþÞ¯´≡­±‗¾¶§÷¸°¨·¹³²■ "
70
+ """All ASCII special characters with the extended ASCII special characters."""
71
+ STANDARD_ASCII = SPECIAL_ASCII + DIGITS + LETTERS
72
+ """All standard ASCII characters."""
73
+ FULL_ASCII = SPECIAL_ASCII_EXTENDED + DIGITS + LETTERS_EXTENDED
74
+ """All characters in the ASCII table."""
75
+
76
+
77
+ class ANSI:
78
+ """Constants and methods for use of ANSI escape codes"""
79
+
80
+ ESCAPED_CHAR = "\\x1b"
81
+ """The printable ANSI escape character."""
82
+ CHAR = char = "\x1b"
83
+ """The ANSI escape character."""
84
+ START = start = "["
85
+ """The start of an ANSI escape sequence."""
86
+ SEP = sep = ";"
87
+ """The separator between ANSI escape sequence parts."""
88
+ END = end = "m"
89
+ """The end of an ANSI escape sequence."""
90
+
91
+ @classmethod
92
+ def seq(cls, parts: int = 1) -> FormattableString:
93
+ """Generate an ANSI sequence with `parts` amount of placeholders."""
94
+ return cls.CHAR + cls.START + cls.SEP.join(["{}" for _ in range(parts)]) + cls.END
95
+
96
+ SEQ_COLOR: FormattableString = CHAR + START + "38" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
97
+ """The ANSI escape sequence for setting the text RGB color."""
98
+ SEQ_BG_COLOR: FormattableString = CHAR + START + "48" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
99
+ """The ANSI escape sequence for setting the background RGB color."""
100
+
101
+ COLOR_MAP: tuple[str, ...] = (
102
+ ########### DEFAULT CONSOLE COLOR NAMES ############
103
+ "black",
104
+ "red",
105
+ "green",
106
+ "yellow",
107
+ "blue",
108
+ "magenta",
109
+ "cyan",
110
+ "white",
111
+ )
112
+ """The console default color names."""
113
+
114
+ CODES_MAP: dict[str | tuple[str, ...], int] = {
115
+ ################# SPECIFIC RESETS ##################
116
+ "_": 0,
117
+ ("_bold", "_b"): 22,
118
+ ("_dim", "_d"): 22,
119
+ ("_italic", "_i"): 23,
120
+ ("_underline", "_u"): 24,
121
+ ("_double-underline", "_du"): 24,
122
+ ("_inverse", "_invert", "_in"): 27,
123
+ ("_hidden", "_hide", "_h"): 28,
124
+ ("_strikethrough", "_s"): 29,
125
+ ("_color", "_c"): 39,
126
+ ("_background", "_bg"): 49,
127
+ ################### TEXT STYLES ####################
128
+ ("bold", "b"): 1,
129
+ ("dim", "d"): 2,
130
+ ("italic", "i"): 3,
131
+ ("underline", "u"): 4,
132
+ ("inverse", "invert", "in"): 7,
133
+ ("hidden", "hide", "h"): 8,
134
+ ("strikethrough", "s"): 9,
135
+ ("double-underline", "du"): 21,
136
+ ################## DEFAULT COLORS ##################
137
+ "black": 30,
138
+ "red": 31,
139
+ "green": 32,
140
+ "yellow": 33,
141
+ "blue": 34,
142
+ "magenta": 35,
143
+ "cyan": 36,
144
+ "white": 37,
145
+ ############## BRIGHT DEFAULT COLORS ###############
146
+ "br:black": 90,
147
+ "br:red": 91,
148
+ "br:green": 92,
149
+ "br:yellow": 93,
150
+ "br:blue": 94,
151
+ "br:magenta": 95,
152
+ "br:cyan": 96,
153
+ "br:white": 97,
154
+ ############ DEFAULT BACKGROUND COLORS #############
155
+ "bg:black": 40,
156
+ "bg:red": 41,
157
+ "bg:green": 42,
158
+ "bg:yellow": 43,
159
+ "bg:blue": 44,
160
+ "bg:magenta": 45,
161
+ "bg:cyan": 46,
162
+ "bg:white": 47,
163
+ ######### BRIGHT DEFAULT BACKGROUND COLORS #########
164
+ "bg:br:black": 100,
165
+ "bg:br:red": 101,
166
+ "bg:br:green": 102,
167
+ "bg:br:yellow": 103,
168
+ "bg:br:blue": 104,
169
+ "bg:br:magenta": 105,
170
+ "bg:br:cyan": 106,
171
+ "bg:br:white": 107,
172
+ }
173
+ """All custom format keys and their corresponding ANSI format number codes."""
@@ -0,0 +1,73 @@
1
+ from .. import __version__
2
+ from ..base.consts import COLOR
3
+ from ..format_codes import FormatCodes
4
+ from ..console import Console
5
+
6
+ from urllib.error import HTTPError
7
+ from typing import Optional
8
+ import urllib.request as _request
9
+ import json as _json
10
+
11
+
12
+ def get_latest_version() -> Optional[str]:
13
+ with _request.urlopen(URL) as response:
14
+ if response.status == 200:
15
+ data = _json.load(response)
16
+ return data["info"]["version"]
17
+ else:
18
+ raise HTTPError(URL, response.status, "Failed to fetch latest version info", response.headers, None)
19
+
20
+
21
+ def is_latest_version() -> Optional[bool]:
22
+ try:
23
+ latest = get_latest_version()
24
+ if latest in ("", None): return None
25
+ latest_v_parts = tuple(int(part) for part in latest.lower().lstrip("v").split('.'))
26
+ installed_v_parts = tuple(int(part) for part in __version__.lower().lstrip("v").split('.'))
27
+ return latest_v_parts <= installed_v_parts
28
+ except Exception:
29
+ return None
30
+
31
+
32
+ URL = "https://pypi.org/pypi/xulbux/json"
33
+ IS_LATEST_VERSION = is_latest_version()
34
+ CLR = {
35
+ "class": COLOR.TANGERINE,
36
+ "code_border": COLOR.GRAY,
37
+ "const": COLOR.RED,
38
+ "func": COLOR.CYAN,
39
+ "import": COLOR.NEON_GREEN,
40
+ "lib": COLOR.ORANGE,
41
+ "notice": COLOR.YELLOW,
42
+ "punctuators": COLOR.DARK_GRAY,
43
+ }
44
+ HELP = FormatCodes.to_ansi(
45
+ rf""" [_|b|#7075FF] __ __
46
+ [b|#7075FF] _ __ __ __/ / / /_ __ ___ __
47
+ [b|#7075FF] | |/ // / / / / / __ \/ / / | |/ /
48
+ [b|#7075FF] > , </ /_/ / /_/ /_/ / /_/ /> , <
49
+ [b|#7075FF]/_/|_|\____/\__/\____/\____//_/|_| [*|BG:{COLOR.GRAY}|#000] v[b]{__version__} [*|dim|{CLR['notice']}]({'' if IS_LATEST_VERSION else ' (newer available)'})[*]
50
+
51
+ [i|{COLOR.CORAL}]A TON OF COOL FUNCTIONS, YOU NEED![*]
52
+
53
+ [b|#FCFCFF]Usage:[*]
54
+ [dim|{CLR['code_border']}](╭────────────────────────────────────────────────────╮)
55
+ [dim|{CLR['code_border']}](│) [{CLR['punctuators']}]# LIBRARY CONSTANTS[*] [dim|{CLR['code_border']}](│)
56
+ [dim|{CLR['code_border']}](│) [{CLR['import']}]from [{CLR['lib']}]xulbux[{CLR['punctuators']}].[{CLR['lib']}]base[{CLR['punctuators']}].[{CLR['lib']}]consts [{CLR['import']}]import [{CLR['const']}]COLOR[{CLR['punctuators']}], [{CLR['const']}]CHARS[{CLR['punctuators']}], [{CLR['const']}]ANSI[*] [dim|{CLR['code_border']}](│)
57
+ [dim|{CLR['code_border']}](│) [{CLR['punctuators']}]# Main Classes[*] [dim|{CLR['code_border']}](│)
58
+ [dim|{CLR['code_border']}](│) [{CLR['import']}]from [{CLR['lib']}]xulbux [{CLR['import']}]import [{CLR['class']}]Code[{CLR['punctuators']}], [{CLR['class']}]Color[{CLR['punctuators']}], [{CLR['class']}]Console[{CLR['punctuators']}], ...[*] [dim|{CLR['code_border']}](│)
59
+ [dim|{CLR['code_border']}](│) [{CLR['punctuators']}]# module specific imports[*] [dim|{CLR['code_border']}](│)
60
+ [dim|{CLR['code_border']}](│) [{CLR['import']}]from [{CLR['lib']}]xulbux[{CLR['punctuators']}].[{CLR['lib']}]color [{CLR['import']}]import [{CLR['func']}]rgba[{CLR['punctuators']}], [{CLR['func']}]hsla[{CLR['punctuators']}], [{CLR['func']}]hexa[*] [dim|{CLR['code_border']}](│)
61
+ [dim|{CLR['code_border']}](╰────────────────────────────────────────────────────╯)
62
+ [b|#FCFCFF]Documentation:[*]
63
+ [dim|{CLR['code_border']}](╭────────────────────────────────────────────────────╮)
64
+ [dim|{CLR['code_border']}](│) [#DADADD]For more information see the GitHub page. [dim|{CLR['code_border']}](│)
65
+ [dim|{CLR['code_border']}](│) [u|#8085FF](https://github.com/XulbuX/PythonLibraryXulbuX/wiki) [dim|{CLR['code_border']}](│)
66
+ [dim|{CLR['code_border']}](╰────────────────────────────────────────────────────╯)
67
+ [_]"""
68
+ )
69
+
70
+
71
+ def show_help() -> None:
72
+ print(HELP)
73
+ Console.pause_exit(pause=True, prompt=" [dim](Press any key to exit...)\n\n")
@@ -92,9 +92,13 @@ class rgba:
92
92
 
93
93
  def __init__(self, r: int, g: int, b: int, a: Optional[float] = None, _validate: bool = True):
94
94
  self.r: int
95
+ """The red channel (`0`–`255`)"""
95
96
  self.g: int
97
+ """The green channel (`0`–`255`)"""
96
98
  self.b: int
99
+ """The blue channel (`0`–`255`)"""
97
100
  self.a: Optional[float]
101
+ """The alpha channel (`0.0`–`1.0`) or `None` if not set"""
98
102
  if not _validate:
99
103
  self.r, self.g, self.b, self.a = r, g, b, a
100
104
  return
@@ -291,9 +295,13 @@ class hsla:
291
295
 
292
296
  def __init__(self, h: int, s: int, l: int, a: Optional[float] = None, _validate: bool = True):
293
297
  self.h: int
298
+ """The hue channel (`0`–`360`)"""
294
299
  self.s: int
300
+ """The saturation channel (`0`–`100`)"""
295
301
  self.l: int
302
+ """The lightness channel (`0`–`100`)"""
296
303
  self.a: Optional[float]
304
+ """The alpha channel (`0.0`–`1.0`) or `None` if not set"""
297
305
  if not _validate:
298
306
  self.h, self.s, self.l, self.a = h, s, l, a
299
307
  return
@@ -496,9 +504,13 @@ class hexa:
496
504
  _a: Optional[float] = None,
497
505
  ):
498
506
  self.r: int
507
+ """The red channel (`0`–`255`)"""
499
508
  self.g: int
509
+ """The green channel (`0`–`255`)"""
500
510
  self.b: int
511
+ """The blue channel (`0`–`255`)"""
501
512
  self.a: Optional[float]
513
+ """The alpha channel (`0.0`–`1.0`) or `None` if not set"""
502
514
  if all(x is not None for x in (_r, _g, _b)):
503
515
  self.r, self.g, self.b, self.a = cast(int, _r), cast(int, _g), cast(int, _b), _a
504
516
  return