xulbux 1.5.5__tar.gz → 1.5.7__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.
- xulbux-1.5.7/.github/workflows/python-package.yml +49 -0
- xulbux-1.5.7/.gitignore +31 -0
- {xulbux-1.5.5 → xulbux-1.5.7}/CHANGELOG.md +20 -4
- {xulbux-1.5.5 → xulbux-1.5.7}/PKG-INFO +14 -10
- {xulbux-1.5.5 → xulbux-1.5.7}/README.md +2 -2
- xulbux-1.5.7/documentation.md +369 -0
- xulbux-1.5.7/pyproject.toml +117 -0
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/__init__.py +20 -10
- xulbux-1.5.5/src/XulbuX/__help__.py → xulbux-1.5.7/src/XulbuX/_cli_.py +15 -37
- xulbux-1.5.7/src/XulbuX/_consts_.py +144 -0
- xulbux-1.5.7/src/XulbuX/xx_cmd.py +381 -0
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_code.py +28 -25
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_color.py +330 -182
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_data.py +214 -90
- xulbux-1.5.7/src/XulbuX/xx_env_vars.py +73 -0
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_file.py +20 -14
- xulbux-1.5.7/src/XulbuX/xx_format_codes.py +278 -0
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_json.py +36 -16
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_path.py +38 -23
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_regex.py +44 -27
- xulbux-1.5.7/src/XulbuX/xx_string.py +144 -0
- {xulbux-1.5.5 → xulbux-1.5.7}/src/XulbuX/xx_system.py +37 -26
- xulbux-1.5.7/tests/test_cmd_info.py +21 -0
- xulbux-1.5.7/tests/test_color_types.py +100 -0
- xulbux-1.5.5/.gitignore +0 -61
- xulbux-1.5.5/pyproject.toml +0 -74
- xulbux-1.5.5/src/XulbuX/_consts_.py +0 -147
- xulbux-1.5.5/src/XulbuX/xx_cmd.py +0 -240
- xulbux-1.5.5/src/XulbuX/xx_env_vars.py +0 -60
- xulbux-1.5.5/src/XulbuX/xx_format_codes.py +0 -212
- xulbux-1.5.5/src/XulbuX/xx_string.py +0 -116
- xulbux-1.5.5/tests/_diverse_.py +0 -99
- xulbux-1.5.5/tests/cmd_info.py +0 -7
- xulbux-1.5.5/tests/color-types.py +0 -68
- xulbux-1.5.5/tests/luminance.py +0 -35
- {xulbux-1.5.5 → xulbux-1.5.7}/LICENSE +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# THIS WORKFLOW WILL INSTALL PYTHON DEPENDENCIES, RUN TESTS AND LINT WITH A VARIETY OF PYTHON VERSIONS
|
|
2
|
+
# FOR MORE INFORMATION SEE: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
|
3
|
+
|
|
4
|
+
name: Python package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: ["main"]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: ["main"]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
uses: actions/setup-python@v3
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
|
|
28
|
+
- name: Cache pip packages
|
|
29
|
+
uses: actions/cache@v3
|
|
30
|
+
with:
|
|
31
|
+
path: ~/.cache/pip
|
|
32
|
+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
|
|
33
|
+
restore-keys: |
|
|
34
|
+
${{ runner.os }}-pip-
|
|
35
|
+
|
|
36
|
+
- name: Install project and dependencies
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
pip install -e .[dev] # INSTALL PROJECT AND DEV DEPENDENCIES
|
|
40
|
+
pip install flake8 pytest # ENSURE BOTH flake8 AND pytest ARE INSTALLED
|
|
41
|
+
|
|
42
|
+
- name: Lint with flake8
|
|
43
|
+
run: |
|
|
44
|
+
python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
45
|
+
python -m flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
46
|
+
|
|
47
|
+
- name: Test with pytest
|
|
48
|
+
run: |
|
|
49
|
+
python -m pytest --verbose # RUN pytest USING PYTHON MODULE TO AVOID PATH ISSUES
|
xulbux-1.5.7/.gitignore
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Python bytecode
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
.Python
|
|
8
|
+
wheels/
|
|
9
|
+
build/
|
|
10
|
+
dist/
|
|
11
|
+
|
|
12
|
+
# PyBuilder
|
|
13
|
+
.pybuilder/
|
|
14
|
+
target/
|
|
15
|
+
|
|
16
|
+
.python-version
|
|
17
|
+
|
|
18
|
+
# PEP 582
|
|
19
|
+
__pypackages__/
|
|
20
|
+
|
|
21
|
+
# pytype static type analyzer
|
|
22
|
+
.pytype/
|
|
23
|
+
|
|
24
|
+
# Cython debug symbols
|
|
25
|
+
cython_debug/
|
|
26
|
+
|
|
27
|
+
# VS Code
|
|
28
|
+
.vscode/
|
|
29
|
+
|
|
30
|
+
# Pytest
|
|
31
|
+
.pytest_cache/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
border-radius: 0.2em;
|
|
8
8
|
text-align: center;
|
|
9
9
|
justify-content: center;
|
|
10
|
-
">🠫</div>
|
|
10
|
+
"><span style="display:none">go to bottom </span>🠫</div>
|
|
11
11
|
</abbr></a>
|
|
12
12
|
</div>
|
|
13
13
|
|
|
@@ -15,17 +15,33 @@
|
|
|
15
15
|
# <br><b>Changelog</b><br>
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## 15.11.2024 `v1.5.7`
|
|
19
|
+
* Change the testing modules to be able to run together with the library `pytest`
|
|
20
|
+
* Added formatting checks, using `black`, `isort` and `flake8`
|
|
21
|
+
* Added the script (*command*) `xx-help` or `xulbux-help`
|
|
22
|
+
* Moved the `help()` function to the file `_cli_.py`, because that's where all the scripts are located (*It also was renamed to* `help_command()`)
|
|
23
|
+
* Structured `Cmd.restricted_input()` a bit nicer, so it appears less complex
|
|
24
|
+
* Corrected code after `Lint with flake8` formatting suggestions
|
|
25
|
+
* Moved the function `normalize_spaces()` to `xx_string`
|
|
26
|
+
* Added additional tests for the custom color types
|
|
27
|
+
* Updated the whole `xx_format_codes` module for more efficiency and speed
|
|
28
|
+
|
|
29
|
+
## 11.11.2024 `v1.5.6`
|
|
30
|
+
* Moved the whole library to it's own repository: [PythonLibraryXulbuX](https://github.com/XulbuX-dev/PythonLibraryXulbuX)
|
|
31
|
+
* Updated all connections and links
|
|
32
|
+
|
|
33
|
+
## 11.11.2024 `v1.5.5`
|
|
19
34
|
* Added functions to get the width and height of the console (*in characters and lines*):<br>
|
|
20
35
|
<code>Cmd.w() -> *int*</code> how many text characters the console is wide<br>
|
|
21
36
|
<code>Cmd.h() -> *int*</code> how many lines the console is high<br>
|
|
22
37
|
<code>Cmd.wh() -> *tuple[int,int]*</code> a tuple with width and height
|
|
23
|
-
* Added the function <code>
|
|
38
|
+
* Added the function <code>split_count(*string*, *count*) -> *list*[*str*]</code> to `xx_string`
|
|
24
39
|
* Added doc-strings to every function in `xx_string`
|
|
25
40
|
* Updated the `Cmd.restricted_input()` function:
|
|
26
41
|
- paste text from the clipboard
|
|
27
42
|
- select all text to delete everything at once
|
|
28
43
|
- write and backspace over multiple lines
|
|
44
|
+
- not the prompt supports custom format codes
|
|
29
45
|
* Added required non-standard libraries to the project file
|
|
30
46
|
* Added more metadata to the project file
|
|
31
47
|
|
|
@@ -282,6 +298,6 @@ from XulbuX import rgb, hsl, hexa
|
|
|
282
298
|
border-radius: 0.2em;
|
|
283
299
|
text-align: center;
|
|
284
300
|
justify-content: center;
|
|
285
|
-
">🠩</div>
|
|
301
|
+
"><span style="display:none">go to top </span>🠩</div>
|
|
286
302
|
</abbr></a>
|
|
287
303
|
</div>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: XulbuX
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.7
|
|
4
4
|
Summary: A library which includes a lot of really helpful functions.
|
|
5
|
-
Project-URL: Homepage, https://github.com/XulbuX-dev/
|
|
6
|
-
Project-URL: Bug Reports, https://github.com/XulbuX-dev/
|
|
7
|
-
Project-URL: Documentation, https://github.com/XulbuX-dev/
|
|
8
|
-
Project-URL: Source Code, https://github.com/XulbuX-dev/
|
|
9
|
-
Project-URL: Changelog, https://github.com/XulbuX-dev/
|
|
5
|
+
Project-URL: Homepage, https://github.com/XulbuX-dev/PythonLibraryXulbuX
|
|
6
|
+
Project-URL: Bug Reports, https://github.com/XulbuX-dev/PythonLibraryXulbuX/issues
|
|
7
|
+
Project-URL: Documentation, https://github.com/XulbuX-dev/PythonLibraryXulbuX/wiki
|
|
8
|
+
Project-URL: Source Code, https://github.com/XulbuX-dev/PythonLibraryXulbuX/tree/main/src
|
|
9
|
+
Project-URL: Changelog, https://github.com/XulbuX-dev/PythonLibraryXulbuX/blob/main/CHANGELOG.md
|
|
10
10
|
Author-email: XulbuX <xulbux.real@gmail.com>
|
|
11
11
|
License: MIT License
|
|
12
12
|
|
|
@@ -29,7 +29,7 @@ License: MIT License
|
|
|
29
29
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
30
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
31
|
SOFTWARE.
|
|
32
|
-
Keywords: classes,cmd,code,color,data,env,environment,file,format,functions,helper,
|
|
32
|
+
Keywords: classes,cmd,code,color,data,env,environment,file,format,functions,helper,json,library,methods,operations,path,presets,python,regex,string,structures,system,tools,types,utility,xulbux
|
|
33
33
|
Classifier: Intended Audience :: Developers
|
|
34
34
|
Classifier: License :: OSI Approved :: MIT License
|
|
35
35
|
Classifier: Operating System :: OS Independent
|
|
@@ -41,17 +41,21 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
41
41
|
Requires-Python: >=3.10.0
|
|
42
42
|
Requires-Dist: keyboard>=0.13.5
|
|
43
43
|
Requires-Dist: mouse>=0.7.1
|
|
44
|
+
Requires-Dist: pyperclip>=1.9.0
|
|
44
45
|
Requires-Dist: regex>=2023.10.3
|
|
45
46
|
Provides-Extra: dev
|
|
46
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: black>=23.7.0; extra == 'dev'
|
|
48
|
+
Requires-Dist: flake8>=6.1.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: isort>=5.12.0; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest>=7.4.2; extra == 'dev'
|
|
47
51
|
Description-Content-Type: text/markdown
|
|
48
52
|
|
|
49
53
|
# **$\color{#8085FF}\Huge\textsf{XulbuX}$**
|
|
50
54
|
|
|
51
55
|
**$\color{#8085FF}\textsf{XulbuX}$** is a library which includes a lot of really helpful classes, types and functions.
|
|
52
56
|
|
|
53
|
-
For the libraries latest changes, see the [change log](https://github.com/XulbuX-dev/
|
|
54
|
-
For precise information about the library, see the library's [Wiki page](https://github.com/XulbuX-dev/
|
|
57
|
+
For the libraries latest changes, see the [change log](https://github.com/XulbuX-dev/PythonLibraryXulbuX/blob/main/CHANGELOG.md).<br>
|
|
58
|
+
For precise information about the library, see the library's [Wiki page](https://github.com/XulbuX-dev/PythonLibraryXulbuX/wiki).
|
|
55
59
|
|
|
56
60
|
|
|
57
61
|
## Installation
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
**$\color{#8085FF}\textsf{XulbuX}$** is a library which includes a lot of really helpful classes, types and functions.
|
|
4
4
|
|
|
5
|
-
For the libraries latest changes, see the [change log](https://github.com/XulbuX-dev/
|
|
6
|
-
For precise information about the library, see the library's [Wiki page](https://github.com/XulbuX-dev/
|
|
5
|
+
For the libraries latest changes, see the [change log](https://github.com/XulbuX-dev/PythonLibraryXulbuX/blob/main/CHANGELOG.md).<br>
|
|
6
|
+
For precise information about the library, see the library's [Wiki page](https://github.com/XulbuX-dev/PythonLibraryXulbuX/wiki).
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
<div id="top" style="width:45px; height:45px; right:10px; top:10px; position:absolute">
|
|
2
|
+
<a href="#bottom"><abbr title="go to bottom" style="text-decoration:none">
|
|
3
|
+
<div style="
|
|
4
|
+
font-size: 2em;
|
|
5
|
+
font-weight: bold;
|
|
6
|
+
background: #88889845;
|
|
7
|
+
border-radius: 0.2em;
|
|
8
|
+
text-align: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
"><span style="display:none">go to bottom </span>🠫</div>
|
|
11
|
+
</abbr></a>
|
|
12
|
+
</div>
|
|
13
|
+
<br>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
**$\color{#8085FF}\Huge\textsf{XulbuX}$**
|
|
17
|
+
|
|
18
|
+
-------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
**$\color{#8085FF}\textsf{XulbuX}$** is a library which includes a lot of really helpful classes, types and functions.<br>
|
|
21
|
+
For the libraries latest changes, see the [change log](https://github.com/XulbuX-dev/Python/blob/main/Libraries/XulbuX/CHANGELOG.md).
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Installation
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Open a console and run the command:
|
|
29
|
+
```css
|
|
30
|
+
pip install XulbuX
|
|
31
|
+
```
|
|
32
|
+
This should install the latest version of the library, along with some other required libraries.<br>
|
|
33
|
+
To upgrade the library (*if there is a new release*) run the following command in your console:
|
|
34
|
+
```css
|
|
35
|
+
pip install --upgrade XulbuX
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Usage
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
This imports the full library under the alias `xx`, so it"s classes, types and functions are accessible with `xx.Class.method()`, `xx.type()` and `xx.function()`:
|
|
44
|
+
```python
|
|
45
|
+
import XulbuX as xx
|
|
46
|
+
```
|
|
47
|
+
So you don"t have to write `xx` in front of the library"s types, you can import them directly:
|
|
48
|
+
```python
|
|
49
|
+
from XulbuX import rgba, hsla, hexa
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Modules
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## xx_color
|
|
58
|
+
|
|
59
|
+
### `rgba()`
|
|
60
|
+
An RGB/RGBA color: is a tuple of 3 integers, representing the red (`0`-`255`), green (`0`-`255`), and blue (`0`-`255`).<br>
|
|
61
|
+
It also includes an optional 4th param, which is a float, that represents the alpha channel (`0.0`-`1.0`):
|
|
62
|
+
```python
|
|
63
|
+
rgba(
|
|
64
|
+
r: int,
|
|
65
|
+
g: int,
|
|
66
|
+
b: int,
|
|
67
|
+
a: float = None
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
Includes methods:
|
|
71
|
+
- `to_hsla()` to convert to HSL color
|
|
72
|
+
- `to_hexa()` to convert to HEX color
|
|
73
|
+
- `has_alpha()` to check if the color has an alpha channel
|
|
74
|
+
- `lighten(amount)` to create a lighter version of the color
|
|
75
|
+
- `darken(amount)` to create a darker version of the color
|
|
76
|
+
- `saturate(amount)` to increase color saturation
|
|
77
|
+
- `desaturate(amount)` to decrease color saturation
|
|
78
|
+
- `rotate(degrees)` to rotate the hue by degrees
|
|
79
|
+
- `invert()` to get the inverse color
|
|
80
|
+
- `grayscale()` to convert to grayscale
|
|
81
|
+
- `blend(other, ratio)` to blend with another color
|
|
82
|
+
- `is_dark()` to check if the color is considered dark
|
|
83
|
+
- `is_light()` to check if the color is considered light
|
|
84
|
+
- `is_grayscale()` to check if the color is grayscale
|
|
85
|
+
- `is_opaque()` to check if the color has no transparency
|
|
86
|
+
- `with_alpha(alpha)` to create a new color with different alpha
|
|
87
|
+
- `complementary()` to get the complementary color
|
|
88
|
+
<br>
|
|
89
|
+
|
|
90
|
+
### `hsla()`
|
|
91
|
+
A HSL/HSLA color: is a tuple of 3 integers, representing hue (`0`-`360`), saturation (`0`-`100`), and lightness (`0`-`100`).<br>
|
|
92
|
+
It also includes an optional 4th param, which is a float, that represents the alpha channel (`0.0`-`1.0`).\n
|
|
93
|
+
```python
|
|
94
|
+
hsla(
|
|
95
|
+
h: int,
|
|
96
|
+
s: int,
|
|
97
|
+
l: int,
|
|
98
|
+
a: float = None
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
Includes methods:
|
|
102
|
+
- `to_rgba()` to convert to RGB color
|
|
103
|
+
- `to_hexa()` to convert to HEX color
|
|
104
|
+
- `has_alpha()` to check if the color has an alpha channel
|
|
105
|
+
- `lighten(amount)` to create a lighter version of the color
|
|
106
|
+
- `darken(amount)` to create a darker version of the color
|
|
107
|
+
- `saturate(amount)` to increase color saturation
|
|
108
|
+
- `desaturate(amount)` to decrease color saturation
|
|
109
|
+
- `rotate(degrees)` to rotate the hue by degrees
|
|
110
|
+
- `invert()` to get the inverse color
|
|
111
|
+
- `grayscale()` to convert to grayscale
|
|
112
|
+
- `blend(other, ratio)` to blend with another color
|
|
113
|
+
- `is_dark()` to check if the color is considered dark
|
|
114
|
+
- `is_light()` to check if the color is considered light
|
|
115
|
+
- `is_grayscale()` to check if the color is grayscale
|
|
116
|
+
- `is_opaque()` to check if the color has no transparency
|
|
117
|
+
- `with_alpha(alpha)` to create a new color with different alpha
|
|
118
|
+
- `complementary()` to get the complementary color
|
|
119
|
+
<br>
|
|
120
|
+
|
|
121
|
+
### `hexa()`
|
|
122
|
+
A HEX color: is a string representing a hexadecimal color code with optional alpha channel.
|
|
123
|
+
```python
|
|
124
|
+
hexa(
|
|
125
|
+
color: str | int
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
Supports formats: RGB, RGBA, RRGGBB, RRGGBBAA (*with or without prefix*)<br>
|
|
129
|
+
Includes methods:
|
|
130
|
+
- `to_rgba()` to convert to RGB color
|
|
131
|
+
- `to_hsla()` to convert to HSL color
|
|
132
|
+
- `has_alpha()` to check if the color has an alpha channel
|
|
133
|
+
- `lighten(amount)` to create a lighter version of the color
|
|
134
|
+
- `darken(amount)` to create a darker version of the color
|
|
135
|
+
- `saturate(amount)` to increase color saturation
|
|
136
|
+
- `desaturate(amount)` to decrease color saturation
|
|
137
|
+
- `rotate(degrees)` to rotate the hue by degrees
|
|
138
|
+
- `invert()` to get the inverse color
|
|
139
|
+
- `grayscale()` to convert to grayscale
|
|
140
|
+
- `blend(other, ratio)` to blend with another color
|
|
141
|
+
- `is_dark()` to check if the color is considered dark
|
|
142
|
+
- `is_light()` to check if the color is considered light
|
|
143
|
+
- `is_grayscale()` to check if the color is grayscale
|
|
144
|
+
- `is_opaque()` to check if the color has no transparency
|
|
145
|
+
- `with_alpha(alpha)` to create a new color with different alpha
|
|
146
|
+
- `complementary()` to get the complementary color
|
|
147
|
+
<br>
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
## xx_cmd
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### `Cmd`
|
|
155
|
+
This class includes functions for logging and other actions within the console.
|
|
156
|
+
<br>
|
|
157
|
+
|
|
158
|
+
#### `Cmd.get_args()`
|
|
159
|
+
----------------------
|
|
160
|
+
This function is used to get the command arguments, for if the current file is run via the console as a command.<br>
|
|
161
|
+
**Params:**<br>
|
|
162
|
+
- <code>find_args: *dict*</code> a dictionary that specifies, which arguments you are looking for and under which alias they should be returned if found. This dictionary could look something like this:
|
|
163
|
+
```python
|
|
164
|
+
{
|
|
165
|
+
"filepath": ["-f", "--file", "-p", "--path", "-fp", "--filepath", "--file-path"],
|
|
166
|
+
"help": ["-h", "--help"],
|
|
167
|
+
"debug": ["-d", "--debug"]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
For this example, the command line could look like this:
|
|
171
|
+
```bash
|
|
172
|
+
python main.py -f /path/to/file -d
|
|
173
|
+
```
|
|
174
|
+
To get one value, you can allow multiple arguments, just like for the filepath in the above example.
|
|
175
|
+
|
|
176
|
+
**Returns:**<br>
|
|
177
|
+
The function will return a dictionary, with the specified aliases and two values per alias:
|
|
178
|
+
1. `"exists"` is `True` if one of the listed arguments is found and `False` otherwise
|
|
179
|
+
2. `"value"` is the value of the argument (`None` *if the argument has no value*)
|
|
180
|
+
|
|
181
|
+
So for the example command line from above, the function would return a dictionary:
|
|
182
|
+
```python
|
|
183
|
+
{
|
|
184
|
+
"filepath": { "exists": True, "value": "/path/to/file" },
|
|
185
|
+
"help": { "exists": False, "value": None },
|
|
186
|
+
"debug": { "exists": True, "value": None }
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
<br>
|
|
190
|
+
|
|
191
|
+
#### `Cmd.user()`
|
|
192
|
+
------------------
|
|
193
|
+
**Returns:** the username of the user of the current console session
|
|
194
|
+
<br>
|
|
195
|
+
|
|
196
|
+
#### `Cmd.is_admin()`
|
|
197
|
+
----------------------
|
|
198
|
+
**Returns:** `True` if the current console session is run as administrator and `False` otherwise
|
|
199
|
+
<br>
|
|
200
|
+
|
|
201
|
+
#### `Cmd.pause_exit()`
|
|
202
|
+
------------------------
|
|
203
|
+
Will print a prompt and then pause and/or exit the program.<br>
|
|
204
|
+
**Params:**
|
|
205
|
+
- <code>pause: *bool*</code> whether to pause the program at the message or not
|
|
206
|
+
- <code>exit: *bool*</code> whether to exit the program after the message was printed (*and the program was unpaused if* `pause` *is true*) or not
|
|
207
|
+
- <code>prompt: *str*</code> the prompt to print before pausing and/or exiting the program
|
|
208
|
+
- <code>exit_code: *int*</code> the exit code to use if `exit` is true
|
|
209
|
+
- <code>reset_ansi: *bool*</code> whether to reset the ANSI codes after the message was printed
|
|
210
|
+
<br>
|
|
211
|
+
|
|
212
|
+
#### `Cmd.cls()`
|
|
213
|
+
-----------------
|
|
214
|
+
Will clear the console in addition to completely resetting the ANSI formats.
|
|
215
|
+
<br>
|
|
216
|
+
|
|
217
|
+
#### <span id="cmd-log">`Cmd.log()`</span>
|
|
218
|
+
-----------------
|
|
219
|
+
Will print a nicely formatted log message.<br>
|
|
220
|
+
**Params:**
|
|
221
|
+
- <code>title: *str*</code> the title of the log message
|
|
222
|
+
- <code>prompt: *object*</code> the prompt to print before the log message
|
|
223
|
+
- <code>start: *str*</code> the string to print before the log message
|
|
224
|
+
- <code>end: *str*</code> the string to print after the log message (*default* `\n`)
|
|
225
|
+
- <code>title_bg_color: *hexa*|*rgba*</code> the background color of the title
|
|
226
|
+
- <code>default_color: *hexa*|*rgba*</code> the default color of the log message
|
|
227
|
+
The log message supports special formatting codes. For more detailed information about formatting codes, see the [`xx_format_codes` documentation](#xx_format_codes).
|
|
228
|
+
<br>
|
|
229
|
+
|
|
230
|
+
#### `Cmd.debug()` `Cmd.info()` `Cmd.done()` `Cmd.warn()` `Cmd.fail()` `Cmd.exit()`
|
|
231
|
+
-----------------------------------------------------------------------------------------
|
|
232
|
+
These functions are all presets for the [`Cmd.log()`](#cmd-log) function, with the options to pause at the message and exit the program after the message was printed. That means, they have the same params as the `Cmd.log()` function, with the two additional ones.<br>
|
|
233
|
+
**Additional Params:**
|
|
234
|
+
- <code>pause: *bool*</code> whether to pause the program at the message or not (*different default depending on the log preset*)
|
|
235
|
+
- <code>exit: *bool*</code> whether to exit the program after the message was printed (*and the program was unpaused if* `pause` *is true*) or not (*different default depending on the log preset*)
|
|
236
|
+
<br>
|
|
237
|
+
|
|
238
|
+
#### `Cmd.confirm()`
|
|
239
|
+
---------------------
|
|
240
|
+
This function can be used to ask a yes/no question.<br>
|
|
241
|
+
Like in the [`Cmd.log()`](#cmd-log) function it is possible to use special formatting codes inside the `prompt`.<br>
|
|
242
|
+
**Params:**
|
|
243
|
+
- <code>prompt: *object*</code> the prompt to print before the question
|
|
244
|
+
- <code>start: *str*</code> the string to print before the question
|
|
245
|
+
- <code>end: *str*</code> the string to print after the question (*default* `\n`)
|
|
246
|
+
- <code>default_color: *hexa*|*rgba*</code> the default color of the question
|
|
247
|
+
- <code>default_is_yes: *bool*</code> whether the default answer is yes or no (*if the user continues without entering anything or an unrecognized answer*)
|
|
248
|
+
|
|
249
|
+
**Returns:**
|
|
250
|
+
- `True` if the user enters `Y` or `yes` and `False` otherwise
|
|
251
|
+
- If the user entered nothing:
|
|
252
|
+
- `True` if `default_is_yes` is true
|
|
253
|
+
- `False` if `default_is_yes` is false
|
|
254
|
+
<br>
|
|
255
|
+
|
|
256
|
+
#### <span id="cmd-restricted_input">`Cmd.restricted_input()`</span>
|
|
257
|
+
------------------------------
|
|
258
|
+
This function acts like a standard Python `input()` with the advantage, that you can specify:
|
|
259
|
+
- what text characters the user is allowed to type and
|
|
260
|
+
- the minimum and/or maximum length of the users input
|
|
261
|
+
- optional mask character (hide user input, e.g. for passwords)
|
|
262
|
+
- reset the ANSI formatting codes after the user continues
|
|
263
|
+
|
|
264
|
+
Like in the [`Cmd.log()`](#cmd-log) function it is possible to use special formatting codes inside the `prompt`.<br>
|
|
265
|
+
**Params:**
|
|
266
|
+
- <code>prompt: *object*</code> the prompt to print before the input
|
|
267
|
+
- <code>allowed_chars: *str*</code> the allowed text characters the user can type (*default is all characters*)
|
|
268
|
+
- <code>min_length: *int*</code> the minimum length of the users input (*user can not confirm the input before this length is reached*)
|
|
269
|
+
- <code>max_length: *int*</code> the maximum length of the users input (*user cannot keep on writing if this length is reached*)
|
|
270
|
+
- <code>mask_char: *str*</code> the mask character to hide the users input
|
|
271
|
+
- <code>reset_ansi: *bool*</code> whether to reset the ANSI formatting codes after the user continues
|
|
272
|
+
|
|
273
|
+
**Returns:** the user's entry as a string
|
|
274
|
+
<br>
|
|
275
|
+
|
|
276
|
+
#### `Cmd.pwd_input()`
|
|
277
|
+
This function almost works like the [`Cmd.restricted_input()`](#cmd-restricted_input) function, but it always hides the users input.<br>
|
|
278
|
+
It has no additional parameters.<br>
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
## xx_code
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
### `Code`
|
|
286
|
+
This class includes functions, used to work with strings, that are code.
|
|
287
|
+
<br>
|
|
288
|
+
|
|
289
|
+
#### `Code.add_indent()`
|
|
290
|
+
-------------------------
|
|
291
|
+
This function will add `indent` spaces at the beginning of each line.<br>
|
|
292
|
+
**Params:**
|
|
293
|
+
- <code>code: *str*</code> the string to add the indent to
|
|
294
|
+
- <code>indent: *int*</code> the amount of spaces to add (*default* `4`)
|
|
295
|
+
|
|
296
|
+
**Returns:** the indented string
|
|
297
|
+
<br>
|
|
298
|
+
|
|
299
|
+
#### `Code.get_tab_spaces()`
|
|
300
|
+
-----------------------------
|
|
301
|
+
This function will try to get the amount of spaces that are used for indentation.<br>
|
|
302
|
+
**Params:**
|
|
303
|
+
- <code>code: *str*</code> the string to get the tab spaces from
|
|
304
|
+
|
|
305
|
+
**Returns:** the amount of spaces used for indentation
|
|
306
|
+
<br>
|
|
307
|
+
|
|
308
|
+
#### `Code.change_tab_size()`
|
|
309
|
+
------------------------------
|
|
310
|
+
This function will change the amount of spaces used for indentation.<br>
|
|
311
|
+
**Params:**
|
|
312
|
+
- <code>code: *str*</code> the string to change the tab size of
|
|
313
|
+
- <code>new_tab_size: *int*</code> the amount of spaces to use for indentation
|
|
314
|
+
- <code>remove_empty_lines: *bool*</code> whether to remove empty lines in the process
|
|
315
|
+
|
|
316
|
+
**Returns:** the string with the new tab size (*and no empty lines if* `remove_empty_lines` *is true*)
|
|
317
|
+
<br>
|
|
318
|
+
|
|
319
|
+
#### `Code.get_func_calls()`
|
|
320
|
+
This function will try to get all the function calls (*JavaScript, Python, etc. style functions*).<br>
|
|
321
|
+
**Params:**
|
|
322
|
+
- <code>code: *str*</code> the string to get the function calls from
|
|
323
|
+
|
|
324
|
+
**Returns:** a list of function calls
|
|
325
|
+
<br>
|
|
326
|
+
|
|
327
|
+
#### `Code.is_js()`
|
|
328
|
+
This function will check if the code is likely to be JavaScript.<br>
|
|
329
|
+
**Params:**
|
|
330
|
+
- <code>code: *str*</code> the string to check
|
|
331
|
+
|
|
332
|
+
**Returns:** `True` if the code is likely to be JavaScript and `False` otherwise
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
#### `String.normalize_spaces()`
|
|
339
|
+
-------------------------------
|
|
340
|
+
This function will replace all special space characters with normal spaces.<br>
|
|
341
|
+
**Params:**
|
|
342
|
+
- <code>code: *str*</code> the string to normalize
|
|
343
|
+
- <code>tab_spaces: *int*</code> the amount of spaces to replace tab characters with (*default* `4`)
|
|
344
|
+
|
|
345
|
+
**Returns:** the normalized string
|
|
346
|
+
<br>
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
<br id="bottom">
|
|
353
|
+
<br>
|
|
354
|
+
|
|
355
|
+
--------------------------------------------------------------
|
|
356
|
+
[View this library on PyPI](https://pypi.org/project/XulbuX/)
|
|
357
|
+
|
|
358
|
+
<div style="width:45px; height:45px; right:10px; position:absolute">
|
|
359
|
+
<a href="#top"><abbr title="go to top" style="text-decoration:none">
|
|
360
|
+
<div style="
|
|
361
|
+
font-size: 2em;
|
|
362
|
+
font-weight: bold;
|
|
363
|
+
background: #88889845;
|
|
364
|
+
border-radius: 0.2em;
|
|
365
|
+
text-align: center;
|
|
366
|
+
justify-content: center;
|
|
367
|
+
"><span style="display:none">go to top </span>🠩</div>
|
|
368
|
+
</abbr></a>
|
|
369
|
+
</div>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "XulbuX"
|
|
7
|
+
version = "1.5.7"
|
|
8
|
+
authors = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
|
|
9
|
+
description = "A library which includes a lot of really helpful functions."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
changelog = "CHANGELOG.md"
|
|
13
|
+
requires-python = ">=3.10.0"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"keyboard>=0.13.5",
|
|
16
|
+
"mouse>=0.7.1",
|
|
17
|
+
"pyperclip>=1.9.0",
|
|
18
|
+
"regex>=2023.10.3",
|
|
19
|
+
]
|
|
20
|
+
optional-dependencies = { dev = [
|
|
21
|
+
"pytest>=7.4.2",
|
|
22
|
+
"black>=23.7.0",
|
|
23
|
+
"isort>=5.12.0",
|
|
24
|
+
"flake8>=6.1.0",
|
|
25
|
+
] }
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"License :: OSI Approved :: MIT License",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
|
+
]
|
|
36
|
+
keywords = [
|
|
37
|
+
"xulbux",
|
|
38
|
+
"python",
|
|
39
|
+
"library",
|
|
40
|
+
"utility",
|
|
41
|
+
"helper",
|
|
42
|
+
"functions",
|
|
43
|
+
"tools",
|
|
44
|
+
"classes",
|
|
45
|
+
"types",
|
|
46
|
+
"methods",
|
|
47
|
+
"cmd",
|
|
48
|
+
"code",
|
|
49
|
+
"color",
|
|
50
|
+
"data",
|
|
51
|
+
"structures",
|
|
52
|
+
"env",
|
|
53
|
+
"environment",
|
|
54
|
+
"file",
|
|
55
|
+
"format",
|
|
56
|
+
"json",
|
|
57
|
+
"path",
|
|
58
|
+
"regex",
|
|
59
|
+
"string",
|
|
60
|
+
"system",
|
|
61
|
+
"operations",
|
|
62
|
+
"presets",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[project.urls]
|
|
66
|
+
"Homepage" = "https://github.com/XulbuX-dev/PythonLibraryXulbuX"
|
|
67
|
+
"Bug Reports" = "https://github.com/XulbuX-dev/PythonLibraryXulbuX/issues"
|
|
68
|
+
"Documentation" = "https://github.com/XulbuX-dev/PythonLibraryXulbuX/wiki"
|
|
69
|
+
"Source Code" = "https://github.com/XulbuX-dev/PythonLibraryXulbuX/tree/main/src"
|
|
70
|
+
"Changelog" = "https://github.com/XulbuX-dev/PythonLibraryXulbuX/blob/main/CHANGELOG.md"
|
|
71
|
+
|
|
72
|
+
[project.scripts]
|
|
73
|
+
xx-help = "XulbuX._cli_:help_command"
|
|
74
|
+
xulbux-help = "XulbuX._cli_:help_command"
|
|
75
|
+
|
|
76
|
+
[tool.black]
|
|
77
|
+
line-length = 127
|
|
78
|
+
target-version = ['py310', 'py311', 'py312', 'py313']
|
|
79
|
+
include = '\.pyi?$'
|
|
80
|
+
extend-exclude = '''
|
|
81
|
+
/(
|
|
82
|
+
# directories
|
|
83
|
+
\.eggs
|
|
84
|
+
| \.git
|
|
85
|
+
| \.hg
|
|
86
|
+
| \.mypy_cache
|
|
87
|
+
| \.tox
|
|
88
|
+
| \.venv
|
|
89
|
+
| build
|
|
90
|
+
| dist
|
|
91
|
+
)/
|
|
92
|
+
'''
|
|
93
|
+
|
|
94
|
+
[tool.isort]
|
|
95
|
+
profile = "black"
|
|
96
|
+
line_length = 127
|
|
97
|
+
multi_line_output = 3
|
|
98
|
+
include_trailing_comma = true
|
|
99
|
+
force_grid_wrap = 0
|
|
100
|
+
use_parentheses = true
|
|
101
|
+
ensure_newline_before_comments = true
|
|
102
|
+
|
|
103
|
+
[tool.flake8]
|
|
104
|
+
max-line-length = 127
|
|
105
|
+
extend-ignore = ["E203", "E266", "E501", "W503", "E303"]
|
|
106
|
+
max-complexity = 18
|
|
107
|
+
select = ["B", "C", "E", "F", "W", "T4", "B9"]
|
|
108
|
+
per-file-ignores = ["__init__.py:F401,F403"]
|
|
109
|
+
|
|
110
|
+
[tool.hatch.build.targets.wheel]
|
|
111
|
+
packages = ["src/xulbux"]
|
|
112
|
+
|
|
113
|
+
[tool.pytest.ini_options]
|
|
114
|
+
minversion = "7.0"
|
|
115
|
+
addopts = "-ra -q"
|
|
116
|
+
pythonpath = ["src"]
|
|
117
|
+
testpaths = ["tests/test_cmd_info.py", "tests/test_color_types.py"]
|