stouputils 1.2.35__tar.gz → 1.2.36__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.
Files changed (35) hide show
  1. {stouputils-1.2.35 → stouputils-1.2.36}/.gitignore +21 -15
  2. {stouputils-1.2.35 → stouputils-1.2.36}/LICENSE +21 -21
  3. {stouputils-1.2.35 → stouputils-1.2.36}/PKG-INFO +1 -1
  4. {stouputils-1.2.35 → stouputils-1.2.36}/README.md +78 -78
  5. {stouputils-1.2.35 → stouputils-1.2.36}/pyproject.toml +33 -1
  6. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/__init__.py +33 -32
  7. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/all_doctests.py +113 -107
  8. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/applications/__init__.py +8 -1
  9. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/applications/automatic_docs.py +519 -519
  10. stouputils-1.2.36/stouputils/applications/upscaler/__init__.py +17 -0
  11. stouputils-1.2.36/stouputils/applications/upscaler/config.py +128 -0
  12. stouputils-1.2.36/stouputils/applications/upscaler/image.py +247 -0
  13. stouputils-1.2.36/stouputils/applications/upscaler/video.py +285 -0
  14. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/archive.py +124 -119
  15. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/backup.py +320 -314
  16. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/collections.py +62 -61
  17. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/continuous_delivery/__init__.py +25 -24
  18. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/continuous_delivery/cd_utils.py +141 -135
  19. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/continuous_delivery/github.py +456 -416
  20. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/continuous_delivery/pypi.py +90 -85
  21. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/continuous_delivery/pyproject.py +124 -121
  22. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/ctx.py +162 -160
  23. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/decorators.py +411 -407
  24. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/dont_look/zip_file_override.py +122 -112
  25. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/image.py +5 -2
  26. stouputils-1.2.36/stouputils/installer/__init__.py +18 -0
  27. stouputils-1.2.36/stouputils/installer/common.py +67 -0
  28. stouputils-1.2.36/stouputils/installer/downloader.py +101 -0
  29. stouputils-1.2.36/stouputils/installer/linux.py +144 -0
  30. stouputils-1.2.36/stouputils/installer/main.py +223 -0
  31. stouputils-1.2.36/stouputils/installer/windows.py +136 -0
  32. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/io.py +220 -219
  33. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/parallel.py +294 -229
  34. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/print.py +359 -335
  35. {stouputils-1.2.35 → stouputils-1.2.36}/stouputils/py.typed +1 -1
