stouputils 1.2.7__tar.gz → 1.2.8__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.2.7 → stouputils-1.2.8}/PKG-INFO +1 -1
- {stouputils-1.2.7 → stouputils-1.2.8}/pyproject.toml +1 -1
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/applications/automatic_docs.py +2 -15
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/ctx.py +26 -5
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/dont_look/zip_file_override.py +4 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/.gitignore +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/LICENSE +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/README.md +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/__init__.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/all_doctests.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/applications/__init__.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/archive.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/backup.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/collections.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/continuous_delivery/__init__.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/continuous_delivery/cd_utils.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/continuous_delivery/github.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/continuous_delivery/pypi.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/continuous_delivery/pyproject.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/decorators.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/io.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/parallel.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/print.py +0 -0
- {stouputils-1.2.7 → stouputils-1.2.8}/stouputils/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.8
|
|
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
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "stouputils"
|
|
8
|
-
version = "1.2.
|
|
8
|
+
version = "1.2.8"
|
|
9
9
|
description = "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."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.10"
|
|
@@ -28,10 +28,6 @@ Example of usage:
|
|
|
28
28
|
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/applications/automatic_docs.gif
|
|
29
29
|
:alt: stouputils automatic_docs examples
|
|
30
30
|
|
|
31
|
-
Note:
|
|
32
|
-
This module requires Sphinx and its dependencies to be installed.
|
|
33
|
-
It also requires the 'm2r2' package for Markdown to RST conversion.
|
|
34
|
-
|
|
35
31
|
Example of GitHub Actions workflow:
|
|
36
32
|
|
|
37
33
|
.. code-block:: yaml
|
|
@@ -40,11 +36,8 @@ Example of GitHub Actions workflow:
|
|
|
40
36
|
|
|
41
37
|
on:
|
|
42
38
|
push:
|
|
43
|
-
branches:
|
|
44
|
-
- main
|
|
45
39
|
tags:
|
|
46
40
|
- 'v*'
|
|
47
|
-
pull_request:
|
|
48
41
|
workflow_dispatch:
|
|
49
42
|
|
|
50
43
|
permissions:
|
|
@@ -58,19 +51,13 @@ Example of GitHub Actions workflow:
|
|
|
58
51
|
- uses: actions/setup-python@v5
|
|
59
52
|
- name: Install dependencies
|
|
60
53
|
run: |
|
|
61
|
-
pip install hatch stouputils
|
|
54
|
+
pip install hatch stouputils
|
|
62
55
|
hatch build
|
|
63
|
-
- name: Build latest docs
|
|
64
|
-
if: github.ref == 'refs/heads/main'
|
|
65
|
-
run: |
|
|
66
|
-
python scripts/create_docs.py
|
|
67
56
|
- name: Build version docs
|
|
68
|
-
if: startsWith(github.ref, 'refs/tags/v')
|
|
69
57
|
run: |
|
|
70
58
|
python scripts/create_docs.py ${GITHUB_REF#refs/tags/v}
|
|
71
59
|
- name: Deploy to GitHub Pages
|
|
72
60
|
uses: peaceiris/actions-gh-pages@v3
|
|
73
|
-
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') }}
|
|
74
61
|
with:
|
|
75
62
|
publish_branch: gh-pages
|
|
76
63
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -206,7 +193,7 @@ autodoc_default_options: dict[str, bool | str] = {{
|
|
|
206
193
|
"member-order": "bysource",
|
|
207
194
|
"special-members": False,
|
|
208
195
|
"undoc-members": False,
|
|
209
|
-
"private-members":
|
|
196
|
+
"private-members": True,
|
|
210
197
|
"show-inheritance": True,
|
|
211
198
|
"ignore-module-all": True,
|
|
212
199
|
"exclude-members": "__weakref__",
|
|
@@ -27,17 +27,28 @@ class Muffle:
|
|
|
27
27
|
"""
|
|
28
28
|
def __init__(self, mute_stderr: bool = False) -> None:
|
|
29
29
|
self.mute_stderr: bool = mute_stderr
|
|
30
|
+
""" Attribute remembering if stderr should be muted """
|
|
31
|
+
self.original_stdout: TextIO = sys.stdout
|
|
32
|
+
""" Attribute remembering original stdout """
|
|
33
|
+
self.original_stderr: TextIO = sys.stderr
|
|
34
|
+
""" Attribute remembering original stderr """
|
|
30
35
|
|
|
31
36
|
def __enter__(self) -> None:
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
""" Enter context manager which redirects stdout and stderr to devnull """
|
|
38
|
+
# Redirect stdout to devnull
|
|
39
|
+
sys.stdout = open(os.devnull, "w")
|
|
40
|
+
|
|
41
|
+
# Redirect stderr to devnull if needed
|
|
34
42
|
if self.mute_stderr:
|
|
35
|
-
|
|
36
|
-
sys.stderr = open(os.devnull, 'w')
|
|
43
|
+
sys.stderr = open(os.devnull, "w")
|
|
37
44
|
|
|
38
45
|
def __exit__(self, exc_type: type[BaseException]|None, exc_val: BaseException|None, exc_tb: Any|None) -> None:
|
|
46
|
+
""" Exit context manager which restores original stdout and stderr """
|
|
47
|
+
# Restore original stdout
|
|
39
48
|
sys.stdout.close()
|
|
40
49
|
sys.stdout = self.original_stdout
|
|
50
|
+
|
|
51
|
+
# Restore original stderr if needed
|
|
41
52
|
if self.mute_stderr:
|
|
42
53
|
sys.stderr.close()
|
|
43
54
|
sys.stderr = self.original_stderr
|
|
@@ -64,15 +75,25 @@ class LogToFile:
|
|
|
64
75
|
"""
|
|
65
76
|
def __init__(self, path: str, mode: str = "w", encoding: str = "utf-8") -> None:
|
|
66
77
|
self.path: str = path
|
|
78
|
+
""" Attribute remembering path to the log file """
|
|
67
79
|
self.mode: str = mode
|
|
80
|
+
""" Attribute remembering mode to open the file in """
|
|
68
81
|
self.encoding: str = encoding
|
|
82
|
+
""" Attribute remembering encoding to use for the file """
|
|
83
|
+
self.file: IO[Any] = super_open(self.path, mode=self.mode, encoding=self.encoding)
|
|
84
|
+
""" Attribute remembering opened file """
|
|
69
85
|
|
|
70
86
|
def __enter__(self) -> None:
|
|
71
|
-
|
|
87
|
+
""" Enter context manager which opens the log file and adds it to the logging_to list """
|
|
88
|
+
# Add file to logging_to list
|
|
72
89
|
logging_to.add(self.file)
|
|
73
90
|
|
|
74
91
|
def __exit__(self, exc_type: type[BaseException]|None, exc_val: BaseException|None, exc_tb: Any|None) -> None:
|
|
92
|
+
""" Exit context manager which closes the log file and removes it from the logging_to list """
|
|
93
|
+
# Close file
|
|
75
94
|
self.file.close()
|
|
95
|
+
|
|
96
|
+
# Remove file from logging_to list
|
|
76
97
|
logging_to.discard(self.file)
|
|
77
98
|
|
|
78
99
|
@staticmethod
|
|
@@ -11,7 +11,10 @@ from zipfile import ZipFile, ZipInfo, ZipExtFile, _SharedFile, sizeFileHeader, s
|
|
|
11
11
|
|
|
12
12
|
# Class overrides
|
|
13
13
|
class ZipExtFileOverride(ZipExtFile):
|
|
14
|
+
""" Override of the ZipExtFile class """
|
|
15
|
+
|
|
14
16
|
def _update_crc(self, newdata) -> None: # type: ignore
|
|
17
|
+
""" Override of the _update_crc method """
|
|
15
18
|
# Update the CRC using the given data.
|
|
16
19
|
if self._expected_crc is None: # type: ignore
|
|
17
20
|
# No need to compute the CRC if we don't have a reference value
|
|
@@ -19,6 +22,7 @@ class ZipExtFileOverride(ZipExtFile):
|
|
|
19
22
|
self._running_crc = crc32(newdata, self._running_crc) # type: ignore
|
|
20
23
|
|
|
21
24
|
class ZipFileOverride(ZipFile):
|
|
25
|
+
""" Override of the ZipFile class """
|
|
22
26
|
|
|
23
27
|
def open(self, name, mode="r", pwd=None, *, force_zip64=False): # type: ignore
|
|
24
28
|
"""Return file-like object for 'name'.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|