python-backpack 2.0.0__py3-none-any.whl → 2.0.1__py3-none-any.whl
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.
- backpack/file_utils.py +41 -0
- backpack/json_utils.py +1 -1
- backpack/version.py +2 -2
- python_backpack-2.0.1.dist-info/METADATA +7 -0
- {python_backpack-2.0.0.dist-info → python_backpack-2.0.1.dist-info}/RECORD +7 -7
- {python_backpack-2.0.0.dist-info → python_backpack-2.0.1.dist-info}/WHEEL +1 -1
- python_backpack-2.0.0.dist-info/METADATA +0 -12
- {python_backpack-2.0.0.dist-info → python_backpack-2.0.1.dist-info}/licenses/LICENSE +0 -0
backpack/file_utils.py
CHANGED
|
@@ -84,3 +84,44 @@ def file_is_writeable(filepath: str) -> bool:
|
|
|
84
84
|
log.info(x.strerror)
|
|
85
85
|
|
|
86
86
|
return False
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def get_version_from_filename(filename: str) -> str:
|
|
90
|
+
"""Extracts version from filename.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
filename: (str) file name to extract version from
|
|
94
|
+
Returns:
|
|
95
|
+
str : version extracted from filename
|
|
96
|
+
|
|
97
|
+
Examples:
|
|
98
|
+
get_version_from_filename('myfile_23.txt') -> '23'
|
|
99
|
+
get_version_from_filename('myfile-9.txt') -> '9'
|
|
100
|
+
get_version_from_filename('myfile.130.txt') -> '130'
|
|
101
|
+
get_version_from_filename('myfile_v1002.txt') -> '1002'
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
filename_no_ext = filename.rsplit('.', 1)[0]
|
|
106
|
+
|
|
107
|
+
# guess is the separator is an underscore, dash, dot or v, and the version is the last part before the extension
|
|
108
|
+
separators = ['_', '-', '.', 'v']
|
|
109
|
+
if not any(sep in filename_no_ext for sep in separators):
|
|
110
|
+
log.info(f'No separator found in filename: {filename_no_ext}. Using fallback extraction.')
|
|
111
|
+
else:
|
|
112
|
+
for sep in separators:
|
|
113
|
+
if sep in filename_no_ext:
|
|
114
|
+
parts = filename_no_ext.split(sep)
|
|
115
|
+
version_part = parts[-1].split('.')[0] # Get the last part before the extension
|
|
116
|
+
if version_part.replace('.', '').isdigit(): # Check if it's a valid version number
|
|
117
|
+
log.info(
|
|
118
|
+
f'Extracted version: {version_part} from filename: {filename} using separator: {sep}'
|
|
119
|
+
)
|
|
120
|
+
return version_part
|
|
121
|
+
|
|
122
|
+
# Fallback: extract from the entire filename
|
|
123
|
+
version = filename_no_ext.lstrip('v')
|
|
124
|
+
version = version.replace('_', '.').replace('-', '.')
|
|
125
|
+
version = version if version.replace('.', '').isdigit() else '0'
|
|
126
|
+
log.info(f'Extracted version: {version} from filename: {filename}')
|
|
127
|
+
return version
|
backpack/json_utils.py
CHANGED
|
@@ -40,7 +40,7 @@ def json_save(data: dict, json_file: str) -> bool:
|
|
|
40
40
|
"""
|
|
41
41
|
|
|
42
42
|
if not os.path.exists(os.path.dirname(json_file)):
|
|
43
|
-
os.makedirs(os.path.dirname(json_file))
|
|
43
|
+
os.makedirs(os.path.dirname(json_file), exist_ok=True)
|
|
44
44
|
|
|
45
45
|
try:
|
|
46
46
|
with open(json_file, 'w') as f:
|
backpack/version.py
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
# 1.1.2 07/2025 - Update actions versions, remove unused badge from README
|
|
10
10
|
# 1.1.3 07/2025 - Improve test class names and docstrings for clarity, ruff formatting
|
|
11
11
|
# 1.1.4 07/2025 - Moved from pipenv to poetry for dependency management.toml
|
|
12
|
-
# 2.0.
|
|
12
|
+
# 2.0.1 05/2026 - Remove tox workflow and setup.py, standardize uv + coverage tooling
|
|
13
13
|
# ----------------------------------------------------------------------------------------
|
|
14
14
|
|
|
15
15
|
VERSION_MAJOR = 2
|
|
16
16
|
VERSION_MINOR = 0
|
|
17
|
-
VERSION_PATCH =
|
|
17
|
+
VERSION_PATCH = 1
|
|
18
18
|
|
|
19
19
|
version = f'{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}'
|
|
20
20
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-backpack
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: A collection of personal scripts for json, File/Folder Operations, String Validation, Custom Errors, Cache and stuff.
|
|
5
|
+
Author: Maximiliano Rocamora
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.11
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
backpack/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
backpack/cache.py,sha256=NlKyeGSXHaA9-RFLSN9Dblt0s7kL9fKzqQhGPHpgGbM,2508
|
|
3
3
|
backpack/custom_errors.py,sha256=tkn0AnV-Ihnge9X197nPeRpCFD6Feu9lLntejNTNpik,1358
|
|
4
|
-
backpack/file_utils.py,sha256=
|
|
4
|
+
backpack/file_utils.py,sha256=VgwVyZFGHJFpaqp0jkqUCAAFfFKFywoK9LTUngsD3bQ,4478
|
|
5
5
|
backpack/folder_utils.py,sha256=RxfVHBLDTL2EdU2w_EMOWsdtCQh-f5BHMzGIRo3UEI8,2983
|
|
6
6
|
backpack/json_metadata.py,sha256=KHsXTCDcrKa68p_HgtQfy_AjXmDCxiA99NIuZfKn2I8,4561
|
|
7
7
|
backpack/json_user_settings.py,sha256=RwdxIZYD4jkcIrWxMn7ZrlKejaGIYOt2TXTGob7nCUg,2676
|
|
8
|
-
backpack/json_utils.py,sha256=
|
|
8
|
+
backpack/json_utils.py,sha256=wQhGzZVltiob_-W4FN40mmq6sO6lw6KSiL1mOQiokH0,1339
|
|
9
9
|
backpack/logger.py,sha256=yoo4_4Ok9MAdd3GSTeeSGaIKJ4c-KwdhI6q7lg_39oo,518
|
|
10
10
|
backpack/patterns.py,sha256=qBwgbpfzMrap4KHtLLsg1CJmsmstGGXfzYLpkuUdbMI,889
|
|
11
11
|
backpack/strings.py,sha256=boYfBi1wPtfkngpb2uIAxiJC2yo32EaL5wUD_3JjWGo,3811
|
|
12
12
|
backpack/test_utils.py,sha256=0VqVZB6snc_XM6MsmIanlFGWo5T2zswFq9Cn-HpZntE,1165
|
|
13
|
-
backpack/version.py,sha256=
|
|
14
|
-
python_backpack-2.0.
|
|
15
|
-
python_backpack-2.0.
|
|
16
|
-
python_backpack-2.0.
|
|
17
|
-
python_backpack-2.0.
|
|
13
|
+
backpack/version.py,sha256=j2Y8h2i35wUoVt32rMwO7c-j3ze1g7ywITv5xLPxFXk,1069
|
|
14
|
+
python_backpack-2.0.1.dist-info/METADATA,sha256=df5vihdX3xWJ5kG0eGtf8_ivrBmqVXc3tVGDpu_gx0I,261
|
|
15
|
+
python_backpack-2.0.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
16
|
+
python_backpack-2.0.1.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
|
17
|
+
python_backpack-2.0.1.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: python-backpack
|
|
3
|
-
Version: 2.0.0
|
|
4
|
-
Summary: A collection of personal scripts for json, File/Folder Operations, String Validation, Custom Errors, Cache and stuff.
|
|
5
|
-
License-File: LICENSE
|
|
6
|
-
Author: Maximiliano Rocamora
|
|
7
|
-
Requires-Python: >=3.11,<4.0
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
File without changes
|