stouputils 1.0.22__tar.gz → 1.0.24__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.22 → stouputils-1.0.24}/PKG-INFO +3 -2
- stouputils-1.0.24/assets/continuous_delivery/github_module.gif +0 -0
- stouputils-1.0.24/build_all_in_one.py +20 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/all_doctests.py +1 -5
- {stouputils-1.0.22 → stouputils-1.0.24}/pyproject.toml +7 -17
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/archive.py +2 -2
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/continuous_delivery/__init__.py +2 -0
- stouputils-1.0.24/src/stouputils/continuous_delivery/pypi.py +85 -0
- stouputils-1.0.24/src/stouputils/continuous_delivery/pyproject.py +69 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/io.py +26 -1
- stouputils-1.0.24/upgrade.py +16 -0
- stouputils-1.0.22/1_upgrades.py +0 -4
- stouputils-1.0.22/2_build.py +0 -4
- stouputils-1.0.22/3_upload.py +0 -10
- stouputils-1.0.22/build_all_in_one.py +0 -14
- stouputils-1.0.22/upgrade.py +0 -58
- {stouputils-1.0.22 → stouputils-1.0.24}/.github/workflows/documentation.yml +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/.gitignore +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/.python-version +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/LICENSE +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/README.md +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/all_in_one.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/all_doctests_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/archive_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/backup_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/collections_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/ctx_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/decorators_module_1.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/decorators_module_2.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/io_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/parallel_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/assets/print_module.gif +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/copy_in_local.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/archive/corrupted.zip +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/archive.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/collections.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/ctx.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/decorators_1.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/decorators_2.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/delta_backup.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/io.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/parallel.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/examples/print.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/github_release.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/scripts/create_docs.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/__init__.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/all_doctests.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/backup.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/collections.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/continuous_delivery/cd_utils.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/continuous_delivery/github.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/ctx.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/decorators.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/dont_look/zip_file_override.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/parallel.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/print.py +0 -0
- {stouputils-1.0.22 → stouputils-1.0.24}/src/stouputils/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.24
|
|
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,8 +10,9 @@ 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
|
|
13
|
+
Requires-Dist: pyyaml
|
|
14
14
|
Requires-Dist: requests>=2.31.0
|
|
15
|
+
Requires-Dist: toml
|
|
15
16
|
Requires-Dist: tqdm>=4.66.4
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
17
18
|
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
# Imports
|
|
3
|
+
import stouputils as stp
|
|
4
|
+
|
|
5
|
+
# Constants
|
|
6
|
+
ROOT: str = stp.get_root_path(__file__)
|
|
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,15 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
# Imports
|
|
3
|
-
import os
|
|
4
3
|
import stouputils as stp
|
|
5
4
|
|
|
6
|
-
# Constants
|
|
7
|
-
ROOT: str = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
-
FOLDER_TO_TEST: str = f"{ROOT}/../src"
|
|
9
|
-
|
|
10
5
|
# Main
|
|
11
6
|
@stp.measure_time(stp.info, message="All doctests finished")
|
|
12
7
|
def main() -> None:
|
|
8
|
+
FOLDER_TO_TEST: str = stp.get_root_path(__file__, 1) + "/src"
|
|
13
9
|
stp.launch_tests(FOLDER_TO_TEST)
|
|
14
10
|
|
|
15
11
|
if __name__ == "__main__":
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
|
|
2
1
|
[build-system]
|
|
3
|
-
requires = ["hatchling"]
|
|
2
|
+
requires = [ "hatchling",]
|
|
4
3
|
build-backend = "hatchling.build"
|
|
5
4
|
|
|
6
5
|
[project]
|
|
7
6
|
name = "stouputils"
|
|
8
|
-
version = "1.0.
|
|
9
|
-
authors = [
|
|
10
|
-
{ name="Stoupy51", email="stoupy51@gmail.com" },
|
|
11
|
-
]
|
|
7
|
+
version = "1.0.24"
|
|
12
8
|
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."
|
|
13
9
|
readme = "README.md"
|
|
14
10
|
requires-python = ">=3.10"
|
|
15
|
-
classifiers = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dependencies = [
|
|
21
|
-
"tqdm>=4.66.4",
|
|
22
|
-
"requests>=2.31.0",
|
|
23
|
-
"pyyaml>=6.0.2",
|
|
24
|
-
]
|
|
11
|
+
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
|
|
12
|
+
dependencies = [ "tqdm>=4.66.4", "requests>=2.31.0", "pyyaml", "toml",]
|
|
13
|
+
[[project.authors]]
|
|
14
|
+
name = "Stoupy51"
|
|
15
|
+
email = "stoupy51@gmail.com"
|
|
25
16
|
|
|
26
17
|
[project.urls]
|
|
27
18
|
Homepage = "https://github.com/Stoupy51/stouputils"
|
|
@@ -29,4 +20,3 @@ Issues = "https://github.com/Stoupy51/stouputils/issues"
|
|
|
29
20
|
|
|
30
21
|
[tool.pyright]
|
|
31
22
|
typeCheckingMode = "strict"
|
|
32
|
-
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
2
|
This module provides functions for creating and managing archives.
|
|
3
3
|
|
|
4
|
-
- make_archive:
|
|
5
|
-
- repair_zip_file: Try to repair a corrupted zip file
|
|
4
|
+
- make_archive: Create a zip archive from a source directory with consistent file timestamps.
|
|
5
|
+
- repair_zip_file: Try to repair a corrupted zip file by ignoring some of the errors
|
|
6
6
|
|
|
7
7
|
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/archive_module.gif
|
|
8
8
|
:alt: stouputils archive examples
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
""" This module contains utilities for PyPI.
|
|
2
|
+
|
|
3
|
+
- pypi_full_routine: Upload the most recent file(s) to PyPI after updating pip and required packages and building the package.
|
|
4
|
+
|
|
5
|
+
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/continuous_delivery/pypi_module.gif
|
|
6
|
+
:alt: stouputils pypi examples
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Imports
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
from ..decorators import handle_error, LogLevels
|
|
13
|
+
from typing import Callable
|
|
14
|
+
|
|
15
|
+
def update_pip_and_required_packages() -> int:
|
|
16
|
+
""" Update pip and required packages.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
int: Return code of the os.system call.
|
|
20
|
+
"""
|
|
21
|
+
return os.system(f"{sys.executable} -m pip install --upgrade pip setuptools build twine pkginfo")
|
|
22
|
+
|
|
23
|
+
def build_package() -> int:
|
|
24
|
+
""" Build the package.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
int: Return code of the os.system call.
|
|
28
|
+
"""
|
|
29
|
+
return os.system(f"{sys.executable} -m build")
|
|
30
|
+
|
|
31
|
+
def upload_package(repository: str, filepath: str) -> int:
|
|
32
|
+
""" Upload the package to PyPI.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
repository (str): Repository to upload to.
|
|
36
|
+
filepath (str): Path to the file to upload.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
int: Return code of the os.system call.
|
|
40
|
+
"""
|
|
41
|
+
return os.system(f"{sys.executable} -m twine upload --verbose -r {repository} {filepath}")
|
|
42
|
+
|
|
43
|
+
@handle_error(message="Error while doing the pypi full routine", error_log=LogLevels.ERROR_TRACEBACK)
|
|
44
|
+
def pypi_full_routine(
|
|
45
|
+
repository: str,
|
|
46
|
+
dist_directory: str,
|
|
47
|
+
last_files: int = 1,
|
|
48
|
+
endswith: str = ".tar.gz",
|
|
49
|
+
|
|
50
|
+
update_all_function: Callable[[], int] = update_pip_and_required_packages,
|
|
51
|
+
build_package_function: Callable[[], int] = build_package,
|
|
52
|
+
upload_package_function: Callable[[str, str], int] = upload_package,
|
|
53
|
+
) -> None:
|
|
54
|
+
""" Upload the most recent file(s) to PyPI after updating pip and required packages and building the package.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
repository (str): Repository to upload to.
|
|
58
|
+
dist_directory (str): Directory to upload from.
|
|
59
|
+
last_files (int): Number of most recent files to upload. Defaults to 1.
|
|
60
|
+
endswith (str): End of the file name to upload. Defaults to ".tar.gz".
|
|
61
|
+
update_all_function (Callable[[], int]): Function to update pip and required packages. Defaults to update_pip_and_required_packages.
|
|
62
|
+
build_package_function (Callable[[], int]): Function to build the package. Defaults to build_package.
|
|
63
|
+
upload_package_function (Callable[[str, str], int]): Function to upload the package. Defaults to upload_package.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
int: Return code of the command.
|
|
67
|
+
"""
|
|
68
|
+
if update_all_function() != 0:
|
|
69
|
+
raise Exception("Error while updating pip and required packages")
|
|
70
|
+
|
|
71
|
+
if build_package_function() != 0:
|
|
72
|
+
raise Exception("Error while building the package")
|
|
73
|
+
|
|
74
|
+
# Get list of tar.gz files in dist directory sorted by modification time
|
|
75
|
+
files: list[str] = sorted(
|
|
76
|
+
[x for x in os.listdir(dist_directory) if x.endswith(endswith)], # Get list of tar.gz files in dist directory
|
|
77
|
+
key=lambda x: os.path.getmtime(f"{dist_directory}/{x}"), # Sort by modification time
|
|
78
|
+
reverse=True # Sort in reverse order
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Upload the most recent file(s)
|
|
82
|
+
for file in files[:last_files]:
|
|
83
|
+
upload_package_function(repository, f"{dist_directory}/{file}")
|
|
84
|
+
|
|
85
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
""" This module contains utilities for reading and writing pyproject.toml files.
|
|
2
|
+
|
|
3
|
+
- read_pyproject: Read the pyproject.toml file.
|
|
4
|
+
- write_pyproject: Write to the pyproject.toml file.
|
|
5
|
+
|
|
6
|
+
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/continuous_delivery/pyproject_module.gif
|
|
7
|
+
:alt: stouputils pyproject examples
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Imports
|
|
11
|
+
from ..io import super_open
|
|
12
|
+
from typing import Any
|
|
13
|
+
import toml
|
|
14
|
+
|
|
15
|
+
def read_pyproject(pyproject_path: str) -> dict[str, Any]:
|
|
16
|
+
""" Read the pyproject.toml file.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
pyproject_path: Path to the pyproject.toml file.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
dict[str, Any]: The content of the pyproject.toml file.
|
|
23
|
+
"""
|
|
24
|
+
return toml.load(pyproject_path)
|
|
25
|
+
|
|
26
|
+
def write_pyproject(pyproject_path: str, pyproject_content: dict[str, Any]) -> None:
|
|
27
|
+
""" Write to the pyproject.toml file.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
pyproject_path: Path to the pyproject.toml file.
|
|
31
|
+
pyproject_content: The content to write to the pyproject.toml file.
|
|
32
|
+
"""
|
|
33
|
+
with super_open(pyproject_path, "w") as file:
|
|
34
|
+
toml.dump(pyproject_content, file)
|
|
35
|
+
|
|
36
|
+
def increment_version(version: str) -> str:
|
|
37
|
+
""" Increment the version.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
version: The version to increment. (ex: "0.1.0")
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
str: The incremented version. (ex: "0.1.1")
|
|
44
|
+
"""
|
|
45
|
+
version_parts: list[str] = version.split(".")
|
|
46
|
+
version_parts[-1] = str(int(version_parts[-1]) + 1)
|
|
47
|
+
return ".".join(version_parts)
|
|
48
|
+
|
|
49
|
+
def increment_version_from_pyproject(pyproject_path: str) -> None:
|
|
50
|
+
""" Increment the version in the pyproject.toml file.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
pyproject_path: Path to the pyproject.toml file.
|
|
54
|
+
"""
|
|
55
|
+
pyproject_content = read_pyproject(pyproject_path)
|
|
56
|
+
pyproject_content["project"]["version"] = increment_version(pyproject_content["project"]["version"])
|
|
57
|
+
write_pyproject(pyproject_path, pyproject_content)
|
|
58
|
+
|
|
59
|
+
def get_version_from_pyproject(pyproject_path: str) -> str:
|
|
60
|
+
""" Get the version from the pyproject.toml file.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
pyproject_path: Path to the pyproject.toml file.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
str: The version. (ex: "0.1.0")
|
|
67
|
+
"""
|
|
68
|
+
return read_pyproject(pyproject_path)["project"]["version"]
|
|
69
|
+
|
|
@@ -67,7 +67,7 @@ def clean_path(file_path: str) -> str:
|
|
|
67
67
|
'C:/folder1/folder2'
|
|
68
68
|
"""
|
|
69
69
|
# Replace tilde
|
|
70
|
-
file_path = replace_tilde(file_path)
|
|
70
|
+
file_path = replace_tilde(str(file_path))
|
|
71
71
|
|
|
72
72
|
# Check if original path ends with slash
|
|
73
73
|
ends_with_slash: bool = file_path.endswith('/') or file_path.endswith('\\')
|
|
@@ -85,6 +85,31 @@ def clean_path(file_path: str) -> str:
|
|
|
85
85
|
return file_path
|
|
86
86
|
|
|
87
87
|
|
|
88
|
+
# Function that takes a relative path and returns the absolute path of the directory
|
|
89
|
+
def get_root_path(relative_path: str, go_up: int = 0) -> str:
|
|
90
|
+
""" Get the absolute path of the directory. Usually used to get the root path of the project using the __file__ variable.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
relative_path (str): The path to get the absolute directory path from
|
|
94
|
+
go_up (int): Number of parent directories to go up (default: 0)
|
|
95
|
+
Returns:
|
|
96
|
+
str: The absolute path of the directory
|
|
97
|
+
|
|
98
|
+
Examples:
|
|
99
|
+
|
|
100
|
+
.. code-block:: python
|
|
101
|
+
|
|
102
|
+
> get_root_path(__file__)
|
|
103
|
+
'C:/Users/Alexandre-PC/AppData/Local/Programs/Python/Python310/lib/site-packages/stouputils'
|
|
104
|
+
|
|
105
|
+
> get_root_path(__file__, 3)
|
|
106
|
+
'C:/Users/Alexandre-PC/AppData/Local/Programs/Python/Python310'
|
|
107
|
+
"""
|
|
108
|
+
return clean_path(
|
|
109
|
+
os.path.dirname(os.path.abspath(relative_path))
|
|
110
|
+
+ "/.." * go_up
|
|
111
|
+
)
|
|
112
|
+
|
|
88
113
|
|
|
89
114
|
# For easy file management
|
|
90
115
|
def super_open(file_path: str, mode: str, encoding: str = "utf-8") -> IO[Any]:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
## Python script that modifies the pyproject.toml to go to the next version
|
|
3
|
+
# Imports
|
|
4
|
+
import stouputils as stp
|
|
5
|
+
|
|
6
|
+
# Constants
|
|
7
|
+
ROOT: str = stp.get_root_path(__file__)
|
|
8
|
+
PYPROJECT_PATH = f"{ROOT}/pyproject.toml"
|
|
9
|
+
CURRENT_VERSION: str = stp.get_version_from_pyproject(PYPROJECT_PATH)
|
|
10
|
+
|
|
11
|
+
# Main
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
|
|
14
|
+
# Increment version
|
|
15
|
+
stp.increment_version_from_pyproject(PYPROJECT_PATH)
|
|
16
|
+
|
stouputils-1.0.22/1_upgrades.py
DELETED
stouputils-1.0.22/2_build.py
DELETED
stouputils-1.0.22/3_upload.py
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import os
|
|
3
|
-
LAST_FILES: int = 1
|
|
4
|
-
for root, _, files in os.walk("dist"):
|
|
5
|
-
files = sorted(files, key=lambda x: os.path.getmtime(f"dist/{x}"), reverse=True)
|
|
6
|
-
lasts = files[:LAST_FILES * 2] # x2 because we have the .tar.gz and the .whl
|
|
7
|
-
for file in lasts:
|
|
8
|
-
if file.endswith(".tar.gz"):
|
|
9
|
-
os.system(f"py -m twine upload --verbose -r stouputils dist/{file}")
|
|
10
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import os
|
|
3
|
-
import sys
|
|
4
|
-
commands = [
|
|
5
|
-
f"{sys.executable} 1_upgrades.py",
|
|
6
|
-
f"{sys.executable} 2_build.py",
|
|
7
|
-
f"{sys.executable} 3_upload.py",
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
for command in commands:
|
|
11
|
-
if os.system(command) != 0:
|
|
12
|
-
print(f"Error while executing '{command}'")
|
|
13
|
-
exit(1)
|
|
14
|
-
|
stouputils-1.0.22/upgrade.py
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
## Python script that modifies the pyproject.toml to go to the next version
|
|
3
|
-
# Imports
|
|
4
|
-
import os
|
|
5
|
-
|
|
6
|
-
# Constants
|
|
7
|
-
ROOT: str = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
8
|
-
PYPROJECT_PATH = f"{ROOT}/pyproject.toml"
|
|
9
|
-
VERSION_KEY = "version = "
|
|
10
|
-
|
|
11
|
-
def read_file(path: str) -> list[str]:
|
|
12
|
-
"""Read file and return lines"""
|
|
13
|
-
with open(path, "r", encoding="utf-8") as file:
|
|
14
|
-
return file.readlines()
|
|
15
|
-
|
|
16
|
-
def find_version_line(lines: list[str]) -> int | None:
|
|
17
|
-
"""Find line containing version and return index"""
|
|
18
|
-
for i, line in enumerate(lines):
|
|
19
|
-
if line.startswith(VERSION_KEY):
|
|
20
|
-
return i
|
|
21
|
-
return None
|
|
22
|
-
|
|
23
|
-
def increment_version(version: str) -> str:
|
|
24
|
-
"""Increment the last number in version string"""
|
|
25
|
-
parts = version.split(".")
|
|
26
|
-
parts[-1] = str(int(parts[-1]) + 1)
|
|
27
|
-
return ".".join(parts)
|
|
28
|
-
|
|
29
|
-
def extract_version(line: str) -> str:
|
|
30
|
-
"""Extract version number from line"""
|
|
31
|
-
return line.replace(VERSION_KEY, "").strip().replace('"', "")
|
|
32
|
-
|
|
33
|
-
def write_file(path: str, lines: list[str]) -> None:
|
|
34
|
-
"""Write lines to file"""
|
|
35
|
-
with open(path, "w", encoding="utf-8") as file:
|
|
36
|
-
file.writelines(lines)
|
|
37
|
-
|
|
38
|
-
# Read the file
|
|
39
|
-
lines = read_file(PYPROJECT_PATH)
|
|
40
|
-
|
|
41
|
-
# Find and update version
|
|
42
|
-
version_line = find_version_line(lines)
|
|
43
|
-
current_version = None
|
|
44
|
-
|
|
45
|
-
if version_line is not None:
|
|
46
|
-
# Get and increment version
|
|
47
|
-
current_version = extract_version(lines[version_line])
|
|
48
|
-
new_version = increment_version(current_version)
|
|
49
|
-
|
|
50
|
-
# Main
|
|
51
|
-
if __name__ == "__main__":
|
|
52
|
-
|
|
53
|
-
# Update version line
|
|
54
|
-
lines[version_line] = f'{VERSION_KEY}"{new_version}"\n'
|
|
55
|
-
|
|
56
|
-
# Write updated file
|
|
57
|
-
write_file(PYPROJECT_PATH, lines)
|
|
58
|
-
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|