python-backpack 2.0.1__tar.gz → 2.0.2__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.
- python_backpack-2.0.2/.vscode/settings.json +9 -0
- python_backpack-2.0.2/PKG-INFO +155 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/README.md +2 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/version.py +2 -1
- {python_backpack-2.0.1 → python_backpack-2.0.2}/pyproject.toml +2 -1
- python_backpack-2.0.1/PKG-INFO +0 -7
- {python_backpack-2.0.1 → python_backpack-2.0.2}/.github/workflows/codecov_tests.yml +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/.gitignore +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/LICENSE +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/__init__.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/__init__.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/cache.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/custom_errors.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/file_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/folder_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/json_metadata.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/json_user_settings.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/json_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/logger.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/patterns.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/strings.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack/test_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/backpack.code-workspace +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/codecov.yml +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/coverage.bat +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/ruff.toml +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/__init__.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_cache.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_errors.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_file_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_files/edited.txt +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_files/edited_remove.txt +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_files/locked_file.txt +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_files/origin.txt +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_files/origin_remove.txt +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_files/unlocked_file.txt +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_folder_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_json/data.json +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_json/data_broken.json +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_json/save/data_saved.json +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_json_user_settings.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_json_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_jsonmd.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_misc.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_strings.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/tests/test_test_utils.py +0 -0
- {python_backpack-2.0.1 → python_backpack-2.0.2}/uv.lock +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-backpack
|
|
3
|
+
Version: 2.0.2
|
|
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
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
[](https://pypi.python.org/pypi/python-backpack/)
|
|
11
|
+
[](https://badge.fury.io/py/python-backpack)
|
|
12
|
+
[](https://badge.fury.io/gh/MaxRocamora%2Fpython-backpack)
|
|
13
|
+
[](https://codecov.io/gh/MaxRocamora/python-backpack)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Python-Backpack
|
|
17
|
+
|
|
18
|
+
Python-Backpack is a lightweight utility collection for common scripting tasks:
|
|
19
|
+
|
|
20
|
+
- JSON load/save helpers with validation
|
|
21
|
+
- user settings persistence under the OS user directory
|
|
22
|
+
- metadata export/import to JSON files
|
|
23
|
+
- file and folder operations
|
|
24
|
+
- string normalization and case conversion
|
|
25
|
+
- cache decorator with expiration support
|
|
26
|
+
- custom exceptions, logging helper, singleton pattern, and testing helpers
|
|
27
|
+
|
|
28
|
+
## Compatibility
|
|
29
|
+
|
|
30
|
+
- Python 3.11+
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install python-backpack
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Package API Reference
|
|
39
|
+
|
|
40
|
+
### Cache (`backpack.cache`)
|
|
41
|
+
|
|
42
|
+
- `timed_lru_cache(seconds: int, maxsize: int = 128)`
|
|
43
|
+
- `functools.lru_cache` decorator with expiration time.
|
|
44
|
+
- Wrapped calls support `force_clear=True` and `show_log=True`.
|
|
45
|
+
|
|
46
|
+
### Custom Errors (`backpack.custom_errors`)
|
|
47
|
+
|
|
48
|
+
- `EnvironmentVariableNotFoundError(var_name: str)`
|
|
49
|
+
- Raised when a required environment variable is missing.
|
|
50
|
+
- `ApplicationNotFoundError(app_name: str)`
|
|
51
|
+
- Raised when a required application is not found.
|
|
52
|
+
|
|
53
|
+
### File Utils (`backpack.file_utils`)
|
|
54
|
+
|
|
55
|
+
- `replace_strings_in_file(ascii_file: str, strings: list, new_string: str) -> None`
|
|
56
|
+
- Replaces multiple string occurrences in a text file.
|
|
57
|
+
- `remove_line_from_file(ascii_file: str, strings: list, verbose: bool = False) -> None`
|
|
58
|
+
- Removes exact matching lines from a text file.
|
|
59
|
+
- `file_is_writeable(filepath: str) -> bool`
|
|
60
|
+
- Checks whether a file can be opened for read/write.
|
|
61
|
+
- `get_version_from_filename(filename: str) -> str`
|
|
62
|
+
- Extracts a numeric version token from a filename.
|
|
63
|
+
|
|
64
|
+
### Folder Utils (`backpack.folder_utils`)
|
|
65
|
+
|
|
66
|
+
- `browse_folder(folder: str) -> bool`
|
|
67
|
+
- Opens a folder in Windows Explorer.
|
|
68
|
+
- `create_folders(folders: list, force_empty: bool = False, verbose: bool = False)`
|
|
69
|
+
- Creates multiple folders.
|
|
70
|
+
- `create_folder(path: str, force_empty: bool = False, verbose: bool = True)`
|
|
71
|
+
- Creates a folder and optionally clears it if it already exists.
|
|
72
|
+
- `remove_files_in_dir(path: str)`
|
|
73
|
+
- Removes all files and subdirectories inside a directory.
|
|
74
|
+
- `recursive_dir_copy(source_path: str, target_path: str)`
|
|
75
|
+
- Recursively copies files and subfolders from source to target.
|
|
76
|
+
|
|
77
|
+
### JSON Utils (`backpack.json_utils`)
|
|
78
|
+
|
|
79
|
+
- `json_load(json_file: str) -> dict`
|
|
80
|
+
- Loads JSON data from file with validation and error handling.
|
|
81
|
+
- `json_save(data: dict, json_file: str) -> bool`
|
|
82
|
+
- Saves a dictionary to JSON file.
|
|
83
|
+
|
|
84
|
+
### JSON Metadata (`backpack.json_metadata`)
|
|
85
|
+
|
|
86
|
+
- `JsonMetaFile(name: str, path: str)`
|
|
87
|
+
- Manages a metadata JSON file with package/system/time information.
|
|
88
|
+
- Main public methods:
|
|
89
|
+
- `has_file() -> bool`
|
|
90
|
+
- `load() -> None`
|
|
91
|
+
- `insert(key: str, value: Any) -> None`
|
|
92
|
+
- `remove(key: str) -> None`
|
|
93
|
+
- `save() -> None`
|
|
94
|
+
- `load_as_class() -> type`
|
|
95
|
+
- `insert_class(_class: type) -> None`
|
|
96
|
+
|
|
97
|
+
### JSON User Settings (`backpack.json_user_settings`)
|
|
98
|
+
|
|
99
|
+
- `JsonUserSettings(folder: str, name: str)`
|
|
100
|
+
- Saves and loads JSON settings in the current user's home directory.
|
|
101
|
+
- Main public methods:
|
|
102
|
+
- `save_settings(data: dict | None = None) -> bool | None`
|
|
103
|
+
- `load_settings() -> dict | bool`
|
|
104
|
+
|
|
105
|
+
### Logger (`backpack.logger`)
|
|
106
|
+
|
|
107
|
+
- `get_logger(name: str) -> logging.Logger`
|
|
108
|
+
- Returns a configured logger with stream handler.
|
|
109
|
+
|
|
110
|
+
### Patterns (`backpack.patterns`)
|
|
111
|
+
|
|
112
|
+
- `Singleton`
|
|
113
|
+
- Base class implementing singleton behavior via `__new__`.
|
|
114
|
+
|
|
115
|
+
### Strings (`backpack.strings`)
|
|
116
|
+
|
|
117
|
+
- `normalize_input_string(input_string: str, under_spaces: bool = True, under_hyphen: bool = True, replacer: str = '_') -> str`
|
|
118
|
+
- Keeps alphanumeric/space/hyphen characters and normalizes separators.
|
|
119
|
+
- `begin_or_end_with_numbers(input_string: str) -> bool`
|
|
120
|
+
- Checks whether first or last character is numeric.
|
|
121
|
+
- `begin_with_number(input_string: str) -> bool`
|
|
122
|
+
- Checks whether the first character is numeric.
|
|
123
|
+
- `has_numbers(input_string: str) -> bool`
|
|
124
|
+
- Checks whether any character is numeric.
|
|
125
|
+
- `camelcase_to_snakecase(input_string: str) -> str`
|
|
126
|
+
- Converts CamelCase to snake_case.
|
|
127
|
+
- Handles acronym prefixes, for example `HTTPServer -> http_server`.
|
|
128
|
+
|
|
129
|
+
### Test Utils (`backpack.test_utils`)
|
|
130
|
+
|
|
131
|
+
- `random_string(length: int = 10) -> str`
|
|
132
|
+
- Generates a random lowercase string.
|
|
133
|
+
- `time_function_decorator(method: type)`
|
|
134
|
+
- Decorator that logs execution time.
|
|
135
|
+
|
|
136
|
+
## Quick Example
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from backpack.cache import timed_lru_cache
|
|
140
|
+
from backpack.strings import camelcase_to_snakecase, normalize_input_string
|
|
141
|
+
from backpack.json_utils import json_save, json_load
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@timed_lru_cache(seconds=60)
|
|
145
|
+
def expensive_call():
|
|
146
|
+
return {'ok': True}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
value = camelcase_to_snakecase('HTTPServer')
|
|
150
|
+
clean = normalize_input_string('Blade Runner-2049')
|
|
151
|
+
|
|
152
|
+
json_save({'value': value, 'clean': clean}, 'data.json')
|
|
153
|
+
data = json_load('data.json')
|
|
154
|
+
```
|
|
155
|
+
|
|
@@ -49,6 +49,8 @@ pip install python-backpack
|
|
|
49
49
|
- Removes exact matching lines from a text file.
|
|
50
50
|
- `file_is_writeable(filepath: str) -> bool`
|
|
51
51
|
- Checks whether a file can be opened for read/write.
|
|
52
|
+
- `get_version_from_filename(filename: str) -> str`
|
|
53
|
+
- Extracts a numeric version token from a filename.
|
|
52
54
|
|
|
53
55
|
### Folder Utils (`backpack.folder_utils`)
|
|
54
56
|
|
|
@@ -10,11 +10,12 @@
|
|
|
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
12
|
# 2.0.1 05/2026 - Remove tox workflow and setup.py, standardize uv + coverage tooling
|
|
13
|
+
# 2.0.2 05/2026 - Add PyPI long description metadata and release polish
|
|
13
14
|
# ----------------------------------------------------------------------------------------
|
|
14
15
|
|
|
15
16
|
VERSION_MAJOR = 2
|
|
16
17
|
VERSION_MINOR = 0
|
|
17
|
-
VERSION_PATCH =
|
|
18
|
+
VERSION_PATCH = 2
|
|
18
19
|
|
|
19
20
|
version = f'{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}'
|
|
20
21
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-backpack"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.2"
|
|
4
4
|
description = "A collection of personal scripts for json, File/Folder Operations, String Validation, Custom Errors, Cache and stuff."
|
|
5
|
+
readme = "README.md"
|
|
5
6
|
authors = [
|
|
6
7
|
{ name = "Maximiliano Rocamora" }
|
|
7
8
|
]
|
python_backpack-2.0.1/PKG-INFO
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
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
|