python-backpack 2.0.3__py3-none-any.whl → 2.0.4__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 +27 -22
- backpack/version.py +3 -2
- {python_backpack-2.0.3.dist-info → python_backpack-2.0.4.dist-info}/METADATA +2 -2
- {python_backpack-2.0.3.dist-info → python_backpack-2.0.4.dist-info}/RECORD +6 -6
- {python_backpack-2.0.3.dist-info → python_backpack-2.0.4.dist-info}/WHEEL +1 -1
- {python_backpack-2.0.3.dist-info → python_backpack-2.0.4.dist-info}/licenses/LICENSE +0 -0
backpack/file_utils.py
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# https://github.com/MaxRocamora/python-backpack
|
|
5
5
|
# ----------------------------------------------------------------------------------------
|
|
6
6
|
|
|
7
|
+
import re
|
|
7
8
|
from collections.abc import Sequence
|
|
8
9
|
|
|
9
10
|
from backpack.logger import get_logger
|
|
@@ -94,11 +95,12 @@ def file_is_writeable(filepath: str) -> bool:
|
|
|
94
95
|
return False
|
|
95
96
|
|
|
96
97
|
|
|
97
|
-
def get_version_from_filename(filename: str) -> str:
|
|
98
|
+
def get_version_from_filename(filename: str, separator: str | None = None) -> str:
|
|
98
99
|
"""Extracts version from filename.
|
|
99
100
|
|
|
100
101
|
Args:
|
|
101
102
|
filename: (str) file name to extract version from
|
|
103
|
+
separator: delimiter that must precede the version; when omitted, use supported delimiters
|
|
102
104
|
Returns:
|
|
103
105
|
str : version extracted from filename
|
|
104
106
|
|
|
@@ -107,29 +109,32 @@ def get_version_from_filename(filename: str) -> str:
|
|
|
107
109
|
get_version_from_filename('myfile-9.txt') -> '9'
|
|
108
110
|
get_version_from_filename('myfile.130.txt') -> '130'
|
|
109
111
|
get_version_from_filename('myfile_v1002.txt') -> '1002'
|
|
112
|
+
get_version_from_filename('XD_shot_0000.0003.ma') -> '0003'
|
|
113
|
+
get_version_from_filename('ANM_shot_0010.0003.ma') -> '0003'
|
|
110
114
|
|
|
111
115
|
"""
|
|
112
116
|
|
|
113
117
|
filename_no_ext = filename.rsplit('.', 1)[0]
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
if separator is not None:
|
|
120
|
+
if not separator:
|
|
121
|
+
raise ValueError('separator must not be empty')
|
|
122
|
+
|
|
123
|
+
version = filename_no_ext.rsplit(separator, 1)[-1]
|
|
124
|
+
if version.isdigit():
|
|
125
|
+
log.info(
|
|
126
|
+
f'Extracted version: {version} from filename: {filename} using separator: {separator}'
|
|
127
|
+
)
|
|
128
|
+
return version
|
|
129
|
+
|
|
130
|
+
log.info(f'No numeric version found in filename: {filename} using separator: {separator}')
|
|
131
|
+
return '0'
|
|
132
|
+
|
|
133
|
+
match = re.search(r'(?:^|[_.-])v?(\d+)$', filename_no_ext)
|
|
134
|
+
if match:
|
|
135
|
+
version = match.group(1)
|
|
136
|
+
log.info(f'Extracted version: {version} from filename: {filename}')
|
|
137
|
+
return version
|
|
138
|
+
|
|
139
|
+
log.info(f'No numeric version found in filename: {filename}')
|
|
140
|
+
return '0'
|
backpack/version.py
CHANGED
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
# 1.1.4 07/2025 - Moved from pipenv to poetry for dependency management.toml
|
|
12
12
|
# 2.0.1 05/2026 - Remove tox workflow and setup.py, standardize uv + coverage tooling
|
|
13
13
|
# 2.0.2 05/2026 - Add PyPI long description metadata and release polish
|
|
14
|
-
# 2.0.3 06/2026 - Add type hints
|
|
14
|
+
# 2.0.3 06/2026 - Add type hints, refactor backpack.cache to use functools.lru_cache, added tests.
|
|
15
|
+
# 2.0.4 08/2026 - Fixed get_version_from_filename().
|
|
15
16
|
# ----------------------------------------------------------------------------------------
|
|
16
17
|
|
|
17
|
-
__version__ = '2.0.
|
|
18
|
+
__version__ = '2.0.4'
|
|
18
19
|
|
|
19
20
|
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH = map(int, __version__.split('.'))
|
|
20
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: python-backpack
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Lightweight utilities for JSON, filesystem operations, strings, caching, and scripting.
|
|
5
5
|
Project-URL: Homepage, https://github.com/MaxRocamora/python-backpack
|
|
6
6
|
Project-URL: Repository, https://github.com/MaxRocamora/python-backpack.git
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
backpack/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
backpack/cache.py,sha256=pAQGxIyQOMZ60Np7aOkS7QebWcJf8f4vyKts7GY5q20,3071
|
|
3
3
|
backpack/custom_errors.py,sha256=tkn0AnV-Ihnge9X197nPeRpCFD6Feu9lLntejNTNpik,1358
|
|
4
|
-
backpack/file_utils.py,sha256=
|
|
4
|
+
backpack/file_utils.py,sha256=S_4EhipFHRuq_D5KH9GMFonQpHYltSR6Zm4a4jnx1GA,4451
|
|
5
5
|
backpack/folder_utils.py,sha256=F6kaaH5K-OSRZZSNdRQjzIaxVokirm2GsGVM48_C7no,3265
|
|
6
6
|
backpack/json_metadata.py,sha256=ekhzxe8u0D7xz4tcKHCzgKNc14LtF0wo2FRTJp4eoCc,4638
|
|
7
7
|
backpack/json_user_settings.py,sha256=bC9BNbFroIwBlV2sPcibaFcPvUzkGRxvGxG3i1OR78o,2644
|
|
@@ -10,8 +10,8 @@ backpack/logger.py,sha256=yoo4_4Ok9MAdd3GSTeeSGaIKJ4c-KwdhI6q7lg_39oo,518
|
|
|
10
10
|
backpack/patterns.py,sha256=qBwgbpfzMrap4KHtLLsg1CJmsmstGGXfzYLpkuUdbMI,889
|
|
11
11
|
backpack/strings.py,sha256=J6GAXRXeNgdA7gvNO5hYOYpIs2jHmYoG99z9O6Sczbo,3611
|
|
12
12
|
backpack/test_utils.py,sha256=am9XWt8NTDQx5gl5tFq47tTDZ7cJjSnpB7f2s603X4s,1370
|
|
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=5W8rugrg7yvzss1RdSpTh7EZ6kuqwBn7dBHUYktOpMw,1305
|
|
14
|
+
python_backpack-2.0.4.dist-info/METADATA,sha256=koB5TMh4ISFQxJ0lvRIMXEZrl6qMxMq04Zy9oBfs4PA,6665
|
|
15
|
+
python_backpack-2.0.4.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
16
|
+
python_backpack-2.0.4.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
|
17
|
+
python_backpack-2.0.4.dist-info/RECORD,,
|
|
File without changes
|