stouputils 1.0.25__tar.gz → 1.0.26__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 (54) hide show
  1. {stouputils-1.0.25 → stouputils-1.0.26}/PKG-INFO +5 -5
  2. {stouputils-1.0.25 → stouputils-1.0.26}/pyproject.toml +8 -5
  3. stouputils-1.0.25/.github/workflows/documentation.yml +0 -42
  4. stouputils-1.0.25/.python-version +0 -1
  5. stouputils-1.0.25/assets/all_doctests_module.gif +0 -0
  6. stouputils-1.0.25/assets/archive_module.gif +0 -0
  7. stouputils-1.0.25/assets/backup_module.gif +0 -0
  8. stouputils-1.0.25/assets/collections_module.gif +0 -0
  9. stouputils-1.0.25/assets/continuous_delivery/github_module.gif +0 -0
  10. stouputils-1.0.25/assets/continuous_delivery/pypi_module.gif +0 -0
  11. stouputils-1.0.25/assets/continuous_delivery/pyproject_module.gif +0 -0
  12. stouputils-1.0.25/assets/ctx_module.gif +0 -0
  13. stouputils-1.0.25/assets/decorators_module_1.gif +0 -0
  14. stouputils-1.0.25/assets/decorators_module_2.gif +0 -0
  15. stouputils-1.0.25/assets/io_module.gif +0 -0
  16. stouputils-1.0.25/assets/parallel_module.gif +0 -0
  17. stouputils-1.0.25/assets/print_module.gif +0 -0
  18. stouputils-1.0.25/copy_in_local.py +0 -22
  19. stouputils-1.0.25/examples/all_doctests.py +0 -13
  20. stouputils-1.0.25/examples/archive/corrupted.zip +0 -0
  21. stouputils-1.0.25/examples/archive.py +0 -24
  22. stouputils-1.0.25/examples/collections.py +0 -28
  23. stouputils-1.0.25/examples/ctx.py +0 -25
  24. stouputils-1.0.25/examples/decorators_1.py +0 -29
  25. stouputils-1.0.25/examples/decorators_2.py +0 -21
  26. stouputils-1.0.25/examples/delta_backup.py +0 -7
  27. stouputils-1.0.25/examples/io.py +0 -33
  28. stouputils-1.0.25/examples/parallel.py +0 -28
  29. stouputils-1.0.25/examples/print.py +0 -27
  30. stouputils-1.0.25/full_routine.py +0 -18
  31. stouputils-1.0.25/scripts/create_docs.py +0 -315
  32. stouputils-1.0.25/scripts/github_release.py +0 -28
  33. stouputils-1.0.25/scripts/pypi_full_routine.py +0 -20
  34. stouputils-1.0.25/scripts/upgrade.py +0 -11
  35. {stouputils-1.0.25 → stouputils-1.0.26}/.gitignore +0 -0
  36. {stouputils-1.0.25 → stouputils-1.0.26}/LICENSE +0 -0
  37. {stouputils-1.0.25 → stouputils-1.0.26}/README.md +0 -0
  38. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/__init__.py +0 -0
  39. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/all_doctests.py +0 -0
  40. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/archive.py +0 -0
  41. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/backup.py +0 -0
  42. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/collections.py +0 -0
  43. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/continuous_delivery/__init__.py +0 -0
  44. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/continuous_delivery/cd_utils.py +0 -0
  45. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/continuous_delivery/github.py +0 -0
  46. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/continuous_delivery/pypi.py +0 -0
  47. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/continuous_delivery/pyproject.py +0 -0
  48. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/ctx.py +0 -0
  49. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/decorators.py +0 -0
  50. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/dont_look/zip_file_override.py +0 -0
  51. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/io.py +0 -0
  52. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/parallel.py +0 -0
  53. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/print.py +0 -0
  54. {stouputils-1.0.25 → stouputils-1.0.26}/src/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.0.25
3
+ Version: 1.0.26
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
@@ -10,10 +10,10 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.10
13
- Requires-Dist: pyyaml
14
- Requires-Dist: requests>=2.31.0
15
- Requires-Dist: toml
16
- Requires-Dist: tqdm>=4.66.4
13
+ Requires-Dist: pyyaml>=6.0.0
14
+ Requires-Dist: requests>=2.30.0
15
+ Requires-Dist: toml>=0.10.0
16
+ Requires-Dist: tqdm>=4.66.0
17
17
  Description-Content-Type: text/markdown
18
18
 
19
19
 
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
 
6
6
  [project]
