stouputils 1.0.20__tar.gz → 1.0.22__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.
- {stouputils-1.0.20 → stouputils-1.0.22}/.github/workflows/documentation.yml +42 -29
- {stouputils-1.0.20 → stouputils-1.0.22}/PKG-INFO +2 -1
- {stouputils-1.0.20 → stouputils-1.0.22}/README.md +1 -0
- stouputils-1.0.22/assets/all_doctests_module.gif +0 -0
- stouputils-1.0.22/assets/archive_module.gif +0 -0
- stouputils-1.0.22/assets/backup_module.gif +0 -0
- stouputils-1.0.22/assets/collections_module.gif +0 -0
- stouputils-1.0.22/assets/ctx_module.gif +0 -0
- stouputils-1.0.22/assets/decorators_module_1.gif +0 -0
- stouputils-1.0.22/assets/decorators_module_2.gif +0 -0
- stouputils-1.0.22/assets/io_module.gif +0 -0
- stouputils-1.0.22/assets/parallel_module.gif +0 -0
- stouputils-1.0.22/assets/print_module.gif +0 -0
- stouputils-1.0.22/examples/all_doctests.py +17 -0
- stouputils-1.0.22/examples/archive/corrupted.zip +0 -0
- stouputils-1.0.22/examples/archive.py +24 -0
- stouputils-1.0.22/examples/collections.py +28 -0
- stouputils-1.0.22/examples/ctx.py +25 -0
- stouputils-1.0.22/examples/decorators_1.py +29 -0
- stouputils-1.0.22/examples/decorators_2.py +21 -0
- stouputils-1.0.22/examples/delta_backup.py +7 -0
- stouputils-1.0.22/examples/io.py +33 -0
- stouputils-1.0.22/examples/parallel.py +28 -0
- stouputils-1.0.22/examples/print.py +27 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/pyproject.toml +1 -1
- stouputils-1.0.22/scripts/create_docs.py +315 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/all_doctests.py +8 -5
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/archive.py +14 -4
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/backup.py +3 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/collections.py +3 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/continuous_delivery/cd_utils.py +1 -1
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/continuous_delivery/github.py +11 -4
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/ctx.py +12 -6
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/decorators.py +25 -52
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/dont_look/zip_file_override.py +1 -8
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/io.py +4 -2
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/parallel.py +18 -15
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/print.py +22 -21
- stouputils-1.0.20/doctests.py +0 -17
- stouputils-1.0.20/examples/delta_backup.py +0 -7
- stouputils-1.0.20/scripts/create_docs.py +0 -133
- {stouputils-1.0.20 → stouputils-1.0.22}/.gitignore +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/.python-version +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/1_upgrades.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/2_build.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/3_upload.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/LICENSE +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/all_in_one.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/build_all_in_one.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/copy_in_local.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/github_release.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/__init__.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/continuous_delivery/__init__.py +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/src/stouputils/py.typed +0 -0
- {stouputils-1.0.20 → stouputils-1.0.22}/upgrade.py +0 -0
|
@@ -1,29 +1,42 @@
|
|
|
1
|
-
name: documentation
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- name:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
name: documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- 'v*'
|
|
9
|
+
pull_request:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
docs:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: |
|
|
23
|
+
pip install hatch stouputils sphinx sphinx_rtd_theme myst_parser furo
|
|
24
|
+
hatch build
|
|
25
|
+
- name: Build latest docs
|
|
26
|
+
if: github.ref == 'refs/heads/main'
|
|
27
|
+
run: |
|
|
28
|
+
python scripts/create_docs.py
|
|
29
|
+
- name: Build version docs
|
|
30
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
31
|
+
run: |
|
|
32
|
+
python scripts/create_docs.py ${GITHUB_REF#refs/tags/v}
|
|
33
|
+
- name: Deploy to GitHub Pages
|
|
34
|
+
uses: peaceiris/actions-gh-pages@v3
|
|
35
|
+
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') }}
|
|
36
|
+
with:
|
|
37
|
+
publish_branch: gh-pages
|
|
38
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
39
|
+
publish_dir: docs/build/html
|
|
40
|
+
keep_files: true
|
|
41
|
+
force_orphan: false
|
|
42
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.22
|
|
4
4
|
Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Stoupy51/stouputils
|
|
6
6
|
Project-URL: Issues, https://github.com/Stoupy51/stouputils/issues
|
|
@@ -19,6 +19,7 @@ Description-Content-Type: text/markdown
|
|
|
19
19
|
# 🛠️ Project Badges
|
|
20
20
|
[](https://github.com/Stoupy51/stouputils/releases/latest)
|
|
21
21
|
[](https://pypi.org/project/stouputils/)
|
|
22
|
+
[](https://stoupy51.github.io/stouputils/latest/)
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
# 📚 Project Overview
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# 🛠️ Project Badges
|
|
3
3
|
[](https://github.com/Stoupy51/stouputils/releases/latest)
|
|
4
4
|
[](https://pypi.org/project/stouputils/)
|
|
5
|
+
[](https://stoupy51.github.io/stouputils/latest/)
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
# 📚 Project Overview
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import os
|
|
4
|
+
import stouputils as stp
|
|
5
|
+
|
|
6
|
+
# Constants
|
|
7
|
+
ROOT: str = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
+
FOLDER_TO_TEST: str = f"{ROOT}/../src"
|
|
9
|
+
|
|
10
|
+
# Main
|
|
11
|
+
@stp.measure_time(stp.info, message="All doctests finished")
|
|
12
|
+
def main() -> None:
|
|
13
|
+
stp.launch_tests(FOLDER_TO_TEST)
|
|
14
|
+
|
|
15
|
+
if __name__ == "__main__":
|
|
16
|
+
main()
|
|
17
|
+
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
from zipfile import ZipFile, BadZipFile
|
|
5
|
+
|
|
6
|
+
# Main
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
PREFIX: str = "examples/archive"
|
|
9
|
+
|
|
10
|
+
## Repair a corrupted zip file
|
|
11
|
+
# Try to read the first file
|
|
12
|
+
@stp.handle_error(BadZipFile)
|
|
13
|
+
def read_file() -> None:
|
|
14
|
+
with ZipFile(f"{PREFIX}/corrupted.zip", "r") as zip_file:
|
|
15
|
+
stp.info(zip_file.read("pack.mcmeta"))
|
|
16
|
+
read_file()
|
|
17
|
+
|
|
18
|
+
# Repair it
|
|
19
|
+
stp.repair_zip_file(f"{PREFIX}/corrupted.zip", f"{PREFIX}/repaired.zip")
|
|
20
|
+
|
|
21
|
+
# Read the first file
|
|
22
|
+
with ZipFile(f"{PREFIX}/repaired.zip", "r") as zip_file:
|
|
23
|
+
stp.info(zip_file.read("pack.mcmeta"))
|
|
24
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
|
|
5
|
+
# Main
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
|
|
8
|
+
# Example with numbers
|
|
9
|
+
numbers: list[int] = [1, 2, 3, 2, 1, 4, 3]
|
|
10
|
+
unique_numbers: list[int] = stp.unique_list(numbers)
|
|
11
|
+
stp.info(f"Original numbers: {numbers}")
|
|
12
|
+
stp.info(f"Unique numbers: {unique_numbers}")
|
|
13
|
+
|
|
14
|
+
# Example with sets using different methods
|
|
15
|
+
s1: set[int] = {1, 2, 3}
|
|
16
|
+
s2: set[int] = {2, 3, 4}
|
|
17
|
+
s3: set[int] = {1, 2, 3}
|
|
18
|
+
sets: list[set[int]] = [s1, s2, s1, s1, s3, s2, s3]
|
|
19
|
+
|
|
20
|
+
# Using id method (keeps s1 and s3 as separate objects)
|
|
21
|
+
unique_sets_id: list[set[int]] = stp.unique_list(sets, method="id")
|
|
22
|
+
stp.info(f"Unique sets (id method): {unique_sets_id}")
|
|
23
|
+
|
|
24
|
+
# Using str method (combines s1 and s3 as they have same string representation)
|
|
25
|
+
unique_sets_str: list[set[int]] = stp.unique_list(sets, method="str")
|
|
26
|
+
stp.info(f"Unique sets (str method): {unique_sets_str}")
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
import sys
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
# Main
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
|
|
10
|
+
with stp.Muffle(mute_stderr=True):
|
|
11
|
+
print("Nothing")
|
|
12
|
+
print("here", file=sys.stderr)
|
|
13
|
+
stp.info("will be")
|
|
14
|
+
stp.info("printed", file=sys.stderr)
|
|
15
|
+
|
|
16
|
+
OUTPUT_PATH: str = "_super_idol_de_xiao_rong.log"
|
|
17
|
+
with stp.LogToFile(OUTPUT_PATH):
|
|
18
|
+
stp.info("""
|
|
19
|
+
Why did the programmer always bring a ladder to work?
|
|
20
|
+
Because they spent so much time debugging and climbing through their log files!
|
|
21
|
+
""")
|
|
22
|
+
|
|
23
|
+
stp.breakpoint("Press Enter to continue...")
|
|
24
|
+
os.remove(OUTPUT_PATH)
|
|
25
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
# Main
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
|
|
9
|
+
# Cache the result of the function and measure the time it takes to execute
|
|
10
|
+
@stp.measure_time(stp.progress, "Time taken to execute long_function")
|
|
11
|
+
@stp.simple_cache()
|
|
12
|
+
def long_function() -> dict[str, int]:
|
|
13
|
+
stp.info("Starting long function...")
|
|
14
|
+
time.sleep(1)
|
|
15
|
+
stp.info("Long function finished!")
|
|
16
|
+
return {"a": 1, "b": 2}
|
|
17
|
+
|
|
18
|
+
a = long_function() # Takes 1 second
|
|
19
|
+
b = long_function() # Takes 0 second
|
|
20
|
+
stp.info(f"a: {a}, b: {b}, a is b: {a is b}")
|
|
21
|
+
b["c"] = 3
|
|
22
|
+
stp.info(f"a has been modified because a is b: {a}")
|
|
23
|
+
|
|
24
|
+
# Silent decorator
|
|
25
|
+
@stp.silent
|
|
26
|
+
def silent_function():
|
|
27
|
+
print("ON THE CONSOLE")
|
|
28
|
+
silent_function()
|
|
29
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
|
|
5
|
+
# Main
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
|
|
8
|
+
# Handle exceptions
|
|
9
|
+
@stp.handle_error(ZeroDivisionError,
|
|
10
|
+
"Debugging: The process of removing software bugs, and putting in new ones",
|
|
11
|
+
error_log=stp.LogLevels.WARNING_TRACEBACK
|
|
12
|
+
)
|
|
13
|
+
def raise_value_error():
|
|
14
|
+
return 1 / 0
|
|
15
|
+
|
|
16
|
+
@stp.handle_error()
|
|
17
|
+
def raise_value_error_2():
|
|
18
|
+
return 1 / 0
|
|
19
|
+
|
|
20
|
+
raise_value_error() # This will show the error using stp.warning
|
|
21
|
+
raise_value_error_2() # This will show the error using stp.error
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
# Main
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
|
|
9
|
+
path: str = "C:\\\\Users\\\\Stoupy\\\\Documents\\\\test.txt"
|
|
10
|
+
path = stp.clean_path(path)
|
|
11
|
+
stp.info(path)
|
|
12
|
+
|
|
13
|
+
tilde_path: str = "~/Desktop/OnlyFansIncome.txt"
|
|
14
|
+
tilde_path = stp.replace_tilde(tilde_path)
|
|
15
|
+
stp.info(tilde_path)
|
|
16
|
+
|
|
17
|
+
this_folder_dont_exist: str = "./this_folder_dont_exist/a/c/feff/efefe/a"
|
|
18
|
+
with stp.super_open(this_folder_dont_exist, "w") as file: # Automatically create the folder
|
|
19
|
+
file.write("Hello, world!")
|
|
20
|
+
|
|
21
|
+
# Copy a file to a folder, or rename the copied file
|
|
22
|
+
stp.super_copy("LICENSE", "this_folder_dont_exist/a/") # .../a/LICENSE
|
|
23
|
+
stp.super_copy("LICENSE", "this_folder_dont_exist/a/LICENSE_2") # .../a/LICENSE_2
|
|
24
|
+
stp.breakpoint("Waiting for input to continue code execution...")
|
|
25
|
+
|
|
26
|
+
# Dump a JSON file with a specified indentation depth
|
|
27
|
+
data: dict[str, Any] = {"name": "John", "array": [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]}
|
|
28
|
+
stp.info("\n", stp.super_json_dump(data, max_level=2))
|
|
29
|
+
|
|
30
|
+
# Remove the folder
|
|
31
|
+
import shutil
|
|
32
|
+
shutil.rmtree("this_folder_dont_exist")
|
|
33
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
# Functions
|
|
7
|
+
def is_even(n: int) -> bool:
|
|
8
|
+
return n % 2 == 0
|
|
9
|
+
|
|
10
|
+
def multiple_args(a: int, b: int) -> int:
|
|
11
|
+
return a * b
|
|
12
|
+
|
|
13
|
+
# Main
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
|
|
16
|
+
# Multi-threading (blazingly fast for IO-bound tasks)
|
|
17
|
+
args_1: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
18
|
+
results_1: list[bool] = stp.multithreading(is_even, args_1)
|
|
19
|
+
stp.info(f"Results: {results_1}")
|
|
20
|
+
|
|
21
|
+
# Multi-processing (better for CPU-bound tasks)
|
|
22
|
+
time.sleep(1)
|
|
23
|
+
args_2: list[tuple[int, int]] = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
|
|
24
|
+
results_2: list[int] = stp.multiprocessing(
|
|
25
|
+
multiple_args, args_2, use_starmap=True, desc="Multiple args", max_workers=2, verbose=1
|
|
26
|
+
)
|
|
27
|
+
stp.info(f"Results: {results_2}")
|
|
28
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import time
|
|
4
|
+
import stouputils as stp
|
|
5
|
+
|
|
6
|
+
# Main
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
stp.info("Hello", "World")
|
|
9
|
+
time.sleep(0.5)
|
|
10
|
+
stp.info("Hello", "World")
|
|
11
|
+
time.sleep(0.5)
|
|
12
|
+
stp.info("Hello", "World")
|
|
13
|
+
time.sleep(0.5)
|
|
14
|
+
stp.info("Not Hello World !")
|
|
15
|
+
time.sleep(0.5)
|
|
16
|
+
stp.info("Hello", "World")
|
|
17
|
+
time.sleep(0.5)
|
|
18
|
+
stp.info("Hello", "World")
|
|
19
|
+
|
|
20
|
+
# All remaining print functions
|
|
21
|
+
stp.debug("Hello", "World")
|
|
22
|
+
stp.suggestion("Hello", "World")
|
|
23
|
+
stp.progress("Hello", "World")
|
|
24
|
+
stp.warning("Hello", "World")
|
|
25
|
+
stp.error("Hello", "World", exit=False)
|
|
26
|
+
stp.whatisit("Hello", "World")
|
|
27
|
+
|