@@ -1,15 +1,21 @@
1
-
2
- # Python
3
- *__pycache__/
4
-
5
- # Miscellaneous
6
- __temporary__/
7
- output.log
8
- logfile.txt
9
-
10
- # Documentation
11
- docs/source/_static/
12
- docs/source/_templates/
13
- docs/source/modules/
14
- docs/source/index.rst
15
-
1
+
2
+ # Python
3
+ *__pycache__/
4
+
5
+ # Miscellaneous
6
+ __temporary__/
7
+ output.log
8
+ logfile.txt
9
+
10
+ # Documentation
11
+ docs/source/_static/
12
+ docs/source/_templates/
13
+ docs/source/modules/
14
+ docs/source/index.rst
15
+
16
+ # Examples
17
+ examples/archive/repaired.zip
18
+ examples/upscaler/input/*.mp4
19
+ examples/upscaler/progress/
20
+ examples/upscaler/output/
21
+
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Alexandre Collignon
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Alexandre Collignon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.2.35
3
+ Version: 1.2.36
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
@@ -1,78 +1,78 @@
1
- # 🛠️ Project Badges
2
- [![GitHub](https://img.shields.io/github/v/release/Stoupy51/stouputils?logo=github&label=GitHub)](https://github.com/Stoupy51/stouputils/releases/latest)
3
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/stouputils?logo=python&label=PyPI%20downloads)](https://pypi.org/project/stouputils/)
4
- [![Documentation](https://img.shields.io/github/v/release/Stoupy51/stouputils?logo=sphinx&label=Documentation&color=purple)](https://stoupy51.github.io/stouputils/latest/)
5
-
6
- <br>
7
-
8
- # 📚 Project Overview
9
- Stouputils is a collection of utility modules designed to simplify and enhance the development process.<br>
10
- It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers.
11
-
12
-
13
- # 🚀 Project File Tree
14
- <html>
15
- <details style="display: none;">
16
- <summary></summary>
17
- <style>
18
- .code-tree {
19
- border-radius: 6px;
20
- padding: 16px;
21
- font-family: monospace;
22
- line-height: 1.45;
23
- overflow: auto;
24
- white-space: pre;
25
- background-color:rgb(43, 43, 43);
26
- color: #d4d4d4;
27
- }
28
- .code-tree a {
29
- color: #569cd6;
30
- text-decoration: none;
31
- }
32
- .code-tree a:hover {
33
- text-decoration: underline;
34
- }
35
- .code-tree .comment {
36
- color:rgb(231, 213, 48);
37
- }
38
- </style>
39
- </details>
40
-
41
- <pre class="code-tree">stouputils/
42
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.applications.html">applications/</a>
43
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.applications.automatic_docs.html">automatic_docs.py</a> <span class="comment"># 📚 Documentation generation utilities (used to create this documentation)</span>
44
- │ └── ...
45
-
46
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.html">continuous_delivery/</a>
47
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.cd_utils.html">cd_utils.py</a> <span class="comment"># 🔧 Common utilities for continuous delivery</span>
48
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.github.html">github.py</a> <span class="comment"># 📦 GitHub utilities (upload_to_github)</span>
49
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pypi.html">pypi.py</a> <span class="comment"># 📦 PyPI utilities (pypi_full_routine)</span>
50
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pyproject.html">pyproject.py</a> <span class="comment"># 📝 Pyproject.toml utilities</span>
51
- │ └── ...
52
-
53
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Execution of all doctests for a given path</span>
54
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.archive.html">archive.py</a> <span class="comment"># 📦 Archive utilities (zip, repair_zip)</span>
55
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 📦 Backup utilities (delta backup, consolidate)</span>
56
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Collection utilities (unique_list)</span>
57
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.ctx.html">ctx.py</a> <span class="comment"># 🚫 Context managers (Muffle, LogToFile)</span>
58
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.decorators.html">decorators.py</a> <span class="comment"># 🎯 Decorators (silent, measure_time, error_handler, simple_cache)</span>
59
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Image utilities (image_resize)</span>
60
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💻 I/O utilities (file management, json)</span>
61
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🧑‍🤝‍🧑 Parallel processing (multiprocessing, multithreading)</span>
62
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.print.html">print.py</a> <span class="comment"># 🖨️ Display utilities (info, debug, warning, error)</span>
63
- └── ...
64
- </pre>
65
- </html>
66
-
67
- ## ⭐ Star History
68
-
69
- <html>
70
- <a href="https://star-history.com/#Stoupy51/stouputils&Date">
71
- <picture>
72
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Stoupy51/stouputils&type=Date&theme=dark" />
73
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Stoupy51/stouputils&type=Date" />
74
- <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Stoupy51/stouputils&type=Date" />
75
- </picture>
76
- </a>
77
- </html>
78
-
1
+ # 🛠️ Project Badges
2
+ [![GitHub](https://img.shields.io/github/v/release/Stoupy51/stouputils?logo=github&label=GitHub)](https://github.com/Stoupy51/stouputils/releases/latest)
3
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/stouputils?logo=python&label=PyPI%20downloads)](https://pypi.org/project/stouputils/)
4
+ [![Documentation](https://img.shields.io/github/v/release/Stoupy51/stouputils?logo=sphinx&label=Documentation&color=purple)](https://stoupy51.github.io/stouputils/latest/)
5
+
6
+ <br>
7
+
8
+ # 📚 Project Overview
9
+ Stouputils is a collection of utility modules designed to simplify and enhance the development process.<br>
10
+ It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers.
11
+
12
+
13
+ # 🚀 Project File Tree
14
+ <html>
15
+ <details style="display: none;">
16
+ <summary></summary>
17
+ <style>
18
+ .code-tree {
19
+ border-radius: 6px;
20
+ padding: 16px;
21
+ font-family: monospace;
22
+ line-height: 1.45;
23
+ overflow: auto;
24
+ white-space: pre;
25
+ background-color:rgb(43, 43, 43);
26
+ color: #d4d4d4;
27
+ }
28
+ .code-tree a {
29
+ color: #569cd6;
30
+ text-decoration: none;
31
+ }
32
+ .code-tree a:hover {
33
+ text-decoration: underline;
34
+ }
35
+ .code-tree .comment {
36
+ color:rgb(231, 213, 48);
37
+ }
38
+ </style>
39
+ </details>
40
+
41
+ <pre class="code-tree">stouputils/
42
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.applications.html">applications/</a>
43
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.applications.automatic_docs.html">automatic_docs.py</a> <span class="comment"># 📚 Documentation generation utilities (used to create this documentation)</span>
44
+ │ └── ...
45
+
46
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.html">continuous_delivery/</a>
47
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.cd_utils.html">cd_utils.py</a> <span class="comment"># 🔧 Common utilities for continuous delivery</span>
48
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.github.html">github.py</a> <span class="comment"># 📦 GitHub utilities (upload_to_github)</span>
49
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pypi.html">pypi.py</a> <span class="comment"># 📦 PyPI utilities (pypi_full_routine)</span>
50
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pyproject.html">pyproject.py</a> <span class="comment"># 📝 Pyproject.toml utilities</span>
51
+ │ └── ...
52
+
53
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Execution of all doctests for a given path</span>
54
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.archive.html">archive.py</a> <span class="comment"># 📦 Archive utilities (zip, repair_zip)</span>
55
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 📦 Backup utilities (delta backup, consolidate)</span>
56
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Collection utilities (unique_list)</span>
57
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.ctx.html">ctx.py</a> <span class="comment"># 🚫 Context managers (Muffle, LogToFile)</span>
58
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.decorators.html">decorators.py</a> <span class="comment"># 🎯 Decorators (silent, measure_time, error_handler, simple_cache)</span>
59
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Image utilities (image_resize)</span>
60
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💻 I/O utilities (file management, json)</span>
61
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🧑‍🤝‍🧑 Parallel processing (multiprocessing, multithreading)</span>
62
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.print.html">print.py</a> <span class="comment"># 🖨️ Display utilities (info, debug, warning, error)</span>
63
+ └── ...
64
+ </pre>
65
+ </html>
66
+
67
+ ## ⭐ Star History
68
+
69
+ <html>
70
+ <a href="https://star-history.com/#Stoupy51/stouputils&Date">
71
+ <picture>
72
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Stoupy51/stouputils&type=Date&theme=dark" />
73
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Stoupy51/stouputils&type=Date" />
74
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Stoupy51/stouputils&type=Date" />
75
+ </picture>
76
+ </a>
77
+ </html>
78
+
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
 
6
6
  [project]
7
7
  name = "stouputils"
8
- version = "1.2.35"
8
+ version = "1.2.36"
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"
@@ -34,6 +34,38 @@ Issues = "https://github.com/Stoupy51/stouputils/issues"
34
34
  [tool.pyright]
35
35
  typeCheckingMode = "strict"
36
36
 
37
+ [tool.ruff]
38
+ exclude = [
39
+ ".git",
40
+ ".ruff_cache",
41
+ ".venv",
42
+ ".vscode",
43
+ ".cursor",
44
+ "build",
45
+ "dist",
46
+ ]
47
+ line-length = 200
48
+
37
49
  [tool.hatch.build]
38
50
  include = ["stouputils"]
39
51
 
52
+ [tool.ruff.lint]
53
+ select = [
54
+ "E",
55
+ "W",
56
+ "F",
57
+ "I",
58
+ "N",
59
+ "UP",
60
+ "B",
61
+ "C4",
62
+ "T20",
63
+ "RUF",
64
+ ]
65
+ ignore = [
66
+ "T201",
67
+ "W191",
68
+ "N803",
69
+ "N806",
70
+ ]
71
+
@@ -1,32 +1,33 @@
1
- """ A collection of utility modules designed to simplify and enhance the development process.
2
-
3
- This package provides various tools and utilities for common development tasks including:
4
-
5
- Key Features:
6
- - Continuous delivery utilities (GitHub, PyPI)
7
- - Display and logging utilities (print)
8
- - File and I/O management (io)
9
- - Decorators for common patterns
10
- - Context managers
11
- - Archive and backup tools
12
- - Parallel processing helpers
13
- - Collection utilities
14
- - Doctests utilities
15
-
16
- """
17
-
18
- # Imports
19
- from .print import *
20
- from .archive import *
21
- from .io import *
22
- from .decorators import *
23
- from .ctx import *
24
- from .parallel import *
25
- from .all_doctests import *
26
- from .collections import *
27
- from .backup import *
28
- from .image import *
29
-
30
- # Folders
31
- from .continuous_delivery import *
32
-
1
+ """ A collection of utility modules designed to simplify and enhance the development process.
2
+
3
+ This package provides various tools and utilities for common development tasks including:
4
+
5
+ Key Features:
6
+ - Continuous delivery utilities (GitHub, PyPI)
7
+ - Display and logging utilities (print)
8
+ - File and I/O management (io)
9
+ - Decorators for common patterns
10
+ - Context managers
11
+ - Archive and backup tools
12
+ - Parallel processing helpers
13
+ - Collection utilities
14
+ - Doctests utilities
15
+
16
+ """
17
+ # ruff: noqa: F403
18
+
19
+ # Imports
20
+ from .all_doctests import *
21
+ from .archive import *
22
+ from .backup import *
23
+ from .collections import *
24
+
25
+ # Folders
26
+ from .continuous_delivery import *
27
+ from .ctx import *
28
+ from .decorators import *
29
+ from .image import *
30
+ from .io import *
31
+ from .parallel import *
32
+ from .print import *
33
+
@@ -1,107 +1,113 @@
1
- """
2
- This module is used to run all the doctests for all the modules in a given directory.
3
-
4
- .. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/all_doctests_module.gif
5
- :alt: stouputils all_doctests examples
6
- """
7
-
8
- # Imports
9
- import os
10
- import sys
11
- from .print import info, error, progress
12
- from .decorators import measure_time, handle_error, LogLevels
13
- from . import decorators
14
- from doctest import TestResults, testmod
15
- from types import ModuleType
16
- import importlib
17
- import pkgutil
18
-
19
- def test_module_with_progress(module: ModuleType, separator: str) -> TestResults:
20
- @measure_time(progress, message=f"Testing module '{module.__name__}' {separator}took")
21
- def internal() -> TestResults:
22
- return testmod(m=module)
23
- return internal()
24
-
25
- # Main program
26
- def launch_tests(root_dir: str, importing_errors: LogLevels = LogLevels.WARNING_TRACEBACK, strict: bool = True) -> int:
27
- """ Main function to launch tests for all modules in the given directory.
28
-
29
- Args:
30
- root_dir (str): Root directory to search for modules
31
- importing_errors (LogLevels): Log level for the errors when importing modules
32
- strict (bool): Modify the force_raise_exception variable to True in the decorators module
33
-
34
- Returns:
35
- int: The number of failed tests
36
-
37
- Examples:
38
- >>> launch_tests("unknown_dir")
39
- Traceback (most recent call last):
40
- ...
41
- ValueError: No modules found in 'unknown_dir'
42
-
43
- .. code-block:: python
44
-
45
- > if launch_tests("/path/to/source") > 0:
46
- sys.exit(1)
47
- [PROGRESS HH:MM:SS] Importing module 'module1' took 0.001s
48
- [PROGRESS HH:MM:SS] Importing module 'module2' took 0.002s
49
- [PROGRESS HH:MM:SS] Importing module 'module3' took 0.003s
50
- [PROGRESS HH:MM:SS] Importing module 'module4' took 0.004s
51
- [INFO HH:MM:SS] Testing 4 modules...
52
- [PROGRESS HH:MM:SS] Testing module 'module1' took 0.005s
53
- [PROGRESS HH:MM:SS] Testing module 'module2' took 0.006s
54
- [PROGRESS HH:MM:SS] Testing module 'module3' took 0.007s
55
- [PROGRESS HH:MM:SS] Testing module 'module4' took 0.008s
56
- """
57
- if strict:
58
- old_value: bool = strict
59
- decorators.force_raise_exception = True
60
- strict = old_value
61
-
62
-
63
- # Get all modules from folder
64
- sys.path.insert(0, root_dir)
65
- modules_file_paths: list[str] = []
66
- for directory_path, _, _ in os.walk(root_dir):
67
- for module_info in pkgutil.walk_packages([directory_path]):
68
- absolute_module_path: str = os.path.join(directory_path, module_info.name)
69
- path: str = absolute_module_path.split(root_dir, 1)[1].replace(os.sep, ".")[1:]
70
- if path not in modules_file_paths:
71
- modules_file_paths.append(path)
72
- if not modules_file_paths:
73
- raise ValueError(f"No modules found in '{root_dir}'")
74
-
75
- # Find longest module path for alignment
76
- max_length: int = max(len(path) for path in modules_file_paths)
77
-
78
- # Dynamically import all modules from iacob package recursively using pkgutil and importlib
79
- modules: list[ModuleType] = []
80
- separators: list[str] = []
81
- for module_path in modules_file_paths:
82
- separator: str = " " * (max_length - len(module_path))
83
- @handle_error(error_log=importing_errors)
84
- @measure_time(progress, message=f"Importing module '{module_path}' {separator}took")
85
- def internal() -> None:
86
- modules.append(importlib.import_module(module_path))
87
- separators.append(separator)
88
- internal()
89
-
90
- # Run tests for each module
91
- info(f"Testing {len(modules)} modules...")
92
- separators = [s + " "*(len("Importing") - len("Testing")) for s in separators]
93
- results: list[TestResults] = [test_module_with_progress(module, separator) for module, separator in zip(modules, separators)]
94
-
95
- # Display any error lines for each module at the end of the script
96
- nb_failed_tests: int = 0
97
- for module, result in zip(modules, results):
98
- if result.failed > 0:
99
- error(f"Errors in module {module.__name__}", exit=False)
100
- nb_failed_tests += result.failed
101
-
102
- # Reset force_raise_exception back
103
- decorators.force_raise_exception = strict
104
-
105
- # Return the number of failed tests
106
- return nb_failed_tests
107
-
1
+ """
2
+ This module is used to run all the doctests for all the modules in a given directory.
3
+
4
+ .. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/all_doctests_module.gif
5
+ :alt: stouputils all_doctests examples
6
+ """
7
+
8
+ # Imports
9
+ import importlib
10
+ import os
11
+ import pkgutil
12
+ import sys
13
+ from doctest import TestResults, testmod
14
+ from types import ModuleType
15
+
16
+ from . import decorators
17
+ from .decorators import LogLevels, handle_error, measure_time
18
+ from .print import error, info, progress
19
+
20
+
21
+ def test_module_with_progress(module: ModuleType, separator: str) -> TestResults:
22
+ @measure_time(progress, message=f"Testing module '{module.__name__}' {separator}took")
23
+ def internal() -> TestResults:
24
+ return testmod(m=module)
25
+ return internal()
26
+
27
+ # Main program
28
+ def launch_tests(root_dir: str, importing_errors: LogLevels = LogLevels.WARNING_TRACEBACK, strict: bool = True) -> int:
29
+ """ Main function to launch tests for all modules in the given directory.
30
+
31
+ Args:
32
+ root_dir (str): Root directory to search for modules
33
+ importing_errors (LogLevels): Log level for the errors when importing modules
34
+ strict (bool): Modify the force_raise_exception variable to True in the decorators module
35
+
36
+ Returns:
37
+ int: The number of failed tests
38
+
39
+ Examples:
40
+ >>> launch_tests("unknown_dir")
41
+ Traceback (most recent call last):
42
+ ...
43
+ ValueError: No modules found in 'unknown_dir'
44
+
45
+ .. code-block:: python
46
+
47
+ > if launch_tests("/path/to/source") > 0:
48
+ sys.exit(1)
49
+ [PROGRESS HH:MM:SS] Importing module 'module1' took 0.001s
50
+ [PROGRESS HH:MM:SS] Importing module 'module2' took 0.002s
51
+ [PROGRESS HH:MM:SS] Importing module 'module3' took 0.003s
52
+ [PROGRESS HH:MM:SS] Importing module 'module4' took 0.004s
53
+ [INFO HH:MM:SS] Testing 4 modules...
54
+ [PROGRESS HH:MM:SS] Testing module 'module1' took 0.005s
55
+ [PROGRESS HH:MM:SS] Testing module 'module2' took 0.006s
56
+ [PROGRESS HH:MM:SS] Testing module 'module3' took 0.007s
57
+ [PROGRESS HH:MM:SS] Testing module 'module4' took 0.008s
58
+ """
59
+ if strict:
60
+ old_value: bool = strict
61
+ decorators.force_raise_exception = True
62
+ strict = old_value
63
+
64
+
65
+ # Get all modules from folder
66
+ sys.path.insert(0, root_dir)
67
+ modules_file_paths: list[str] = []
68
+ for directory_path, _, _ in os.walk(root_dir):
69
+ for module_info in pkgutil.walk_packages([directory_path]):
70
+ absolute_module_path: str = os.path.join(directory_path, module_info.name)
71
+ path: str = absolute_module_path.split(root_dir, 1)[1].replace(os.sep, ".")[1:]
72
+ if path not in modules_file_paths:
73
+ modules_file_paths.append(path)
74
+ if not modules_file_paths:
75
+ raise ValueError(f"No modules found in '{root_dir}'")
76
+
77
+ # Find longest module path for alignment
78
+ max_length: int = max(len(path) for path in modules_file_paths)
79
+
80
+ # Dynamically import all modules from iacob package recursively using pkgutil and importlib
81
+ modules: list[ModuleType] = []
82
+ separators: list[str] = []
83
+ for module_path in modules_file_paths:
84
+ separator: str = " " * (max_length - len(module_path))
85
+
86
+ @handle_error(error_log=importing_errors)
87
+ @measure_time(progress, message=f"Importing module '{module_path}' {separator}took")
88
+ def internal(a: str = module_path, b: str = separator) -> None:
89
+ modules.append(importlib.import_module(a))
90
+ separators.append(b)
91
+ internal()
92
+
93
+ # Run tests for each module
94
+ info(f"Testing {len(modules)} modules...")
95
+ separators = [s + " "*(len("Importing") - len("Testing")) for s in separators]
96
+ results: list[TestResults] = [
97
+ test_module_with_progress(module, separator)
98
+ for module, separator in zip(modules, separators, strict=False)
99
+ ]
100
+
101
+ # Display any error lines for each module at the end of the script
102
+ nb_failed_tests: int = 0
103
+ for module, result in zip(modules, results, strict=False):
104
+ if result.failed > 0:
105
+ error(f"Errors in module {module.__name__}", exit=False)
106
+ nb_failed_tests += result.failed
107
+
108
+ # Reset force_raise_exception back
109
+ decorators.force_raise_exception = strict
110
+
111
+ # Return the number of failed tests
112
+ return nb_failed_tests
113
+
@@ -2,14 +2,21 @@
2
2
 
3
3
  This module provides higher-level utilities for specific application needs:
4
4
 
5
- Key Features:
5
+ Automatic Documentation:
6
+
6
7
  - Automatic documentation generation with Sphinx: `update_documentation(...)`
7
8
  - Support for multi-version documentation
8
9
  - GitHub Pages integration
9
10
  - Markdown to RST conversion
10
11
 
12
+ Upscaler:
13
+
14
+ - TODO
15
+
11
16
  """
17
+ # ruff: noqa: F403
12
18
 
13
19
  # Imports
14
20
  from .automatic_docs import *
21
+ from .upscaler import *
15
22