7
7
  name = "stouputils"
8
- version = "1.0.25"
8
+ version = "1.0.26"
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"
@@ -15,10 +15,10 @@ classifiers = [
15
15
  "Operating System :: OS Independent",
16
16
  ]
17
17
  dependencies = [
18
- "tqdm>=4.66.4",
19
- "requests>=2.31.0",
20
- "pyyaml",
21
- "toml",
18
+ "tqdm>=4.66.0",
19
+ "requests>=2.30.0",
20
+ "pyyaml>=6.0.0",
21
+ "toml>=0.10.0",
22
22
  ]
23
23
  [[project.authors]]
24
24
  name = "Stoupy51"
@@ -31,3 +31,6 @@ Issues = "https://github.com/Stoupy51/stouputils/issues"
31
31
  [tool.pyright]
32
32
  typeCheckingMode = "strict"
33
33
 
34
+ [tool.hatch.build]
35
+ include = ["src"]
36
+
@@ -1,42 +0,0 @@
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 +0,0 @@
1
- 3.10
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,22 +0,0 @@
1
-
2
- # Imports
3
- import stouputils as stp
4
- import shutil
5
-
6
- # Constants
7
- ROOT: str = stp.get_root_path(__file__)
8
- SOURCE: str = f"{ROOT}/src/stouputils"
9
- DESTINATION: str = "C:/Users/Alexandre-PC/AppData/Local/Programs/Python/Python310/Lib/site-packages/stouputils"
10
-
11
- # Main
12
- if __name__ == "__main__":
13
-
14
- # Remove destination
15
- shutil.rmtree(DESTINATION, ignore_errors=True)
16
-
17
- # Copy source
18
- shutil.copytree(SOURCE, DESTINATION)
19
-
20
- # Info
21
- stp.info("Copied stouputils to local Python's site-packages")
22
-
@@ -1,13 +0,0 @@
1
-
2
- # Imports
3
- import stouputils as stp
4
-
5
- # Main
6
- @stp.measure_time(stp.info, message="All doctests finished")
7
- def main() -> None:
8
- FOLDER_TO_TEST: str = stp.get_root_path(__file__, 1) + "/src"
9
- stp.launch_tests(FOLDER_TO_TEST)
10
-
11
- if __name__ == "__main__":
12
- main()
13
-
@@ -1,24 +0,0 @@
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
-
@@ -1,28 +0,0 @@
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
-
@@ -1,25 +0,0 @@
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
-
@@ -1,29 +0,0 @@
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
-
@@ -1,21 +0,0 @@
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
@@ -1,7 +0,0 @@
1
-
2
- # Example of use:
3
- # py examples/delta_backup.py delta "src" "backup" -x "*pycache*"
4
-
5
- import stouputils as stp
6
- stp.backup_cli()
7
-
@@ -1,33 +0,0 @@
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
-
@@ -1,28 +0,0 @@
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
-
@@ -1,27 +0,0 @@
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
-
@@ -1,18 +0,0 @@
1
-
2
- # Imports
3
- import os
4
- import sys
5
- import stouputils as stp
6
-
7
- # Constants
8
- ROOT: str = stp.get_root_path(__file__)
9
-
10
- # Main
11
- if __name__ == "__main__":
12
-
13
- # Increment version in pyproject.toml
14
- stp.increment_version_from_pyproject(f"{ROOT}/pyproject.toml")
15
-
16
- # PyPI full routine
17
- os.system(f"{sys.executable} {ROOT}/scripts/pypi_full_routine.py")
18
-
@@ -1,315 +0,0 @@
1
-
2
- # Imports
3
- import os
4
- import shutil
5
- import subprocess
6
- import sys
7
- from stouputils import clean_path, handle_error, warning, simple_cache
8
- from stouputils.continuous_delivery.github import version_to_float
9
- clean_exec: str = clean_path(sys.executable)
10
-
11
- conf_content: str = """
12
- # Imports
13
- import os
14
- import sys
15
- from typing import Any
16
- sys.path.insert(0, os.path.abspath('../..'))
17
- sys.path.insert(0, os.path.abspath('../../src'))
18
- from upgrade import current_version # Get version from pyproject.toml
19
-
20
- # Project information
21
- project: str = 'stouputils'
22
- copyright: str = '2024, Stoupy'
23
- author: str = 'Stoupy'
24
- release: str = current_version
25
-
26
- # General configuration
27
- extensions: list[str] = [
28
- 'sphinx.ext.autodoc',
29
- 'sphinx.ext.napoleon',
30
- 'sphinx.ext.viewcode',
31
- 'sphinx.ext.githubpages',
32
- 'sphinx.ext.intersphinx',
33
- 'furo.sphinxext',
34
- ]
35
-
36
- templates_path: list[str] = ['_templates']
37
- exclude_patterns: list[str] = []
38
-
39
- # HTML output options
40
- html_theme: str = 'furo'
41
- html_static_path: list[str] = ['_static']
42
- html_logo: str = 'https://avatars.githubusercontent.com/u/35665974'
43
- html_title: str = 'stouputils'
44
- html_favicon: str = 'https://avatars.githubusercontent.com/u/35665974'
45
-
46
- # Theme options
47
- html_theme_options: dict[str, Any] = {
48
- 'light_css_variables': {
49
- 'color-brand-primary': '#2980B9',
50
- 'color-brand-content': '#2980B9',
51
- 'color-admonition-background': '#E8F0F8',
52
- },
53
- 'dark_css_variables': {
54
- 'color-brand-primary': '#56B4E9',
55
- 'color-brand-content': '#56B4E9',
56
- 'color-admonition-background': '#1F262B',
57
- },
58
- 'sidebar_hide_name': False,
59
- 'navigation_with_keys': True,
60
- 'announcement': 'This is the latest documentation of stouputils',
61
- 'footer_icons': [
62
- {
63
- 'name': 'GitHub',
64
- 'url': 'https://github.com/Stoupy51/stouputils',
65
- 'html': '<i class="fab fa-github-square"></i>',
66
- 'class': '',
67
- },
68
- ],
69
- }
70
-
71
- # Add any paths that contain custom static files
72
- html_static_path: list[str] = ['_static']
73
-
74
- # Autodoc settings
75
- autodoc_default_options: dict[str, bool | str] = {
76
- 'members': True,
77
- 'member-order': 'bysource',
78
- 'special-members': False,
79
- 'undoc-members': False,
80
- 'private-members': False,
81
- 'show-inheritance': True,
82
- 'ignore-module-all': True,
83
- 'exclude-members': '__weakref__'
84
- }
85
-
86
- # Tell autodoc to prefer source code over installed package
87
- autodoc_mock_imports = []
88
- always_document_param_types = True
89
- add_module_names = False
90
-
91
- # Tell Sphinx to look for source code in src directory
92
- html_context = {
93
- 'display_github': True,
94
- 'github_user': 'Stoupy51',
95
- 'github_repo': 'stouputils',
96
- 'github_version': 'main',
97
- 'conf_py_path': '/docs/source/',
98
- 'source_suffix': '.rst',
99
- 'default_mode': 'dark',
100
- }
101
-
102
- # Only document items with docstrings
103
- def skip_undocumented(app: Any, what: str, name: str, obj: Any, skip: bool, *args: Any, **kwargs: Any) -> bool:
104
- if not obj.__doc__:
105
- return True
106
- return skip
107
-
108
- def setup(app: Any) -> None:
109
- app.connect('autodoc-skip-member', skip_undocumented)
110
- """
111
-
112
- @simple_cache()
113
- def get_versions_from_github() -> list[str]:
114
- """ Get list of versions from GitHub gh-pages branch.
115
-
116
- Returns:
117
- list[str]: List of versions, with 'latest' as first element
118
- """
119
- import requests
120
- version_list: list[str] = []
121
- try:
122
- response = requests.get("https://api.github.com/repos/Stoupy51/stouputils/contents?ref=gh-pages")
123
- if response.status_code == 200:
124
- contents = response.json()
125
- version_list = ["latest"] + sorted(
126
- [d["name"].replace("v", "") for d in contents
127
- if d["type"] == "dir" and d["name"].startswith("v")],
128
- key=version_to_float,
129
- reverse=True
130
- )
131
- except Exception as e:
132
- warning(f"Failed to get versions from GitHub: {e}")
133
- version_list = ["latest"]
134
- return version_list
135
-
136
- def generate_index_rst(readme_path: str, index_path: str) -> None:
137
- """ Generate index.rst from README.md content.
138
-
139
- Args:
140
- readme_path (str): Path to the README.md file
141
- index_path (str): Path where index.rst should be created
142
- """
143
- with open(readme_path, 'r', encoding="utf-8") as f:
144
- readme_content: str = f.read()
145
-
146
- # Convert markdown badges to RST format
147
- badges_rst: str = """
148
- .. image:: https://img.shields.io/github/v/release/Stoupy51/stouputils?logo=github&label=GitHub
149
- :target: https://github.com/Stoupy51/stouputils/releases/latest
150
-
151
- .. image:: https://img.shields.io/pypi/dm/stouputils?logo=python&label=PyPI%20downloads
152
- :target: https://pypi.org/project/stouputils/
153
- """
154
-
155
- # Generate version selector
156
- version_selector: str = """
157
-
158
- **Versions**: """
159
-
160
- # Get versions from GitHub
161
- version_list: list[str] = get_versions_from_github()
162
-
163
- # Create version links
164
- version_links: list[str] = []
165
- for version in version_list:
166
- if version == 'latest':
167
- version_links.append("`latest <../latest/index.html>`_")
168
- else:
169
- version_links.append(f"`v{version} <../v{version}/index.html>`_")
170
-
171
- version_selector += ", ".join(version_links)
172
-
173
- # Extract sections while preserving emojis
174
- overview_section: str = readme_content.split('# 📚 Project Overview')[1].split('\n#')[0].strip()
175
- file_tree_section: str = readme_content.split('# 🚀 Project File Tree')[1].split('\n#')[0].strip()
176
- file_tree_section = file_tree_section.replace('```bash', '').replace('```', '').strip()
177
- file_tree_section = "\n".join([f" {line}" for line in file_tree_section.split('\n')])
178
-
179
- # Generate module documentation section
180
- module_docs: str = ".. toctree::\n :maxdepth: 10\n :caption: Contents:\n\n"
181
-
182
- # Add base module
183
- module_docs += " modules/stouputils\n\n"
184
-
185
- # Generate the RST content with emojis and proper title underlines
186
- rst_content: str = f"""
187
- 🛠️ Welcome to Stouputils Documentation
188
- =======================================
189
-
190
- {badges_rst}
191
-
192
- {version_selector}
193
-
194
- 📚 Overview
195
- -----------
196
- {overview_section.replace("<br>", " ")}
197
-
198
- 🚀 Project Structure
199
- -------------------
200
- .. code-block:: bash
201
-
202
- {file_tree_section}
203
-
204
- 📖 Module Documentation
205
- ----------------------
206
- {module_docs}
207
-
208
- ⚡ Indices and Tables
209
- ===================
210
-
211
- * :ref:`genindex`
212
- * :ref:`modindex`
213
- * :ref:`search`
214
- """
215
-
216
- # Write the RST file
217
- with open(index_path, 'w', encoding="utf-8") as f:
218
- f.write(rst_content)
219
-
220
- def generate_conf_py(conf_path: str) -> None:
221
- """ Generate conf.py file.
222
-
223
- Args:
224
- conf_path (str): Path where conf.py should be created
225
- """
226
- with open(conf_path, 'w', encoding="utf-8") as f:
227
- f.write(conf_content)
228
-
229
- @handle_error()
230
- def update_documentation(version: str | None = None) -> None:
231
- """ Update the Sphinx documentation.
232
- This script will:
233
- 1. Create necessary directories if they don't exist
234
- 2. Generate module documentation using sphinx-apidoc
235
- 3. Build HTML documentation for specific version if provided
236
-
237
- Args:
238
- version (str | None): Version to build documentation for. If None, builds for latest
239
- """
240
- # Get the project root directory (parent of scripts folder)
241
- root_dir: str = clean_path(os.path.dirname(os.path.dirname(__file__)))
242
- docs_dir: str = clean_path(os.path.join(root_dir, "docs"))
243
- source_dir: str = clean_path(os.path.join(docs_dir, "source"))
244
- modules_dir: str = clean_path(os.path.join(source_dir, "modules"))
245
-
246
- # Modify build directory if version is specified
247
- build_dir: str = "html/latest" if not version else f"html/v{version}"
248
-
249
- # Create directories if they don't exist
250
- os.makedirs(modules_dir, exist_ok=True)
251
- os.makedirs(clean_path(os.path.join(source_dir, "_static")), exist_ok=True)
252
- os.makedirs(clean_path(os.path.join(source_dir, "_templates")), exist_ok=True)
253
-
254
- # Generate index.rst from README.md
255
- readme_path: str = clean_path(os.path.join(root_dir, "README.md"))
256
- index_path: str = clean_path(os.path.join(source_dir, "index.rst"))
257
- generate_index_rst(readme_path, index_path)
258
-
259
- # Clean up old module documentation
260
- if os.path.exists(modules_dir):
261
- shutil.rmtree(modules_dir)
262
- os.makedirs(modules_dir)
263
-
264
- # Update conf.py to include version selector
265
- version_list: list[str] = get_versions_from_github()
266
-
267
- # Update html_context in conf.py
268
- global conf_content
269
- conf_content = conf_content.replace(
270
- "html_context = {",
271
- f"""html_context = {{
272
- 'versions': {version_list},
273
- 'current_version': 'latest' if not {repr(version)} else {repr(version)},"""
274
- )
275
-
276
- # Generate docs/source/conf.py
277
- conf_path: str = clean_path(os.path.join(source_dir, "conf.py"))
278
- generate_conf_py(conf_path)
279
-
280
- # Generate module documentation using python -m
281
- subprocess.run([
282
- clean_exec,
283
- "-m", "sphinx.ext.apidoc",
284
- "-o", modules_dir, # Output directory
285
- "-f", # Force overwrite
286
- "-e", # Put documentation for each module on its own page
287
- "-M", # Put module documentation before submodule documentation
288
- "--no-toc", # Don't create a table of contents file
289
- "-P", # Include private modules
290
- "--implicit-namespaces",# Handle implicit namespaces
291
- "--module-first", # Put module documentation before submodule documentation
292
- clean_path(os.path.join(root_dir, "src/stouputils")), # Source code directory
293
- ], check=True)
294
-
295
- # Build HTML documentation using python -m
296
- subprocess.run([
297
- clean_exec,
298
- "-m", "sphinx",
299
- "-b", "html", # Build HTML
300
- "-a", # Write all files
301
- source_dir, # Source directory
302
- clean_path(f"{docs_dir}/build/{build_dir}"), # Output directory
303
- ], check=True)
304
-
305
- print("Documentation updated successfully!")
306
- print(f"You can view the documentation by opening {docs_dir}/build/{build_dir}/index.html")
307
-
308
- if __name__ == "__main__":
309
- if len(sys.argv) == 2:
310
- update_documentation(sys.argv[1].replace("v", "")) # Remove "v" from version just in case
311
- elif len(sys.argv) == 1:
312
- update_documentation()
313
- else:
314
- raise ValueError("Usage: python create_docs.py [version]")
315
-
@@ -1,28 +0,0 @@
1
-
2
- # Imports
3
- import stouputils as stp
4
- from typing import Any
5
-
6
- # Constants
7
- ROOT: str = stp.get_root_path(__file__, go_up=1)
8
- CURRENT_VERSION: str = stp.get_version_from_pyproject(f"{ROOT}/pyproject.toml")
9
- CREDENTIALS_PATH: str = "~/stouputils/credentials.yml"
10
- GITHUB_CONFIG: dict[str, Any] = {
11
- "project_name": "stouputils",
12
- "version": CURRENT_VERSION,
13
- "build_folder": f"{ROOT}/dist",
14
- "endswith": [
15
- f"{CURRENT_VERSION}.tar.gz",
16
- f"{CURRENT_VERSION}-py3-none-any.whl",
17
- ],
18
- }
19
-
20
- # Main
21
- if __name__ == "__main__":
22
-
23
- # Get credentials
24
- credentials: dict[str, Any] = stp.load_credentials(CREDENTIALS_PATH)
25
-
26
- # Upload to GitHub
27
- changelog: str = stp.upload_to_github(credentials, GITHUB_CONFIG)
28
-
@@ -1,20 +0,0 @@
1
-
2
- # Imports
3
- import stouputils as stp
4
-
5
- # Constants
6
- ROOT: str = stp.get_root_path(__file__, go_up=1)
7
- REPOSITORY: str = "stouputils"
8
- DIST_DIRECTORY: str = f"{ROOT}/dist"
9
- LAST_FILES: int = 1
10
- ENDWITH: str = ".tar.gz"
11
-
12
- if __name__ == "__main__":
13
-
14
- stp.pypi_full_routine(
15
- repository=REPOSITORY,
16
- dist_directory=DIST_DIRECTORY,
17
- last_files=LAST_FILES,
18
- endswith=ENDWITH,
19
- )
20
-
@@ -1,11 +0,0 @@
1
-
2
- # Imports
3
- import stouputils as stp
4
-
5
- # Main
6
- if __name__ == "__main__":
7
-
8
- # Increment version
9
- ROOT: str = stp.get_root_path(__file__, go_up=1)
10
- stp.increment_version_from_pyproject(f"{ROOT}/pyproject.toml")
11
-
File without changes
File without changes
File without changes