xulbux 1.6.5__py3-none-any.whl → 1.6.7__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/_cli_.py +9 -9
- xulbux/_consts_.py +98 -62
- xulbux/xx_code.py +37 -42
- xulbux/xx_color.py +27 -55
- xulbux/xx_console.py +205 -110
- xulbux/xx_data.py +176 -128
- xulbux/xx_env_path.py +3 -7
- xulbux/xx_file.py +10 -4
- xulbux/xx_format_codes.py +26 -37
- xulbux/xx_json.py +2 -5
- xulbux/xx_path.py +33 -23
- xulbux/xx_regex.py +18 -20
- xulbux/xx_string.py +23 -76
- xulbux/xx_system.py +16 -19
- {xulbux-1.6.5.dist-info → xulbux-1.6.7.dist-info}/METADATA +92 -13
- xulbux-1.6.7.dist-info/RECORD +21 -0
- {xulbux-1.6.5.dist-info → xulbux-1.6.7.dist-info}/WHEEL +1 -1
- xulbux-1.6.5.dist-info/RECORD +0 -21
- {xulbux-1.6.5.dist-info → xulbux-1.6.7.dist-info}/LICENSE +0 -0
- {xulbux-1.6.5.dist-info → xulbux-1.6.7.dist-info}/entry_points.txt +0 -0
- {xulbux-1.6.5.dist-info → xulbux-1.6.7.dist-info}/top_level.txt +0 -0
xulbux/xx_json.py
CHANGED
|
@@ -91,11 +91,8 @@ class Json:
|
|
|
91
91
|
from `comment_start` to `comment_end` is ignored."""
|
|
92
92
|
if isinstance(update_values, str):
|
|
93
93
|
update_values = [update_values]
|
|
94
|
-
valid_entries = [
|
|
95
|
-
|
|
96
|
-
for update_value in update_values
|
|
97
|
-
if len(parts := update_value.split(str(sep[1]).strip())) == 2
|
|
98
|
-
]
|
|
94
|
+
valid_entries = [(parts[0].strip(), parts[1]) for update_value in update_values
|
|
95
|
+
if len(parts := update_value.split(str(sep[1]).strip())) == 2]
|
|
99
96
|
value_paths, new_values = zip(*valid_entries) if valid_entries else ([], [])
|
|
100
97
|
processed_data, data = Json.read(json_file, comment_start, comment_end, return_original=True)
|
|
101
98
|
update = []
|
xulbux/xx_path.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from typing import Optional
|
|
1
2
|
import tempfile as _tempfile
|
|
2
3
|
import difflib as _difflib
|
|
3
4
|
import shutil as _shutil
|
|
@@ -5,35 +6,44 @@ import sys as _sys
|
|
|
5
6
|
import os as _os
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
# YAPF: disable
|
|
10
|
+
class ProcessNotFoundError(Exception):
|
|
11
|
+
pass
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
class _Cwd:
|
|
14
|
+
def __get__(self, obj, owner=None):
|
|
15
|
+
return _os.getcwd()
|
|
16
|
+
|
|
17
|
+
class _ScriptDir:
|
|
18
|
+
def __get__(self, obj, owner=None):
|
|
19
|
+
if getattr(_sys, "frozen", False):
|
|
20
|
+
base_path = _os.path.dirname(_sys.executable)
|
|
21
|
+
else:
|
|
22
|
+
main_module = _sys.modules["__main__"]
|
|
23
|
+
if hasattr(main_module, "__file__"):
|
|
24
|
+
base_path = _os.path.dirname(_os.path.abspath(main_module.__file__))
|
|
25
|
+
elif (hasattr(main_module, "__spec__") and main_module.__spec__
|
|
26
|
+
and getattr(main_module.__spec__, "origin", None)):
|
|
27
|
+
base_path = _os.path.dirname(_os.path.abspath(main_module.__spec__.origin))
|
|
18
28
|
else:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
raise RuntimeError("Can only get base directory if accessed from a file.")
|
|
30
|
+
return base_path
|
|
31
|
+
# YAPF: enable
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Path:
|
|
35
|
+
|
|
36
|
+
cwd: str = _Cwd()
|
|
37
|
+
"""The path to the current working directory."""
|
|
38
|
+
script_dir: str = _ScriptDir()
|
|
39
|
+
"""The path to the directory of the current script."""
|
|
30
40
|
|
|
31
41
|
@staticmethod
|
|
32
42
|
def extend(path: str, search_in: str | list[str] = None, raise_error: bool = False, correct_path: bool = False) -> str:
|
|
33
43
|
if path in (None, ""):
|
|
34
44
|
return path
|
|
35
45
|
|
|
36
|
-
def get_closest_match(dir: str, part: str) -> str
|
|
46
|
+
def get_closest_match(dir: str, part: str) -> Optional[str]:
|
|
37
47
|
try:
|
|
38
48
|
files_and_dirs = _os.listdir(dir)
|
|
39
49
|
matches = _difflib.get_close_matches(part, files_and_dirs, n=1, cutoff=0.6)
|
|
@@ -41,7 +51,7 @@ class Path:
|
|
|
41
51
|
except Exception:
|
|
42
52
|
return None
|
|
43
53
|
|
|
44
|
-
def find_path(start: str, parts: list[str]) -> str
|
|
54
|
+
def find_path(start: str, parts: list[str]) -> Optional[str]:
|
|
45
55
|
current = start
|
|
46
56
|
for part in parts:
|
|
47
57
|
if _os.path.isfile(current):
|
|
@@ -68,7 +78,7 @@ class Path:
|
|
|
68
78
|
search_dirs = (drive + _os.sep) if drive else [_os.sep]
|
|
69
79
|
else:
|
|
70
80
|
rel_path = path.lstrip(_os.sep)
|
|
71
|
-
base_dir = Path.
|
|
81
|
+
base_dir = Path.script_dir
|
|
72
82
|
search_dirs = (
|
|
73
83
|
_os.getcwd(),
|
|
74
84
|
base_dir,
|
xulbux/xx_regex.py
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
3
|
-
`quotes` match everything inside quotes
|
|
4
|
-
`brackets` match everything inside brackets
|
|
5
|
-
`outside_strings` match the pattern but not inside strings
|
|
6
|
-
`all_except` match everything except a certain pattern
|
|
7
|
-
`func_call` match a function call
|
|
8
|
-
`rgba_str` match an RGBA color
|
|
9
|
-
`hsla_str` match a HSLA color
|
|
2
|
+
Very useful and complicated (generated) regex patterns.
|
|
10
3
|
"""
|
|
11
4
|
|
|
12
5
|
import regex as _rx
|
|
@@ -27,24 +20,34 @@ class Regex:
|
|
|
27
20
|
return r'(?P<quote>[\'"])(?P<string>(?:\\.|(?!\g<quote>).)*?)\g<quote>'
|
|
28
21
|
|
|
29
22
|
@staticmethod
|
|
30
|
-
def brackets(
|
|
23
|
+
def brackets(
|
|
24
|
+
bracket1: str = "(",
|
|
25
|
+
bracket2: str = ")",
|
|
26
|
+
is_group: bool = False,
|
|
27
|
+
strip_spaces: bool = True,
|
|
28
|
+
ignore_in_strings: bool = True,
|
|
29
|
+
) -> str:
|
|
31
30
|
"""Matches everything inside brackets, including other nested brackets.\n
|
|
32
31
|
--------------------------------------------------------------------------------
|
|
33
32
|
If `is_group` is true, you will be able to reference the matched content as a
|
|
34
33
|
group (e.g. `match.group(…)` or `r'\\…'`).
|
|
34
|
+
If `strip_spaces` is true, it will ignore spaces around the content inside the
|
|
35
|
+
brackets.
|
|
35
36
|
If `ignore_in_strings` is true and a bracket is inside a string (e.g. `'...'`
|
|
36
37
|
or `"..."`), it will not be counted as the matching closing bracket.\n
|
|
37
38
|
--------------------------------------------------------------------------------
|
|
38
39
|
Attention: Requires non standard library `regex` not standard library `re`!"""
|
|
39
|
-
g, b1, b2 = (
|
|
40
|
+
g, b1, b2, s1, s2 = (
|
|
40
41
|
"" if is_group else "?:",
|
|
41
42
|
_rx.escape(bracket1) if len(bracket1) == 1 else bracket1,
|
|
42
43
|
_rx.escape(bracket2) if len(bracket2) == 1 else bracket2,
|
|
44
|
+
r"\s*" if strip_spaces else "",
|
|
45
|
+
"" if strip_spaces else r"\s*",
|
|
43
46
|
)
|
|
44
47
|
if ignore_in_strings:
|
|
45
|
-
return rf'{b1}
|
|
48
|
+
return rf'{b1}{s1}({g}{s2}(?:[^{b1}{b2}"\']|"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|{b1}(?:[^{b1}{b2}"\']|"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|(?R))*{b2})*{s2}){s1}{b2}'
|
|
46
49
|
else:
|
|
47
|
-
return rf"{b1}
|
|
50
|
+
return rf"{b1}{s1}({g}{s2}(?:[^{b1}{b2}]|{b1}(?:[^{b1}{b2}]|(?R))*{b2})*{s2}){s1}{b2}"
|
|
48
51
|
|
|
49
52
|
@staticmethod
|
|
50
53
|
def outside_strings(pattern: str = r".*") -> str:
|
|
@@ -109,9 +112,7 @@ class Regex:
|
|
|
109
112
|
rf"""(?ix)
|
|
110
113
|
(?:rgb|rgba)?\s*(?:\(?\s*{rgb_part}
|
|
111
114
|
(?:(?:\s*{fix_sep}\s*)((?:0*(?:0?\.[0-9]+|1\.0+|[0-9]+\.[0-9]+|[0-9]+))))?
|
|
112
|
-
\s*\)?)"""
|
|
113
|
-
if allow_alpha
|
|
114
|
-
else rf"(?ix)(?:rgb|rgba)?\s*(?:\(?\s*{rgb_part}\s*\)?)"
|
|
115
|
+
\s*\)?)""" if allow_alpha else rf"(?ix)(?:rgb|rgba)?\s*(?:\(?\s*{rgb_part}\s*\)?)"
|
|
115
116
|
)
|
|
116
117
|
|
|
117
118
|
@staticmethod
|
|
@@ -144,9 +145,7 @@ class Regex:
|
|
|
144
145
|
rf"""(?ix)
|
|
145
146
|
(?:hsl|hsla)?\s*(?:\(?\s*{hsl_part}
|
|
146
147
|
(?:(?:\s*{fix_sep}\s*)((?:0*(?:0?\.[0-9]+|1\.0+|[0-9]+\.[0-9]+|[0-9]+))))?
|
|
147
|
-
\s*\)?)"""
|
|
148
|
-
if allow_alpha
|
|
149
|
-
else rf"(?ix)(?:hsl|hsla)?\s*(?:\(?\s*{hsl_part}\s*\)?)"
|
|
148
|
+
\s*\)?)""" if allow_alpha else rf"(?ix)(?:hsl|hsla)?\s*(?:\(?\s*{hsl_part}\s*\)?)"
|
|
150
149
|
)
|
|
151
150
|
|
|
152
151
|
@staticmethod
|
|
@@ -162,6 +161,5 @@ class Regex:
|
|
|
162
161
|
every channel from 0-9 and A-F (case insensitive)"""
|
|
163
162
|
return (
|
|
164
163
|
r"(?i)^(?:#|0x)?[0-9A-F]{8}|[0-9A-F]{6}|[0-9A-F]{4}|[0-9A-F]{3}$"
|
|
165
|
-
if allow_alpha
|
|
166
|
-
else r"(?i)^(?:#|0x)?[0-9A-F]{6}|[0-9A-F]{3}$"
|
|
164
|
+
if allow_alpha else r"(?i)^(?:#|0x)?[0-9A-F]{6}|[0-9A-F]{3}$"
|
|
167
165
|
)
|
xulbux/xx_string.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import json as _json
|
|
2
|
+
import ast as _ast
|
|
1
3
|
import re as _re
|
|
2
4
|
|
|
3
5
|
|
|
@@ -5,73 +7,25 @@ class String:
|
|
|
5
7
|
|
|
6
8
|
@staticmethod
|
|
7
9
|
def to_type(string: str) -> any:
|
|
8
|
-
"""Will convert a string to the found type."""
|
|
9
|
-
string = string.strip()
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
elif _re.match(r"^-?\d+$", string):
|
|
18
|
-
return int(string)
|
|
19
|
-
# FLOAT
|
|
20
|
-
elif _re.match(r"^-?\d+\.\d+$", string):
|
|
21
|
-
return float(string)
|
|
22
|
-
# COMPLEX
|
|
23
|
-
elif _re.match(r"^(-?\d+(\.\d+)?[+-]\d+(\.\d+)?j)$", string):
|
|
24
|
-
return complex(string)
|
|
25
|
-
# QUOTED STRING
|
|
26
|
-
elif _re.match(r'^["\'](.*)["\']$', string):
|
|
27
|
-
return string[1:-1]
|
|
28
|
-
# BYTES
|
|
29
|
-
elif _re.match(r"^b['\"](.*)['\"]$", string):
|
|
30
|
-
return bytes(string[2:-1], "utf-8")
|
|
31
|
-
# LIST
|
|
32
|
-
elif _re.match(r"^\[(.*)\]$", string):
|
|
33
|
-
return [
|
|
34
|
-
String.to_type(item.strip()) for item in _re.findall(r"(?:[^,\[\]]+|\[.*?\]|\(.*?\)|\{.*?\})+", string[1:-1])
|
|
35
|
-
]
|
|
36
|
-
# TUPLE
|
|
37
|
-
elif _re.match(r"^\((.*)\)$", string):
|
|
38
|
-
return tuple(
|
|
39
|
-
String.to_type(item.strip()) for item in _re.findall(r"(?:[^,\(\)]+|\[.*?\]|\(.*?\)|\{.*?\})+", string[1:-1])
|
|
40
|
-
)
|
|
41
|
-
# DICTIONARY
|
|
42
|
-
elif _re.match(r"^\{(.*)\}$", string) and ":" in string:
|
|
43
|
-
return {
|
|
44
|
-
String.to_type(k.strip()): String.to_type(v.strip())
|
|
45
|
-
for k, v in _re.findall(
|
|
46
|
-
r"((?:[^:,{}]+|\[.*?\]|\(.*?\)|\{.*?\})+)\s*:\s*((?:[^:,{}]+|\[.*?\]|\(.*?\)|\{.*?\})+)", string[1:-1]
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
# SET
|
|
50
|
-
elif _re.match(r"^\{(.*?)\}$", string):
|
|
51
|
-
return {
|
|
52
|
-
String.to_type(item.strip()) for item in _re.findall(r"(?:[^,{}]+|\[.*?\]|\(.*?\)|\{.*?\})+", string[1:-1])
|
|
53
|
-
}
|
|
54
|
-
# RETURN AS IS (str)
|
|
55
|
-
return string
|
|
10
|
+
"""Will convert a string to the found type, including complex nested structures."""
|
|
11
|
+
string = string.strip()
|
|
12
|
+
try:
|
|
13
|
+
return _ast.literal_eval(string)
|
|
14
|
+
except (ValueError, SyntaxError):
|
|
15
|
+
try:
|
|
16
|
+
return _json.loads(string)
|
|
17
|
+
except _json.JSONDecodeError:
|
|
18
|
+
return string
|
|
56
19
|
|
|
57
20
|
@staticmethod
|
|
58
21
|
def normalize_spaces(string: str, tab_spaces: int = 4) -> str:
|
|
59
22
|
"""Replaces all special space characters with normal spaces.
|
|
60
23
|
Also replaces tab characters with `tab_spaces` spaces."""
|
|
61
|
-
return (
|
|
62
|
-
string.replace("\t", " " * tab_spaces)
|
|
63
|
-
.replace("\
|
|
64
|
-
.replace("\
|
|
65
|
-
|
|
66
|
-
.replace("\u2003", " ")
|
|
67
|
-
.replace("\u2004", " ")
|
|
68
|
-
.replace("\u2005", " ")
|
|
69
|
-
.replace("\u2006", " ")
|
|
70
|
-
.replace("\u2007", " ")
|
|
71
|
-
.replace("\u2008", " ")
|
|
72
|
-
.replace("\u2009", " ")
|
|
73
|
-
.replace("\u200A", " ")
|
|
74
|
-
)
|
|
24
|
+
return ( # YAPF: disable
|
|
25
|
+
string.replace("\t", " " * tab_spaces).replace("\u2000", " ").replace("\u2001", " ").replace("\u2002", " ")
|
|
26
|
+
.replace("\u2003", " ").replace("\u2004", " ").replace("\u2005", " ").replace("\u2006", " ")
|
|
27
|
+
.replace("\u2007", " ").replace("\u2008", " ").replace("\u2009", " ").replace("\u200A", " ")
|
|
28
|
+
) # YAPF: enable
|
|
75
29
|
|
|
76
30
|
@staticmethod
|
|
77
31
|
def escape(string: str, str_quotes: str = '"') -> str:
|
|
@@ -80,15 +34,10 @@ class String:
|
|
|
80
34
|
`str_quotes` can be either `"` or `'` and should match the quotes, the string will be put
|
|
81
35
|
inside of. So if your string will be `"string"`, you should pass `"` to the parameter
|
|
82
36
|
`str_quotes`. That way, if the string includes the same quotes, they will be escaped."""
|
|
83
|
-
string = (
|
|
84
|
-
string.replace("\\", r"\\")
|
|
85
|
-
.replace("\
|
|
86
|
-
|
|
87
|
-
.replace("\t", r"\t")
|
|
88
|
-
.replace("\b", r"\b")
|
|
89
|
-
.replace("\f", r"\f")
|
|
90
|
-
.replace("\a", r"\a")
|
|
91
|
-
)
|
|
37
|
+
string = ( # YAPF: disable
|
|
38
|
+
string.replace("\\", r"\\").replace("\n", r"\n").replace("\r", r"\r").replace("\t", r"\t")
|
|
39
|
+
.replace("\b", r"\b").replace("\f", r"\f").replace("\a", r"\a")
|
|
40
|
+
) # YAPF: enable
|
|
92
41
|
if str_quotes == '"':
|
|
93
42
|
string = string.replace(r"\\'", "'").replace(r'"', r"\"")
|
|
94
43
|
elif str_quotes == "'":
|
|
@@ -114,10 +63,8 @@ class String:
|
|
|
114
63
|
@staticmethod
|
|
115
64
|
def decompose(case_string: str, seps: str = "-_", lower_all: bool = True) -> list[str]:
|
|
116
65
|
"""Will decompose the string (any type of casing, also mixed) into parts."""
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
for part in _re.split(rf"(?<=[a-z])(?=[A-Z])|[{_re.escape(seps)}]", case_string)
|
|
120
|
-
]
|
|
66
|
+
return [(part.lower() if lower_all else part)
|
|
67
|
+
for part in _re.split(rf"(?<=[a-z])(?=[A-Z])|[{_re.escape(seps)}]", case_string)]
|
|
121
68
|
|
|
122
69
|
@staticmethod
|
|
123
70
|
def to_camel_case(string: str, upper: bool = True) -> str:
|
|
@@ -155,4 +102,4 @@ class String:
|
|
|
155
102
|
@staticmethod
|
|
156
103
|
def split_count(string: str, count: int) -> list[str]:
|
|
157
104
|
"""Will split the string every `count` characters."""
|
|
158
|
-
return [string[i
|
|
105
|
+
return [string[i:i + count] for i in range(0, len(string), count)]
|
xulbux/xx_system.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from typing import Optional
|
|
1
2
|
import subprocess as _subprocess
|
|
2
3
|
import platform as _platform
|
|
3
4
|
import ctypes as _ctypes
|
|
@@ -6,31 +7,31 @@ import sys as _sys
|
|
|
6
7
|
import os as _os
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
# YAPF: disable
|
|
9
11
|
class ProcessNotFoundError(Exception):
|
|
10
12
|
pass
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@staticmethod
|
|
16
|
-
def is_elevated() -> bool:
|
|
17
|
-
"""Returns `True` if the current user is an admin and `False` otherwise."""
|
|
14
|
+
class _IsElevated:
|
|
15
|
+
def __get__(self, obj, owner=None):
|
|
18
16
|
try:
|
|
19
17
|
if _os.name == "nt":
|
|
20
18
|
return _ctypes.windll.shell32.IsUserAnAdmin() != 0
|
|
21
19
|
elif _os.name == "posix":
|
|
22
20
|
return _os.geteuid() == 0
|
|
23
|
-
except:
|
|
21
|
+
except Exception:
|
|
24
22
|
pass
|
|
25
23
|
return False
|
|
24
|
+
# YAPF: enable
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class System:
|
|
28
|
+
|
|
29
|
+
is_elevated: bool = _IsElevated()
|
|
30
|
+
"""Is `True` if the current process has
|
|
31
|
+
elevated privileges and `False` otherwise."""
|
|
26
32
|
|
|
27
33
|
@staticmethod
|
|
28
|
-
def restart(
|
|
29
|
-
prompt: object = None,
|
|
30
|
-
wait: int = 0,
|
|
31
|
-
continue_program: bool = False,
|
|
32
|
-
force: bool = False,
|
|
33
|
-
) -> None:
|
|
34
|
+
def restart(prompt: object = None, wait: int = 0, continue_program: bool = False, force: bool = False) -> None:
|
|
34
35
|
"""Starts a system restart:
|
|
35
36
|
- `prompt` is the message to be displayed in the systems restart notification.
|
|
36
37
|
- `wait` is the time to wait until restarting in seconds.
|
|
@@ -70,11 +71,7 @@ class System:
|
|
|
70
71
|
raise NotImplementedError(f"Restart not implemented for `{system}`")
|
|
71
72
|
|
|
72
73
|
@staticmethod
|
|
73
|
-
def check_libs(
|
|
74
|
-
lib_names: list[str],
|
|
75
|
-
install_missing: bool = False,
|
|
76
|
-
confirm_install: bool = True,
|
|
77
|
-
) -> None | list[str]:
|
|
74
|
+
def check_libs(lib_names: list[str], install_missing: bool = False, confirm_install: bool = True) -> Optional[list[str]]:
|
|
78
75
|
"""Checks if the given list of libraries are installed. If not:
|
|
79
76
|
- If `install_missing` is `False` the missing libraries will be returned as a list.
|
|
80
77
|
- If `install_missing` is `True` the missing libraries will be installed.
|
|
@@ -102,7 +99,7 @@ class System:
|
|
|
102
99
|
return missing
|
|
103
100
|
|
|
104
101
|
@staticmethod
|
|
105
|
-
def elevate(win_title: str
|
|
102
|
+
def elevate(win_title: Optional[str] = None, args: Optional[list] = None) -> bool:
|
|
106
103
|
"""Attempts to start a new process with elevated privileges.\n
|
|
107
104
|
---------------------------------------------------------------------------------
|
|
108
105
|
The param `win_title` is window the title of the elevated process.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xulbux
|
|
3
|
-
Version: 1.6.
|
|
4
|
-
Summary: A library which includes
|
|
3
|
+
Version: 1.6.7
|
|
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: MIT License
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ Project-URL: Documentation, https://github.com/XulbuX/PythonLibraryXulbuX/wiki
|
|
|
31
31
|
Project-URL: Homepage, https://github.com/XulbuX/PythonLibraryXulbuX
|
|
32
32
|
Project-URL: License, https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/LICENSE
|
|
33
33
|
Project-URL: Source Code, https://github.com/XulbuX/PythonLibraryXulbuX/tree/main/src
|
|
34
|
-
Keywords: xulbux,python,library,utility,helper,functions,tools,classes,types,methods,cmd,console,code,color,data,structures,env,environment,file,format,json,path,regex,string,system,operations,presets
|
|
34
|
+
Keywords: xulbux,python,library,utility,helper,functions,tools,classes,types,methods,cmd,console,constants,code,color,data,structures,env,environment,file,format,json,path,regex,string,system,operations,presets
|
|
35
35
|
Classifier: Intended Audience :: Developers
|
|
36
36
|
Classifier: Programming Language :: Python :: 3
|
|
37
37
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -45,6 +45,7 @@ Description-Content-Type: text/markdown
|
|
|
45
45
|
License-File: LICENSE
|
|
46
46
|
Requires-Dist: keyboard>=0.13.5
|
|
47
47
|
Requires-Dist: mouse>=0.7.1
|
|
48
|
+
Requires-Dist: prompt_toolkit>=3.0.41
|
|
48
49
|
Requires-Dist: pyperclip>=1.9.0
|
|
49
50
|
Requires-Dist: regex>=2023.10.3
|
|
50
51
|
Provides-Extra: dev
|
|
@@ -52,41 +53,54 @@ Requires-Dist: pytest>=7.4.2; extra == "dev"
|
|
|
52
53
|
Requires-Dist: black>=23.7.0; extra == "dev"
|
|
53
54
|
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
54
55
|
Requires-Dist: flake8>=6.1.0; extra == "dev"
|
|
56
|
+
Requires-Dist: flake8-pyproject>=1.2.3; extra == "dev"
|
|
55
57
|
|
|
56
58
|
# **$\color{#8085FF}\Huge\textsf{XulbuX}$**
|
|
57
59
|
|
|
58
|
-
**$\color{#8085FF}\textsf{XulbuX}$** is
|
|
60
|
+
**$\color{#8085FF}\textsf{XulbuX}$** is library that contains many useful classes, types, and functions,
|
|
61
|
+
ranging from console logging and working with colors to file management and system operations.
|
|
62
|
+
The library is designed to simplify common programming tasks and improve code readability through its collection of tools.
|
|
59
63
|
|
|
60
|
-
For precise information about the library, see the library's [
|
|
61
|
-
For the libraries latest changes, see the [change log](https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/CHANGELOG.md).
|
|
64
|
+
For precise information about the library, see the library's [wiki page](https://github.com/XulbuX/PythonLibraryXulbuX/wiki).<br>
|
|
65
|
+
For the libraries latest changes and updates, see the [change log](https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/CHANGELOG.md).
|
|
62
66
|
|
|
67
|
+
<br>
|
|
63
68
|
|
|
64
69
|
## Installation
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
Run the following commands in a console with administrator privileges, so the actions take effect for all users.
|
|
72
|
+
|
|
73
|
+
Install the library and all its dependencies with the command:
|
|
74
|
+
```console
|
|
68
75
|
pip install xulbux
|
|
69
76
|
```
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
```
|
|
78
|
+
Upgrade the library and all its dependencies to their latest available version with the command:
|
|
79
|
+
```console
|
|
73
80
|
pip install --upgrade xulbux
|
|
74
81
|
```
|
|
75
82
|
|
|
83
|
+
<br>
|
|
76
84
|
|
|
77
85
|
## Usage
|
|
78
86
|
|
|
79
|
-
Import the full library under the alias `xx`, so
|
|
87
|
+
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()`:
|
|
80
88
|
```python
|
|
81
89
|
import xulbux as xx
|
|
82
90
|
```
|
|
83
|
-
So you don't have to
|
|
91
|
+
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:
|
|
84
92
|
```python
|
|
93
|
+
# CONSTANTS
|
|
94
|
+
from xulbux import COLOR, CHARS, ANSI
|
|
95
|
+
# Classes
|
|
96
|
+
from xulbux import Code, Color, Console, ...
|
|
97
|
+
# types
|
|
85
98
|
from xulbux import rgba, hsla, hexa
|
|
86
99
|
```
|
|
87
100
|
|
|
101
|
+
<br>
|
|
88
102
|
|
|
89
|
-
|
|
103
|
+
## Modules
|
|
90
104
|
|
|
91
105
|
| | |
|
|
92
106
|
| :--------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------- |
|
|
@@ -103,7 +117,72 @@ from xulbux import rgba, hsla, hexa
|
|
|
103
117
|
| <h3>[`xx_string`](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_string)</h3> | helpful actions when working with strings. (*normalize, escape, decompose, ...*) |
|
|
104
118
|
| <h3>`xx_system`</h3> | advanced system actions (*restart with message, check installed Python libs, ...*) |
|
|
105
119
|
|
|
120
|
+
<br>
|
|
121
|
+
|
|
122
|
+
## Example Usage
|
|
106
123
|
|
|
124
|
+
This is what it could look like using this library for a simple but very nice looking color converter:
|
|
125
|
+
```python
|
|
126
|
+
from xulbux import COLOR # CONSTANTS
|
|
127
|
+
from xulbux import FormatCodes, Console # Classes
|
|
128
|
+
from xulbux import hexa # types
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def main() -> None:
|
|
132
|
+
|
|
133
|
+
# LET THE USER ENTER A HEXA COLOR IN ANY HEXA FORMAT
|
|
134
|
+
input_clr = FormatCodes.input(
|
|
135
|
+
"\n[b](Enter a HEXA color in any format) [dim](>) "
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# ANNOUNCE INDEXING THE INPUT COLOR
|
|
139
|
+
Console.log(
|
|
140
|
+
"INDEX",
|
|
141
|
+
"Indexing the input HEXA color...",
|
|
142
|
+
start="\n",
|
|
143
|
+
title_bg_color=COLOR.blue,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
try:
|
|
147
|
+
# TRY TO CONVERT THE INPUT COLOR INTO A hexa() COLOR
|
|
148
|
+
hexa_color = hexa(input_clr)
|
|
149
|
+
|
|
150
|
+
except ValueError:
|
|
151
|
+
# ANNOUNCE THE ERROR AND EXIT THE PROGRAM
|
|
152
|
+
Console.fail(
|
|
153
|
+
"The input HEXA color is invalid.",
|
|
154
|
+
end="\n\n",
|
|
155
|
+
exit=True,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# ANNOUNCE STARTING THE CONVERSION
|
|
159
|
+
Console.log(
|
|
160
|
+
"CONVERT",
|
|
161
|
+
"Converting the HEXA color into different types...",
|
|
162
|
+
title_bg_color=COLOR.tangerine,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# CONVERT THE HEXA COLOR INTO THE TWO OTHER COLOR TYPES
|
|
166
|
+
rgba_color = hexa_color.to_rgba()
|
|
167
|
+
hsla_color = hexa_color.to_hsla()
|
|
168
|
+
|
|
169
|
+
# ANNOUNCE THE SUCCESSFUL CONVERSION
|
|
170
|
+
Console.done(
|
|
171
|
+
"Successfully converted color into different types.",
|
|
172
|
+
end="\n\n",
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# PRETTY PRINT THE COLOR IN DIFFERENT TYPES
|
|
176
|
+
FormatCodes.print(f"[b](HEXA:) [i|white]({hexa_color})")
|
|
177
|
+
FormatCodes.print(f"[b](RGBA:) [i|white]({rgba_color})")
|
|
178
|
+
FormatCodes.print(f"[b](HSLA:) [i|white]({hsla_color})\n")
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if __name__ == "__main__":
|
|
182
|
+
main()
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
<br>
|
|
107
186
|
<br>
|
|
108
187
|
|
|
109
188
|
--------------------------------------------------------------
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
xulbux/__init__.py,sha256=UpA3daxpIqjsDltsQawhVZWD5ggQAHl9L8YVurs_LgQ,1654
|
|
2
|
+
xulbux/_cli_.py,sha256=I1TieHnX60mlRvMaTQnon-VRuf_70dkP7sOU1aHthQY,3470
|
|
3
|
+
xulbux/_consts_.py,sha256=b85O5sePS18z7CJgrVw0V7v88PIG9qnQ7G2bJL71odk,6287
|
|
4
|
+
xulbux/xx_code.py,sha256=dY2HRXIDXHN3KTzzUkQVBacFDExNVwH8flREshwi4vk,5288
|
|
5
|
+
xulbux/xx_color.py,sha256=nwcd5_4JIRfZ99JqbCXMl4RWpic_-M361AA5zEa9Nuw,44846
|
|
6
|
+
xulbux/xx_console.py,sha256=X5Xw-Sd-0aOPqIhdddTyXyEELsnlOP8QFOmBED4cbJg,22175
|
|
7
|
+
xulbux/xx_data.py,sha256=5MIEKDgbRLGkZi9Yd35XhzrWZY09oXyVLGs0BgTTHFA,30219
|
|
8
|
+
xulbux/xx_env_path.py,sha256=pdFyfZgOgCQ440thNdUKzhb1JVxefeTLp7rj6YHYrpk,4305
|
|
9
|
+
xulbux/xx_file.py,sha256=sVUj50vT0wpc2C8Kkg1MlqDUFauCvLGQx6ZEh1gMm5k,3316
|
|
10
|
+
xulbux/xx_format_codes.py,sha256=abR9TWtnBLF0L08oyRjDYXx9VCtun9kjGVPmkv44emU,20359
|
|
11
|
+
xulbux/xx_json.py,sha256=dw2AiqMErdjW0ot4pICDBdTL6j03IrYJWJz-Lw21d4Q,5149
|
|
12
|
+
xulbux/xx_path.py,sha256=trDke1N9ewbkQmAIqjeB9gfbTuAlzqFY2mtPtlK2Ks0,4639
|
|
13
|
+
xulbux/xx_regex.py,sha256=gvnDel8xVmf11kvhc0iIjSj1dFW3OLnXNDlaJsUxXU4,7952
|
|
14
|
+
xulbux/xx_string.py,sha256=nJBXAVNknhTE9N_4yOyCVwSSIwOyHCRlZe_D7LOgrOY,5450
|
|
15
|
+
xulbux/xx_system.py,sha256=4WuItIeVF5cU3u3-cu3XqhtxBcap9YDJiQKTZuWsUyM,6494
|
|
16
|
+
xulbux-1.6.7.dist-info/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
|
|
17
|
+
xulbux-1.6.7.dist-info/METADATA,sha256=QDBNVRyIAIrMBzSHxJ1u-cIX2QiU-f9HxcudiCr5of4,9295
|
|
18
|
+
xulbux-1.6.7.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
|
|
19
|
+
xulbux-1.6.7.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
|
|
20
|
+
xulbux-1.6.7.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
|
|
21
|
+
xulbux-1.6.7.dist-info/RECORD,,
|
xulbux-1.6.5.dist-info/RECORD
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
xulbux/__init__.py,sha256=oLUyQ20jckO5yaen5i7y4ydoDb3WovCw-1PDAXtfEzg,1654
|
|
2
|
-
xulbux/_cli_.py,sha256=U25ZrtpQgpKXtvOSTBBbh7-AJ_WTeZ95A66DQARAqzo,3558
|
|
3
|
-
xulbux/_consts_.py,sha256=I-dAF5_0NXrHXUZLMylOKFBiJRc3qMKIFf7wMpaNzeI,4591
|
|
4
|
-
xulbux/xx_code.py,sha256=yBP5WxCxNxjBiS6nVAmUBJpD0hX6fgnh5RWq-NmrnaY,5222
|
|
5
|
-
xulbux/xx_color.py,sha256=kqlU9hyO9BFy7uiMJjkNiQXW8-hPrAwZokJ8gQMbo80,45298
|
|
6
|
-
xulbux/xx_console.py,sha256=IJ2oD9MMUyLzBQCbMViZd_2mV33ERqFX9DXEAOX4e8g,16974
|
|
7
|
-
xulbux/xx_data.py,sha256=MqTt_hpBUdgaf-DroVXp5euXM1ApeTiW2ognCFFitC4,25844
|
|
8
|
-
xulbux/xx_env_path.py,sha256=iv3Jw0TsNDbbL_NySnazvIP9Iv9swymhiJIr2B3EG8k,4388
|
|
9
|
-
xulbux/xx_file.py,sha256=MGGrPDyvgVQJrdcRSGE_jiB_aQz6zo5I0m6_5pKYIo8,3123
|
|
10
|
-
xulbux/xx_format_codes.py,sha256=pL4BpV74YOYs8yltMrWTjGQ3x8vtELSbXEPhx6EWV4s,20380
|
|
11
|
-
xulbux/xx_json.py,sha256=q60lOj8Xg8c4L9cBu6SBZdJzFC7QbjDfFwcKKzBKj5w,5173
|
|
12
|
-
xulbux/xx_path.py,sha256=_xkH9cowPdi3nHw2q_TvN_i_5oG6GJut-QwPBLxnrAQ,4519
|
|
13
|
-
xulbux/xx_regex.py,sha256=S1-MIk2qG4vHdxuaHGhMe5PHfY1SF9kncg8iQ8HJgS4,8002
|
|
14
|
-
xulbux/xx_string.py,sha256=de6rwINc_2sIDI35POxIzu2REU4Oc9Oau13Pz2sUgkA,7208
|
|
15
|
-
xulbux/xx_system.py,sha256=M3VGU3Tf3nDU59DjIJgDXJOqNB80Vr0wf15Vcnb5UCo,6430
|
|
16
|
-
xulbux-1.6.5.dist-info/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
|
|
17
|
-
xulbux-1.6.5.dist-info/METADATA,sha256=yo1jnPqizUqaC3UCKsHU69qPIxInJS5Ex6iH4m30CN4,6884
|
|
18
|
-
xulbux-1.6.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
19
|
-
xulbux-1.6.5.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
|
|
20
|
-
xulbux-1.6.5.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
|
|
21
|
-
xulbux-1.6.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|