xulbux 1.6.8__py3-none-any.whl → 1.7.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.
Potentially problematic release.
This version of xulbux might be problematic. Click here for more details.
- xulbux/__init__.py +3 -35
- xulbux/_cli_.py +21 -28
- xulbux/_consts_.py +1 -0
- xulbux/xx_code.py +62 -46
- xulbux/xx_color.py +223 -159
- xulbux/xx_console.py +152 -78
- xulbux/xx_data.py +79 -71
- xulbux/xx_env_path.py +6 -9
- xulbux/xx_file.py +22 -26
- xulbux/xx_format_codes.py +55 -33
- xulbux/xx_json.py +107 -51
- xulbux/xx_path.py +74 -24
- xulbux/xx_regex.py +11 -10
- xulbux/xx_string.py +4 -1
- xulbux/xx_system.py +6 -10
- {xulbux-1.6.8.dist-info → xulbux-1.7.0.dist-info}/METADATA +18 -39
- xulbux-1.7.0.dist-info/RECORD +21 -0
- {xulbux-1.6.8.dist-info → xulbux-1.7.0.dist-info}/WHEEL +1 -1
- xulbux-1.6.8.dist-info/RECORD +0 -21
- {xulbux-1.6.8.dist-info → xulbux-1.7.0.dist-info}/entry_points.txt +0 -0
- {xulbux-1.6.8.dist-info → xulbux-1.7.0.dist-info/licenses}/LICENSE +0 -0
- {xulbux-1.6.8.dist-info → xulbux-1.7.0.dist-info}/top_level.txt +0 -0
xulbux/xx_string.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from typing import Any
|
|
1
2
|
import json as _json
|
|
2
3
|
import ast as _ast
|
|
3
4
|
import re as _re
|
|
@@ -6,7 +7,7 @@ import re as _re
|
|
|
6
7
|
class String:
|
|
7
8
|
|
|
8
9
|
@staticmethod
|
|
9
|
-
def to_type(string: str) ->
|
|
10
|
+
def to_type(string: str) -> Any:
|
|
10
11
|
"""Will convert a string to the found type, including complex nested structures."""
|
|
11
12
|
string = string.strip()
|
|
12
13
|
try:
|
|
@@ -102,4 +103,6 @@ class String:
|
|
|
102
103
|
@staticmethod
|
|
103
104
|
def split_count(string: str, count: int) -> list[str]:
|
|
104
105
|
"""Will split the string every `count` characters."""
|
|
106
|
+
if count <= 0:
|
|
107
|
+
raise ValueError("Count must be greater than 0.")
|
|
105
108
|
return [string[i:i + count] for i in range(0, len(string), count)]
|
xulbux/xx_system.py
CHANGED
|
@@ -7,26 +7,22 @@ import sys as _sys
|
|
|
7
7
|
import os as _os
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
# YAPF: disable
|
|
11
|
-
class ProcessNotFoundError(Exception):
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
10
|
class _IsElevated:
|
|
11
|
+
|
|
15
12
|
def __get__(self, obj, owner=None):
|
|
16
13
|
try:
|
|
17
14
|
if _os.name == "nt":
|
|
18
15
|
return _ctypes.windll.shell32.IsUserAnAdmin() != 0
|
|
19
16
|
elif _os.name == "posix":
|
|
20
|
-
return _os.geteuid() == 0
|
|
17
|
+
return _os.geteuid() == 0 # type: ignore[attr-defined]
|
|
21
18
|
except Exception:
|
|
22
19
|
pass
|
|
23
20
|
return False
|
|
24
|
-
# YAPF: enable
|
|
25
21
|
|
|
26
22
|
|
|
27
23
|
class System:
|
|
28
24
|
|
|
29
|
-
is_elevated: bool = _IsElevated()
|
|
25
|
+
is_elevated: bool = _IsElevated() # type: ignore[assignment]
|
|
30
26
|
"""Is `True` if the current process has
|
|
31
27
|
elevated privileges and `False` otherwise."""
|
|
32
28
|
|
|
@@ -58,7 +54,7 @@ class System:
|
|
|
58
54
|
if len(processes) > 2: # EXCLUDING THE PYTHON PROCESS AND PS
|
|
59
55
|
raise RuntimeError("Processes are still running. Use the parameter `force=True` to restart anyway.")
|
|
60
56
|
if prompt:
|
|
61
|
-
_subprocess.Popen(["notify-send", "System Restart", prompt])
|
|
57
|
+
_subprocess.Popen(["notify-send", "System Restart", str(prompt)])
|
|
62
58
|
_time.sleep(wait)
|
|
63
59
|
try:
|
|
64
60
|
_subprocess.run(["sudo", "shutdown", "-r", "now"])
|
|
@@ -99,7 +95,7 @@ class System:
|
|
|
99
95
|
return missing
|
|
100
96
|
|
|
101
97
|
@staticmethod
|
|
102
|
-
def elevate(win_title: Optional[str] = None, args:
|
|
98
|
+
def elevate(win_title: Optional[str] = None, args: list = []) -> bool:
|
|
103
99
|
"""Attempts to start a new process with elevated privileges.\n
|
|
104
100
|
---------------------------------------------------------------------------------
|
|
105
101
|
The param `win_title` is window the title of the elevated process.
|
|
@@ -110,7 +106,7 @@ class System:
|
|
|
110
106
|
---------------------------------------------------------------------------------
|
|
111
107
|
Returns `True` if the current process already has elevated privileges and raises
|
|
112
108
|
a `PermissionError` if the user denied the elevation or the elevation failed."""
|
|
113
|
-
if System.is_elevated
|
|
109
|
+
if System.is_elevated:
|
|
114
110
|
return True
|
|
115
111
|
if _os.name == "nt": # WINDOWS
|
|
116
112
|
if win_title:
|
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: xulbux
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
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
|
-
License: MIT
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2024 XulbuX
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
|
|
6
|
+
License-Expression: MIT
|
|
28
7
|
Project-URL: Bug Reports, https://github.com/XulbuX/PythonLibraryXulbuX/issues
|
|
29
8
|
Project-URL: Changelog, https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/CHANGELOG.md
|
|
30
9
|
Project-URL: Documentation, https://github.com/XulbuX/PythonLibraryXulbuX/wiki
|
|
@@ -37,7 +16,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
37
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
38
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
39
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
41
19
|
Classifier: Operating System :: OS Independent
|
|
42
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
21
|
Requires-Python: >=3.10.0
|
|
@@ -54,6 +32,7 @@ Requires-Dist: black>=23.7.0; extra == "dev"
|
|
|
54
32
|
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
55
33
|
Requires-Dist: flake8>=6.1.0; extra == "dev"
|
|
56
34
|
Requires-Dist: flake8-pyproject>=1.2.3; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
57
36
|
|
|
58
37
|
# **$\color{#8085FF}\Huge\textsf{XulbuX}$**
|
|
59
38
|
|
|
@@ -102,20 +81,20 @@ from xulbux import rgba, hsla, hexa
|
|
|
102
81
|
|
|
103
82
|
## Modules
|
|
104
83
|
|
|
105
|
-
| Module
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
84
|
+
| Module | Short Description |
|
|
85
|
+
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_code) | advanced code-string operations (*changing the indent, finding function calls, ...*) |
|
|
87
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_color) | everything around colors (*converting, blending, searching colors in strings, ...*) |
|
|
88
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_console) | advanced actions related to the console (*pretty logging, advanced inputs, ...*) |
|
|
89
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_data) | advanced operations with data structures (*compare, generate path ID's, pretty print/format, ...*) |
|
|
90
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_env_path) | getting and editing the PATH variable (*get paths, check for paths, add paths, ...*) |
|
|
91
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_file) | advanced working with files (*create files, rename file-extensions, ...*) |
|
|
92
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_format_codes) | easy pretty printing with custom format codes (*print, inputs, custom format codes to ANSI, ...*) |
|
|
93
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_json) | advanced working with json files (*read, create, update, ...*) |
|
|
94
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_path) | advanced path operations (*get paths, smart-extend relative paths, delete paths, ...*) |
|
|
95
|
+
|  | generated regex pattern-templates (*match bracket- and quote pairs, match colors, ...*) |
|
|
96
|
+
| [](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/xx_string) | helpful actions when working with strings. (*normalize, escape, decompose, ...*) |
|
|
97
|
+
|  | advanced system actions (*restart with message, check installed Python libs, ...*) |
|
|
119
98
|
|
|
120
99
|
<br>
|
|
121
100
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
xulbux/__init__.py,sha256=TbXPioXPENwpR9t4lvqBBhV4cby0JGdIrSzzdMFYrEc,815
|
|
2
|
+
xulbux/_cli_.py,sha256=J4vfJHLJEYxCZzA_VJUB46w2WGShfdYFoetsLG5PfKo,3428
|
|
3
|
+
xulbux/_consts_.py,sha256=AuYTTmqrP2lawyVGlPLUaP1syxOoPA-ejJGH7WlwFzk,6314
|
|
4
|
+
xulbux/xx_code.py,sha256=w9yO-GPMeaE-xDi-L3VtpPpWpu5jOwagfMsG93aXANE,6106
|
|
5
|
+
xulbux/xx_color.py,sha256=ZEV9AG3MtgNMh4t4VexmBiaperan1pHO4d_VPCdv188,49923
|
|
6
|
+
xulbux/xx_console.py,sha256=WmH6YURaA-Y-LNB-2kZc8SuPxoZim8ZmzsuI01V9vcM,28682
|
|
7
|
+
xulbux/xx_data.py,sha256=nEfVwK6-ILaL3K-bLezKpG1G7117CY5ZgC3BGwANrUE,30886
|
|
8
|
+
xulbux/xx_env_path.py,sha256=x56mKK4lSvU5yMCAs8k0RVIqXWUJcpcHYz5HoZ_RklM,4160
|
|
9
|
+
xulbux/xx_file.py,sha256=KerXOvKS93zIoAt36YTYuZboSmxVFVf2WcOrDcdwXfE,2627
|
|
10
|
+
xulbux/xx_format_codes.py,sha256=fOFidFDBYV-rUXOlYTeKIZarfh9Q1jSUCGYyk8pg-ic,23397
|
|
11
|
+
xulbux/xx_json.py,sha256=V7vdfpvSe9wpktR_c8zG_Meix7x9IRmn66k5nB3HUyo,7457
|
|
12
|
+
xulbux/xx_path.py,sha256=lLAEVZrW0TAwCewlONFVQcQ_8tVn9LTJZVOZpeGvE5s,7673
|
|
13
|
+
xulbux/xx_regex.py,sha256=ejqVs4a-eCSTrSQfENoyl0AVztb8BuI2TNl-wzMQwYw,8048
|
|
14
|
+
xulbux/xx_string.py,sha256=QaTo0TQ9m_2USNgQNaVw5ivQt-A1E-e5x8OpIB3xIlY,5561
|
|
15
|
+
xulbux/xx_system.py,sha256=Tsx4wgztUg46KloqcGeiFkarDoM3EgJLXw3XNxgHBmU,6460
|
|
16
|
+
xulbux-1.7.0.dist-info/licenses/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
|
|
17
|
+
xulbux-1.7.0.dist-info/METADATA,sha256=symGYQzZhSYyGcwM_dGI3FETAcqgTL-ft90CLtJoNlY,9222
|
|
18
|
+
xulbux-1.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
xulbux-1.7.0.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
|
|
20
|
+
xulbux-1.7.0.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
|
|
21
|
+
xulbux-1.7.0.dist-info/RECORD,,
|
xulbux-1.6.8.dist-info/RECORD
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
xulbux/__init__.py,sha256=UY5nyn_XmeHAhiPtZmNMlc9hQRlNWbQ0uirICuihWzg,1654
|
|
2
|
-
xulbux/_cli_.py,sha256=I1TieHnX60mlRvMaTQnon-VRuf_70dkP7sOU1aHthQY,3470
|
|
3
|
-
xulbux/_consts_.py,sha256=b85O5sePS18z7CJgrVw0V7v88PIG9qnQ7G2bJL71odk,6287
|
|
4
|
-
xulbux/xx_code.py,sha256=GfzpbN-41L_qfzEdkl4PWq9tbCSAlnE2xX3lPtHo1Iw,5275
|
|
5
|
-
xulbux/xx_color.py,sha256=nwcd5_4JIRfZ99JqbCXMl4RWpic_-M361AA5zEa9Nuw,44846
|
|
6
|
-
xulbux/xx_console.py,sha256=2ZHNxwpSoILjHk45QwzJJbtCn3WOVQ9TmkyqPpdU_3w,25860
|
|
7
|
-
xulbux/xx_data.py,sha256=5MIEKDgbRLGkZi9Yd35XhzrWZY09oXyVLGs0BgTTHFA,30219
|
|
8
|
-
xulbux/xx_env_path.py,sha256=WoBYywFsncX-GMvSdvrGmuajXeeuRY2l_-3GuJJXChU,4200
|
|
9
|
-
xulbux/xx_file.py,sha256=Rij2NjxyBlwfFIN_Sc-vDJzzsn3jzgIigFQ_p6Zg80o,3246
|
|
10
|
-
xulbux/xx_format_codes.py,sha256=5Q5RAVfL-EmhqjJMQ4wMm0MQ3r0okjNKrpdsXeodupI,22313
|
|
11
|
-
xulbux/xx_json.py,sha256=dw2AiqMErdjW0ot4pICDBdTL6j03IrYJWJz-Lw21d4Q,5149
|
|
12
|
-
xulbux/xx_path.py,sha256=trDke1N9ewbkQmAIqjeB9gfbTuAlzqFY2mtPtlK2Ks0,4639
|
|
13
|
-
xulbux/xx_regex.py,sha256=rmy6stkVP-vm8j7QoIn0Z4ic_fMT9p_hs0QE6PkMcr0,7917
|
|
14
|
-
xulbux/xx_string.py,sha256=nJBXAVNknhTE9N_4yOyCVwSSIwOyHCRlZe_D7LOgrOY,5450
|
|
15
|
-
xulbux/xx_system.py,sha256=4WuItIeVF5cU3u3-cu3XqhtxBcap9YDJiQKTZuWsUyM,6494
|
|
16
|
-
xulbux-1.6.8.dist-info/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
|
|
17
|
-
xulbux-1.6.8.dist-info/METADATA,sha256=D0zdyVryi5SUH7ylNmFbi5qa1dgbPt7zdn08LkgqFOQ,9673
|
|
18
|
-
xulbux-1.6.8.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
19
|
-
xulbux-1.6.8.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
|
|
20
|
-
xulbux-1.6.8.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
|
|
21
|
-
xulbux-1.6.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|