pygenutils 16.3.2__tar.gz → 17.1.1__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.
- {pygenutils-16.3.2/pygenutils.egg-info → pygenutils-17.1.1}/PKG-INFO +37 -33
- {pygenutils-16.3.2 → pygenutils-17.1.1}/README.md +29 -28
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/__init__.py +1 -1
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/arrays_and_lists/data_manipulation.py +3 -3
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/number_bases/base_converters.py +15 -14
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/strings/string_handler.py +52 -18
- pygenutils-17.1.1/pygenutils/time_handling/_optional_climate.py +44 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/calendar_utils.py +4 -2
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/countdown.py +20 -7
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/date_and_time_utils.py +38 -13
- {pygenutils-16.3.2 → pygenutils-17.1.1/pygenutils.egg-info}/PKG-INFO +37 -33
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils.egg-info/SOURCES.txt +1 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils.egg-info/requires.txt +8 -4
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pyproject.toml +9 -5
- {pygenutils-16.3.2 → pygenutils-17.1.1}/LICENSE +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/MANIFEST.in +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/arrays_and_lists/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/arrays_and_lists/conversions.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/arrays_and_lists/maths.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/arrays_and_lists/patterns.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/audio_and_video/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/audio_and_video/audio_and_video_manipulation.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/audio_and_video/merge_audio_and_video.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/audio_and_video/merge_audio_or_video.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/audio_and_video/trim_media.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/dictionaries/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/dictionaries/dict_handler.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/dictionaries/dict_operators.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/number_bases/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/number_bases/binary_operations.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/number_bases/bitwise_operators.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/number_bases/mathematical_utils.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/operative_systems/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/operative_systems/os_operations.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/sets_and_intervals/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/sets_and_intervals/interval_handler.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/sets_and_intervals/sets_handler.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/strings/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/strings/text_formatters.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/__init__.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/date_and_time_maths.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/program_snippet_exec_timers.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/time_formatters.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/time_utils.py +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils.egg-info/dependency_links.txt +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils.egg-info/top_level.txt +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/setup.cfg +0 -0
- {pygenutils-16.3.2 → pygenutils-17.1.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygenutils
|
|
3
|
-
Version:
|
|
3
|
+
Version: 17.1.1
|
|
4
4
|
Summary: A comprehensive Python utility library for general-purpose and specialised tasks
|
|
5
5
|
Author-email: Jon Ander Gabantxo <jagabantxo@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -43,10 +43,12 @@ Requires-Python: >=3.10
|
|
|
43
43
|
Description-Content-Type: text/markdown
|
|
44
44
|
License-File: LICENSE
|
|
45
45
|
Requires-Dist: more_itertools>=10.0.0
|
|
46
|
-
Requires-Dist: numpy
|
|
47
|
-
Requires-Dist: pandas
|
|
48
|
-
Requires-Dist: filewise>=3.
|
|
49
|
-
Requires-Dist: paramlib>=3.
|
|
46
|
+
Requires-Dist: numpy>=2.2.3
|
|
47
|
+
Requires-Dist: pandas>=2.2.3
|
|
48
|
+
Requires-Dist: filewise>=3.14.0
|
|
49
|
+
Requires-Dist: paramlib>=3.5.0
|
|
50
|
+
Provides-Extra: climate
|
|
51
|
+
Requires-Dist: climarraykit>=0.2.1; extra == "climate"
|
|
50
52
|
Provides-Extra: xarray
|
|
51
53
|
Requires-Dist: xarray>=2024.2.0; extra == "xarray"
|
|
52
54
|
Provides-Extra: arrow
|
|
@@ -58,12 +60,13 @@ Requires-Dist: black>=23.0.0; extra == "dev"
|
|
|
58
60
|
Requires-Dist: isort>=5.0.0; extra == "dev"
|
|
59
61
|
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
60
62
|
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
63
|
+
Requires-Dist: climarraykit>=0.2.1; extra == "dev"
|
|
61
64
|
Dynamic: license-file
|
|
62
65
|
|
|
63
66
|
# pygenutils
|
|
64
67
|
|
|
65
68
|
[](https://www.python.org/downloads/)
|
|
66
|
-
[](LICENSE)
|
|
69
|
+
[](https://github.com/EusDancerDev/pygenutils/blob/main/LICENSE)
|
|
67
70
|
[](https://pypi.org/project/pygenutils/)
|
|
68
71
|
|
|
69
72
|
**pygenutils** is a comprehensive Python utilities package designed to provide a wide range of general-purpose tools for data manipulation, string handling, time operations, and system interactions. It serves as a collection of commonly needed utilities for Python development.
|
|
@@ -119,15 +122,18 @@ This package has minimal external dependencies and is designed to be lightweight
|
|
|
119
122
|
|
|
120
123
|
```bash
|
|
121
124
|
pip install pygenutils # Core functionality
|
|
122
|
-
pip install pygenutils[
|
|
125
|
+
pip install 'pygenutils[climate]' # NetCDF / climarraykit features in time_handling
|
|
126
|
+
pip install pygenutils[arrow] # Arrow support (optional)
|
|
123
127
|
```
|
|
124
128
|
|
|
125
|
-
|
|
129
|
+
Core install pulls **numpy**, **pandas**, **filewise**, **paramlib**, and **more_itertools**. **climarraykit** (and thus **xarray** for those code paths) is optional.
|
|
126
130
|
|
|
127
|
-
**
|
|
131
|
+
**Optional extras**:
|
|
128
132
|
|
|
129
|
-
- `pip install pygenutils`
|
|
130
|
-
- `pip install pygenutils[
|
|
133
|
+
- `pip install pygenutils` — core only (no climarraykit)
|
|
134
|
+
- `pip install 'pygenutils[climate]'` — NetCDF helpers (`ncfile_integrity_status`, `get_file_dimensions` proxies)
|
|
135
|
+
- `pip install pygenutils[arrow]` — Arrow for enhanced time handling
|
|
136
|
+
- `pip install pygenutils[xarray]` — xarray only (rare; prefer `[climate]` for climarraykit-backed APIs)
|
|
131
137
|
|
|
132
138
|
### Package Updates
|
|
133
139
|
|
|
@@ -154,7 +160,7 @@ cd pygenutils
|
|
|
154
160
|
pip install -e .[dev]
|
|
155
161
|
```
|
|
156
162
|
|
|
157
|
-
**Note**: The `-e` flag installs the package in "editable" mode
|
|
163
|
+
**Note**: The `-e` flag installs the package in "editable" mode. The `[dev]` extra includes development tools **and** `climarraykit` so time-handling tests and NetCDF code paths work without a separate `[climate]` install.
|
|
158
164
|
|
|
159
165
|
#### Alternative Setup (Explicit Git Dependencies)
|
|
160
166
|
|
|
@@ -168,11 +174,11 @@ cd pygenutils
|
|
|
168
174
|
# Install development dependencies from requirements-dev.txt
|
|
169
175
|
pip install -r requirements-dev.txt
|
|
170
176
|
|
|
171
|
-
# Install in editable mode
|
|
172
|
-
pip install -e .
|
|
177
|
+
# Install in editable mode (add [climate] if you skip Git climarraykit and need NetCDF features)
|
|
178
|
+
pip install -e .[dev]
|
|
173
179
|
```
|
|
174
180
|
|
|
175
|
-
This approach gives you
|
|
181
|
+
This approach gives you Git checkouts of **filewise**, **climarraykit**, and **paramlib** plus pinned scientific stack; use **`pip install -e .[dev]`** so editable **pygenutils** matches **`pyproject.toml`** (including dev + climarraykit).
|
|
176
182
|
|
|
177
183
|
#### Development with Optional Dependencies
|
|
178
184
|
|
|
@@ -183,7 +189,8 @@ For full development capabilities, including testing and linting:
|
|
|
183
189
|
pip install -e ".[dev]"
|
|
184
190
|
|
|
185
191
|
# Or install specific optional dependencies
|
|
186
|
-
pip install -e ".[
|
|
192
|
+
pip install -e ".[climate]" # climarraykit / NetCDF-related time_handling
|
|
193
|
+
pip install -e ".[xarray]" # xarray only (optional; [climate] is usually preferred)
|
|
187
194
|
```
|
|
188
195
|
|
|
189
196
|
### For Multiple Package Development
|
|
@@ -194,20 +201,22 @@ If you're working on multiple interdependent packages simultaneously:
|
|
|
194
201
|
# Clone all repositories
|
|
195
202
|
git clone https://github.com/EusDancerDev/pygenutils.git
|
|
196
203
|
git clone https://github.com/EusDancerDev/filewise.git
|
|
204
|
+
git clone https://github.com/EusDancerDev/climarraykit.git
|
|
197
205
|
git clone https://github.com/EusDancerDev/paramlib.git
|
|
198
206
|
|
|
199
|
-
# Install each in editable mode
|
|
207
|
+
# Install each in editable mode (order: dependencies first)
|
|
200
208
|
pip install -e ./filewise
|
|
201
209
|
pip install -e ./paramlib
|
|
202
|
-
pip install -e ./
|
|
210
|
+
pip install -e ./climarraykit
|
|
211
|
+
pip install -e ./pygenutils[dev]
|
|
203
212
|
```
|
|
204
213
|
|
|
205
214
|
### Troubleshooting
|
|
206
215
|
|
|
207
216
|
If you encounter import errors after cloning:
|
|
208
217
|
|
|
209
|
-
1. **For regular users**: Run `pip install pygenutils` (
|
|
210
|
-
2. **For developers**: Run `pip install -e .[dev]`
|
|
218
|
+
1. **For regular users**: Run `pip install pygenutils` (core dependencies) or `pip install 'pygenutils[climate]'` for NetCDF/climarraykit features
|
|
219
|
+
2. **For developers**: Run `pip install -e .[dev]` (includes dev tools and climarraykit)
|
|
211
220
|
3. **Verify Python environment**: Make sure you're using a compatible Python version (3.10+)
|
|
212
221
|
|
|
213
222
|
### Verify Installation
|
|
@@ -227,21 +236,16 @@ try:
|
|
|
227
236
|
|
|
228
237
|
except ImportError as e:
|
|
229
238
|
print(f"❌ Import error: {e}")
|
|
230
|
-
print("💡 For regular users: pip install pygenutils")
|
|
239
|
+
print("💡 For regular users: pip install pygenutils # add [climate] for NetCDF features")
|
|
231
240
|
print("💡 For developers: pip install -e .[dev]")
|
|
232
241
|
```
|
|
233
242
|
|
|
234
243
|
### Implementation Notes
|
|
235
244
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
- **
|
|
239
|
-
- **
|
|
240
|
-
- **Installation Methods**:
|
|
241
|
-
- **Regular users**: Simple `pip install pygenutils` with all dependencies included
|
|
242
|
-
- **Developers**: `pip install -e .[dev]` for latest Git versions and development tools
|
|
243
|
-
- **PyPI Compatibility**: All packages can be published without Git dependency issues
|
|
244
|
-
- **Development Flexibility**: Contributors get access to latest versions for testing and development
|
|
245
|
+
- **Core PyPI dependencies**: **more_itertools**, **numpy**, **pandas**, **filewise**, **paramlib**.
|
|
246
|
+
- **Optional `[climate]`**: **climarraykit** (pulls **xarray**) for NetCDF-related helpers in `time_handling`.
|
|
247
|
+
- **Optional `[dev]`**: development tools plus **climarraykit** for a full local test stack.
|
|
248
|
+
- **Git-based `requirements-dev.txt`**: optional bleeding-edge **filewise**, **climarraykit**, **paramlib** before `pip install -e .[dev]`.
|
|
245
249
|
|
|
246
250
|
### Package Structure
|
|
247
251
|
|
|
@@ -284,8 +288,8 @@ The package is organised into several specialised modules:
|
|
|
284
288
|
|
|
285
289
|
For detailed version history and changes, please refer to:
|
|
286
290
|
|
|
287
|
-
-
|
|
288
|
-
-
|
|
291
|
+
- [Changelog](https://github.com/EusDancerDev/pygenutils/blob/main/pygenutils/CHANGELOG.md): comprehensive list of changes for each version
|
|
292
|
+
- [Versioning](https://github.com/EusDancerDev/pygenutils/blob/main/pygenutils/VERSIONING.md): versioning policy and guidelines
|
|
289
293
|
|
|
290
294
|
## Usage Examples
|
|
291
295
|
|
|
@@ -350,4 +354,4 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major
|
|
|
350
354
|
|
|
351
355
|
## License
|
|
352
356
|
|
|
353
|
-
This project is licensed under the MIT License
|
|
357
|
+
This project is licensed under the MIT License — see the [LICENSE](https://github.com/EusDancerDev/pygenutils/blob/main/LICENSE) file in the repository for details.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pygenutils
|
|
2
2
|
|
|
3
3
|
[](https://www.python.org/downloads/)
|
|
4
|
-
[](LICENSE)
|
|
4
|
+
[](https://github.com/EusDancerDev/pygenutils/blob/main/LICENSE)
|
|
5
5
|
[](https://pypi.org/project/pygenutils/)
|
|
6
6
|
|
|
7
7
|
**pygenutils** is a comprehensive Python utilities package designed to provide a wide range of general-purpose tools for data manipulation, string handling, time operations, and system interactions. It serves as a collection of commonly needed utilities for Python development.
|
|
@@ -57,15 +57,18 @@ This package has minimal external dependencies and is designed to be lightweight
|
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
pip install pygenutils # Core functionality
|
|
60
|
-
pip install pygenutils[
|
|
60
|
+
pip install 'pygenutils[climate]' # NetCDF / climarraykit features in time_handling
|
|
61
|
+
pip install pygenutils[arrow] # Arrow support (optional)
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
Core install pulls **numpy**, **pandas**, **filewise**, **paramlib**, and **more_itertools**. **climarraykit** (and thus **xarray** for those code paths) is optional.
|
|
64
65
|
|
|
65
|
-
**
|
|
66
|
+
**Optional extras**:
|
|
66
67
|
|
|
67
|
-
- `pip install pygenutils`
|
|
68
|
-
- `pip install pygenutils[
|
|
68
|
+
- `pip install pygenutils` — core only (no climarraykit)
|
|
69
|
+
- `pip install 'pygenutils[climate]'` — NetCDF helpers (`ncfile_integrity_status`, `get_file_dimensions` proxies)
|
|
70
|
+
- `pip install pygenutils[arrow]` — Arrow for enhanced time handling
|
|
71
|
+
- `pip install pygenutils[xarray]` — xarray only (rare; prefer `[climate]` for climarraykit-backed APIs)
|
|
69
72
|
|
|
70
73
|
### Package Updates
|
|
71
74
|
|
|
@@ -92,7 +95,7 @@ cd pygenutils
|
|
|
92
95
|
pip install -e .[dev]
|
|
93
96
|
```
|
|
94
97
|
|
|
95
|
-
**Note**: The `-e` flag installs the package in "editable" mode
|
|
98
|
+
**Note**: The `-e` flag installs the package in "editable" mode. The `[dev]` extra includes development tools **and** `climarraykit` so time-handling tests and NetCDF code paths work without a separate `[climate]` install.
|
|
96
99
|
|
|
97
100
|
#### Alternative Setup (Explicit Git Dependencies)
|
|
98
101
|
|
|
@@ -106,11 +109,11 @@ cd pygenutils
|
|
|
106
109
|
# Install development dependencies from requirements-dev.txt
|
|
107
110
|
pip install -r requirements-dev.txt
|
|
108
111
|
|
|
109
|
-
# Install in editable mode
|
|
110
|
-
pip install -e .
|
|
112
|
+
# Install in editable mode (add [climate] if you skip Git climarraykit and need NetCDF features)
|
|
113
|
+
pip install -e .[dev]
|
|
111
114
|
```
|
|
112
115
|
|
|
113
|
-
This approach gives you
|
|
116
|
+
This approach gives you Git checkouts of **filewise**, **climarraykit**, and **paramlib** plus pinned scientific stack; use **`pip install -e .[dev]`** so editable **pygenutils** matches **`pyproject.toml`** (including dev + climarraykit).
|
|
114
117
|
|
|
115
118
|
#### Development with Optional Dependencies
|
|
116
119
|
|
|
@@ -121,7 +124,8 @@ For full development capabilities, including testing and linting:
|
|
|
121
124
|
pip install -e ".[dev]"
|
|
122
125
|
|
|
123
126
|
# Or install specific optional dependencies
|
|
124
|
-
pip install -e ".[
|
|
127
|
+
pip install -e ".[climate]" # climarraykit / NetCDF-related time_handling
|
|
128
|
+
pip install -e ".[xarray]" # xarray only (optional; [climate] is usually preferred)
|
|
125
129
|
```
|
|
126
130
|
|
|
127
131
|
### For Multiple Package Development
|
|
@@ -132,20 +136,22 @@ If you're working on multiple interdependent packages simultaneously:
|
|
|
132
136
|
# Clone all repositories
|
|
133
137
|
git clone https://github.com/EusDancerDev/pygenutils.git
|
|
134
138
|
git clone https://github.com/EusDancerDev/filewise.git
|
|
139
|
+
git clone https://github.com/EusDancerDev/climarraykit.git
|
|
135
140
|
git clone https://github.com/EusDancerDev/paramlib.git
|
|
136
141
|
|
|
137
|
-
# Install each in editable mode
|
|
142
|
+
# Install each in editable mode (order: dependencies first)
|
|
138
143
|
pip install -e ./filewise
|
|
139
144
|
pip install -e ./paramlib
|
|
140
|
-
pip install -e ./
|
|
145
|
+
pip install -e ./climarraykit
|
|
146
|
+
pip install -e ./pygenutils[dev]
|
|
141
147
|
```
|
|
142
148
|
|
|
143
149
|
### Troubleshooting
|
|
144
150
|
|
|
145
151
|
If you encounter import errors after cloning:
|
|
146
152
|
|
|
147
|
-
1. **For regular users**: Run `pip install pygenutils` (
|
|
148
|
-
2. **For developers**: Run `pip install -e .[dev]`
|
|
153
|
+
1. **For regular users**: Run `pip install pygenutils` (core dependencies) or `pip install 'pygenutils[climate]'` for NetCDF/climarraykit features
|
|
154
|
+
2. **For developers**: Run `pip install -e .[dev]` (includes dev tools and climarraykit)
|
|
149
155
|
3. **Verify Python environment**: Make sure you're using a compatible Python version (3.10+)
|
|
150
156
|
|
|
151
157
|
### Verify Installation
|
|
@@ -165,21 +171,16 @@ try:
|
|
|
165
171
|
|
|
166
172
|
except ImportError as e:
|
|
167
173
|
print(f"❌ Import error: {e}")
|
|
168
|
-
print("💡 For regular users: pip install pygenutils")
|
|
174
|
+
print("💡 For regular users: pip install pygenutils # add [climate] for NetCDF features")
|
|
169
175
|
print("💡 For developers: pip install -e .[dev]")
|
|
170
176
|
```
|
|
171
177
|
|
|
172
178
|
### Implementation Notes
|
|
173
179
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
- **
|
|
177
|
-
- **
|
|
178
|
-
- **Installation Methods**:
|
|
179
|
-
- **Regular users**: Simple `pip install pygenutils` with all dependencies included
|
|
180
|
-
- **Developers**: `pip install -e .[dev]` for latest Git versions and development tools
|
|
181
|
-
- **PyPI Compatibility**: All packages can be published without Git dependency issues
|
|
182
|
-
- **Development Flexibility**: Contributors get access to latest versions for testing and development
|
|
180
|
+
- **Core PyPI dependencies**: **more_itertools**, **numpy**, **pandas**, **filewise**, **paramlib**.
|
|
181
|
+
- **Optional `[climate]`**: **climarraykit** (pulls **xarray**) for NetCDF-related helpers in `time_handling`.
|
|
182
|
+
- **Optional `[dev]`**: development tools plus **climarraykit** for a full local test stack.
|
|
183
|
+
- **Git-based `requirements-dev.txt`**: optional bleeding-edge **filewise**, **climarraykit**, **paramlib** before `pip install -e .[dev]`.
|
|
183
184
|
|
|
184
185
|
### Package Structure
|
|
185
186
|
|
|
@@ -222,8 +223,8 @@ The package is organised into several specialised modules:
|
|
|
222
223
|
|
|
223
224
|
For detailed version history and changes, please refer to:
|
|
224
225
|
|
|
225
|
-
-
|
|
226
|
-
-
|
|
226
|
+
- [Changelog](https://github.com/EusDancerDev/pygenutils/blob/main/pygenutils/CHANGELOG.md): comprehensive list of changes for each version
|
|
227
|
+
- [Versioning](https://github.com/EusDancerDev/pygenutils/blob/main/pygenutils/VERSIONING.md): versioning policy and guidelines
|
|
227
228
|
|
|
228
229
|
## Usage Examples
|
|
229
230
|
|
|
@@ -288,4 +289,4 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major
|
|
|
288
289
|
|
|
289
290
|
## License
|
|
290
291
|
|
|
291
|
-
This project is licensed under the MIT License
|
|
292
|
+
This project is licensed under the MIT License — see the [LICENSE](https://github.com/EusDancerDev/pygenutils/blob/main/LICENSE) file in the repository for details.
|
|
@@ -535,10 +535,10 @@ def flatten_list(lst, return_list=True, sort=False, reverse=False):
|
|
|
535
535
|
[1, 2, 3, 4, 5, 6]
|
|
536
536
|
"""
|
|
537
537
|
if return_list:
|
|
538
|
-
|
|
538
|
+
flattened_list = list(_flatten_generator(lst))
|
|
539
539
|
if sort:
|
|
540
|
-
return sort_1d_basic(
|
|
541
|
-
return
|
|
540
|
+
return sort_1d_basic(flattened_list, reverse=reverse)
|
|
541
|
+
return flattened_list
|
|
542
542
|
else:
|
|
543
543
|
return _flatten_generator(lst)
|
|
544
544
|
|
|
@@ -59,8 +59,8 @@ def _check_input_binary(b):
|
|
|
59
59
|
str
|
|
60
60
|
The binary number as a string without the 'b' or '0b' prefix.
|
|
61
61
|
"""
|
|
62
|
-
b_clean = substring_replacer(substring_replacer(b, "
|
|
63
|
-
are_only_binaries = find_substring_index(b_clean, r"^[01]+$")
|
|
62
|
+
b_clean = substring_replacer(substring_replacer(b, "0b", ""), "b", "")
|
|
63
|
+
are_only_binaries = find_substring_index(b_clean, r"^[01]+$", advanced_search=True)
|
|
64
64
|
if are_only_binaries == -1:
|
|
65
65
|
raise ValueError("The input binary number is not in the correct format.")
|
|
66
66
|
return b_clean
|
|
@@ -130,12 +130,12 @@ def dec2bin_basic(n):
|
|
|
130
130
|
The binary representation of the input number.
|
|
131
131
|
"""
|
|
132
132
|
n_checked = _check_input_int(n)
|
|
133
|
-
|
|
133
|
+
bits_lsb_first = "" # LSB == Least Significant Bit
|
|
134
134
|
while n_checked >= 1:
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
mod = n_checked % 2
|
|
136
|
+
bits_lsb_first += str(mod)
|
|
137
137
|
n_checked //= 2
|
|
138
|
-
return
|
|
138
|
+
return bits_lsb_first[::-1]
|
|
139
139
|
|
|
140
140
|
# Advanced #
|
|
141
141
|
#-#-#-#-#-#-
|
|
@@ -280,16 +280,17 @@ def bin2dec_basic(b, procedure="loop"):
|
|
|
280
280
|
# Calculation #
|
|
281
281
|
###############
|
|
282
282
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
res = sum(summands_iter)
|
|
283
|
+
# Take the LSB at index 0 of reversed string — bit i contributes int(bit) * 2**i
|
|
284
|
+
b_lsb_first = b_checked[::-1]
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
for pos, i in enumerate(range(lb-1,-1,-1)):
|
|
290
|
-
res += int(b_checked[i]) * 2 ** pos
|
|
291
|
-
return res
|
|
286
|
+
if procedure == "list_comprehension":
|
|
287
|
+
return sum(int(b_lsb_first[i]) * 2**i for i in range(lb))
|
|
292
288
|
|
|
289
|
+
res = 0
|
|
290
|
+
for i in range(lb):
|
|
291
|
+
res += int(b_lsb_first[i]) * 2**i
|
|
292
|
+
return res
|
|
293
|
+
|
|
293
294
|
|
|
294
295
|
def oct2dec(n_oct):
|
|
295
296
|
"""
|
|
@@ -365,7 +365,7 @@ def _return_search_obj_spec(string, substring, re_obj_str,
|
|
|
365
365
|
# Specifications of a file or directory path #
|
|
366
366
|
##############################################
|
|
367
367
|
|
|
368
|
-
def obj_path_specs(obj_path, module="os", SPLIT_DELIM=None):
|
|
368
|
+
def obj_path_specs(obj_path, module="os", SPLIT_DELIM=None, parent_levels=1):
|
|
369
369
|
"""
|
|
370
370
|
Retrieve the specifications of a file or directory path.
|
|
371
371
|
|
|
@@ -381,12 +381,16 @@ def obj_path_specs(obj_path, module="os", SPLIT_DELIM=None):
|
|
|
381
381
|
The module to use for path processing. Options are 'os' (default) and 'Path' (from pathlib).
|
|
382
382
|
SPLIT_DELIM : str, optional
|
|
383
383
|
Delimiter for splitting the file name (without extension) into parts. If None, no splitting is performed.
|
|
384
|
+
parent_levels : int, optional
|
|
385
|
+
How many parent directories to walk from ``obj_path`` for the ``'parent'`` entry (default ``1``
|
|
386
|
+
is the immediate parent). Pathlib uses a single ``.parents[parent_levels - 1]`` lookup; ``os`` uses
|
|
387
|
+
repeated ``os.path.dirname`` calls.
|
|
384
388
|
|
|
385
389
|
Returns
|
|
386
390
|
-------
|
|
387
391
|
obj_specs_dict : dict
|
|
388
392
|
A dictionary containing the following path components:
|
|
389
|
-
- 'parent': The parent directory of the path.
|
|
393
|
+
- 'parent': The parent directory of the path (or the ancestor ``parent_levels`` steps up).
|
|
390
394
|
- 'name': The full name of the file or directory.
|
|
391
395
|
- 'name_noext': The file or directory name without the extension.
|
|
392
396
|
- 'ext': The file extension (without the dot).
|
|
@@ -395,7 +399,7 @@ def obj_path_specs(obj_path, module="os", SPLIT_DELIM=None):
|
|
|
395
399
|
Raises
|
|
396
400
|
------
|
|
397
401
|
ValueError
|
|
398
|
-
If an unsupported module is provided.
|
|
402
|
+
If an unsupported module is provided, or if ``parent_levels`` is less than 1.
|
|
399
403
|
"""
|
|
400
404
|
|
|
401
405
|
# List of supported modules for path specification retrieval
|
|
@@ -406,8 +410,11 @@ def obj_path_specs(obj_path, module="os", SPLIT_DELIM=None):
|
|
|
406
410
|
raise ValueError(f"Unsupported module '{module}'. "
|
|
407
411
|
f"Choose one from {path_specs_retrieval_modules}.")
|
|
408
412
|
|
|
413
|
+
if parent_levels < 1:
|
|
414
|
+
raise ValueError("'parent_levels' must be an integer >= 1.")
|
|
415
|
+
|
|
409
416
|
# Retrieve path specifications based on the chosen module
|
|
410
|
-
obj_specs_dict = PATH_FUNCTIONS[module](obj_path)
|
|
417
|
+
obj_specs_dict = PATH_FUNCTIONS[module](obj_path, parent_levels)
|
|
411
418
|
|
|
412
419
|
# Optionally, split the file name without extension by the specified delimiter
|
|
413
420
|
if SPLIT_DELIM:
|
|
@@ -419,7 +426,7 @@ def obj_path_specs(obj_path, module="os", SPLIT_DELIM=None):
|
|
|
419
426
|
# Specific component retrieval #
|
|
420
427
|
################################
|
|
421
428
|
|
|
422
|
-
def get_obj_specs(obj_path, obj_spec_key=None, SPLIT_DELIM=None):
|
|
429
|
+
def get_obj_specs(obj_path, obj_spec_key=None, SPLIT_DELIM=None, parent_levels=1):
|
|
423
430
|
"""
|
|
424
431
|
Retrieve a specific component of a file or directory path.
|
|
425
432
|
|
|
@@ -442,6 +449,8 @@ def get_obj_specs(obj_path, obj_spec_key=None, SPLIT_DELIM=None):
|
|
|
442
449
|
SPLIT_DELIM : str, optional
|
|
443
450
|
Delimiter for splitting the file name (without extension) into parts.
|
|
444
451
|
Required if `obj_spec_key` is 'name_noext_parts'.
|
|
452
|
+
parent_levels : int, optional
|
|
453
|
+
Passed to :func:`obj_path_specs` when resolving a path string (see ``parent_levels`` there).
|
|
445
454
|
|
|
446
455
|
Returns
|
|
447
456
|
-------
|
|
@@ -465,7 +474,9 @@ def get_obj_specs(obj_path, obj_spec_key=None, SPLIT_DELIM=None):
|
|
|
465
474
|
|
|
466
475
|
# If obj_path is not already a dictionary, get the path specifications
|
|
467
476
|
if not isinstance(obj_path, dict):
|
|
468
|
-
obj_specs_dict = obj_path_specs(
|
|
477
|
+
obj_specs_dict = obj_path_specs(
|
|
478
|
+
obj_path, SPLIT_DELIM=SPLIT_DELIM, parent_levels=parent_levels
|
|
479
|
+
)
|
|
469
480
|
else:
|
|
470
481
|
obj_specs_dict = obj_path
|
|
471
482
|
|
|
@@ -828,19 +839,42 @@ STRIP_OPTION_DICT = {
|
|
|
828
839
|
}
|
|
829
840
|
|
|
830
841
|
# File or directory path specifications retrieval #
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
'
|
|
842
|
-
'
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
def _path_specs_os(obj_path, parent_levels=1):
|
|
845
|
+
"""Single basename/splitext pass; parent via repeated dirname (same as n-1 index in Path.parents)."""
|
|
846
|
+
base = os.path.basename(obj_path)
|
|
847
|
+
root, ext_with_dot = os.path.splitext(base)
|
|
848
|
+
parent = obj_path
|
|
849
|
+
for _ in range(parent_levels):
|
|
850
|
+
parent = os.path.dirname(parent)
|
|
851
|
+
return {
|
|
852
|
+
'parent': parent,
|
|
853
|
+
'name': base,
|
|
854
|
+
'name_noext': root,
|
|
855
|
+
'ext': ext_with_dot[1:],
|
|
843
856
|
}
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
def _path_specs_pathlib(obj_path, parent_levels=1):
|
|
860
|
+
"""Single Path instance; use ``.parent`` for one level (root-safe), else ``.parents[...]``."""
|
|
861
|
+
p = Path(obj_path)
|
|
862
|
+
ext = p.suffix
|
|
863
|
+
if parent_levels == 1:
|
|
864
|
+
parent = p.parent
|
|
865
|
+
else:
|
|
866
|
+
parent = p.parents[parent_levels - 1]
|
|
867
|
+
return {
|
|
868
|
+
'parent': parent,
|
|
869
|
+
'name': p.name,
|
|
870
|
+
'name_noext': p.stem,
|
|
871
|
+
'ext': ext[1:] if ext else '',
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
PATH_FUNCTIONS = {
|
|
876
|
+
'os': _path_specs_os,
|
|
877
|
+
'Path': _path_specs_pathlib,
|
|
844
878
|
}
|
|
845
879
|
|
|
846
880
|
# Index return types for pattern matches #
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Optional climarraykit-backed helpers for NetCDF and dimension utilities.
|
|
5
|
+
|
|
6
|
+
Install with::
|
|
7
|
+
|
|
8
|
+
pip install 'pygenutils[climate]'
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from functools import cache
|
|
12
|
+
|
|
13
|
+
_INSTALL_MSG = (
|
|
14
|
+
"NetCDF / climarraykit features require optional dependencies. "
|
|
15
|
+
"Install with: pip install 'pygenutils[climate]'"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@cache
|
|
20
|
+
def _ncfile_integrity_status_fn():
|
|
21
|
+
try:
|
|
22
|
+
from climarraykit.file_utils import ncfile_integrity_status
|
|
23
|
+
except ImportError as exc:
|
|
24
|
+
raise ImportError(_INSTALL_MSG) from exc
|
|
25
|
+
return ncfile_integrity_status
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def ncfile_integrity_status(*args, **kwargs):
|
|
29
|
+
"""Proxy to :func:`climarraykit.file_utils.ncfile_integrity_status` when ``[climate]`` is installed."""
|
|
30
|
+
return _ncfile_integrity_status_fn()(*args, **kwargs)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@cache
|
|
34
|
+
def _get_file_dimensions_fn():
|
|
35
|
+
try:
|
|
36
|
+
from climarraykit.patterns import get_file_dimensions
|
|
37
|
+
except ImportError as exc:
|
|
38
|
+
raise ImportError(_INSTALL_MSG) from exc
|
|
39
|
+
return get_file_dimensions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_file_dimensions(*args, **kwargs):
|
|
43
|
+
"""Proxy to :func:`climarraykit.patterns.get_file_dimensions` when ``[climate]`` is installed."""
|
|
44
|
+
return _get_file_dimensions_fn()(*args, **kwargs)
|
|
@@ -169,13 +169,15 @@ def standardise_calendar(obj,
|
|
|
169
169
|
|
|
170
170
|
return obj_std_calendar
|
|
171
171
|
|
|
172
|
-
# Handling xarray datasets or data arrays
|
|
172
|
+
# Handling xarray datasets or data arrays (no xarray/climarraykit at module import;
|
|
173
|
+
# cftime_range and get_file_dimensions are loaded only for this branch)
|
|
173
174
|
elif obj_type in ["dataarray", "dataset"] \
|
|
174
175
|
or (obj_type == "list" and all(get_type_str(element) in ["dataarray", "dataset"]
|
|
175
176
|
for element in obj)):
|
|
176
177
|
|
|
177
178
|
from xarray import cftime_range
|
|
178
|
-
|
|
179
|
+
|
|
180
|
+
from ._optional_climate import get_file_dimensions
|
|
179
181
|
|
|
180
182
|
if isinstance(obj, list):
|
|
181
183
|
obj = obj[0] # Assuming only one object in the list
|
|
@@ -98,11 +98,20 @@ def __countdown(time_str, dt_fmt_str):
|
|
|
98
98
|
hours, minutes, seconds = dt_obj.hour, dt_obj.minute, dt_obj.second
|
|
99
99
|
|
|
100
100
|
if days > 0:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
dt_args_day = {
|
|
102
|
+
"days": days,
|
|
103
|
+
"hours": hours,
|
|
104
|
+
"minutes": minutes,
|
|
105
|
+
"seconds": seconds,
|
|
106
|
+
}
|
|
107
|
+
time_display = format_string(TIME_STR_PARTS_FMTS[0], dt_args_day)
|
|
108
|
+
else:
|
|
109
|
+
dt_args_noday = {
|
|
110
|
+
"hours": hours,
|
|
111
|
+
"minutes": minutes,
|
|
112
|
+
"seconds": seconds,
|
|
113
|
+
}
|
|
114
|
+
time_display = format_string(TIME_STR_PARTS_FMTS[1], dt_args_noday)
|
|
106
115
|
|
|
107
116
|
# Rellenar la cadena de visualización para limpiar caracteres sobrantes
|
|
108
117
|
# Pad the display string to clear any leftover characters
|
|
@@ -122,10 +131,14 @@ def __countdown(time_str, dt_fmt_str):
|
|
|
122
131
|
print("\nTime up!")
|
|
123
132
|
|
|
124
133
|
#---------------------------------#
|
|
125
|
-
# Define parameters and
|
|
134
|
+
# Define parameters and templates #
|
|
126
135
|
#---------------------------------#
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
# Named fields for format_string(..., dict); see pygenutils.strings.text_formatters.format_string.
|
|
138
|
+
TIME_STR_PARTS_FMTS = [
|
|
139
|
+
"{days} days {hours:02d}:{minutes:02d}:{seconds:02d}",
|
|
140
|
+
"{hours:02d}:{minutes:02d}:{seconds:02d}",
|
|
141
|
+
]
|
|
129
142
|
|
|
130
143
|
#---------------------#
|
|
131
144
|
# Program progression #
|
|
@@ -16,14 +16,12 @@ from datetime import datetime, timedelta, timezone
|
|
|
16
16
|
|
|
17
17
|
# Third-party modules #
|
|
18
18
|
import pandas as pd
|
|
19
|
-
import xarray as xr
|
|
20
19
|
|
|
21
20
|
#------------------------#
|
|
22
21
|
# Import project modules #
|
|
23
22
|
#------------------------#
|
|
24
23
|
|
|
25
24
|
from filewise.general.introspection_utils import get_caller_args, get_type_str
|
|
26
|
-
from filewise.xarray_utils.file_utils import ncfile_integrity_status
|
|
27
25
|
from pygenutils.arrays_and_lists.data_manipulation import flatten_list
|
|
28
26
|
from pygenutils.strings.string_handler import find_substring_index
|
|
29
27
|
from pygenutils.strings.text_formatters import format_string, print_format_string
|
|
@@ -36,6 +34,19 @@ try:
|
|
|
36
34
|
except ImportError:
|
|
37
35
|
pytz_installed = False
|
|
38
36
|
|
|
37
|
+
|
|
38
|
+
def _is_xarray_dataset_or_dataarray(obj):
|
|
39
|
+
"""
|
|
40
|
+
Return True if *obj* is an xarray Dataset or DataArray without importing xarray.
|
|
41
|
+
|
|
42
|
+
Used so this module can be imported without loading xarray unless a caller
|
|
43
|
+
passes xarray objects or NetCDF paths into the helpers that need it.
|
|
44
|
+
"""
|
|
45
|
+
cls = type(obj)
|
|
46
|
+
mod = getattr(cls, "__module__", "") or ""
|
|
47
|
+
return mod.startswith("xarray.") and cls.__name__ in ("Dataset", "DataArray")
|
|
48
|
+
|
|
49
|
+
|
|
39
50
|
#------------------#
|
|
40
51
|
# Define functions #
|
|
41
52
|
#------------------#
|
|
@@ -166,7 +177,7 @@ def get_current_datetime(dtype="datetime", time_fmt_str=None, tz_arg=None):
|
|
|
166
177
|
return current_time
|
|
167
178
|
|
|
168
179
|
# Date/time attributes and keys #
|
|
169
|
-
|
|
180
|
+
#-------------------------------#
|
|
170
181
|
|
|
171
182
|
def find_dt_key(data):
|
|
172
183
|
"""
|
|
@@ -192,6 +203,13 @@ def find_dt_key(data):
|
|
|
192
203
|
If the input data type is not supported.
|
|
193
204
|
ValueError
|
|
194
205
|
If no time-related key is found.
|
|
206
|
+
|
|
207
|
+
Notes
|
|
208
|
+
-----
|
|
209
|
+
This module does not import xarray at import time. ``xarray`` is imported
|
|
210
|
+
lazily only when *data* is a file path string. NetCDF path handling uses
|
|
211
|
+
``_optional_climate`` (requires ``pip install 'pygenutils[climate]'``) in
|
|
212
|
+
:func:`infer_frequency` / :func:`infer_dt_range`.
|
|
195
213
|
"""
|
|
196
214
|
|
|
197
215
|
# Common time-related keywords - both full words and prefixes
|
|
@@ -225,8 +243,8 @@ def find_dt_key(data):
|
|
|
225
243
|
|
|
226
244
|
raise ValueError("No time-related column found in the pandas DataFrame.")
|
|
227
245
|
|
|
228
|
-
# Handle xarray objects
|
|
229
|
-
elif
|
|
246
|
+
# Handle xarray objects (no top-level xarray import; see _is_xarray_dataset_or_dataarray)
|
|
247
|
+
elif _is_xarray_dataset_or_dataarray(data):
|
|
230
248
|
# First check dimensions
|
|
231
249
|
for dim in data.dims:
|
|
232
250
|
if check_exact_match(dim):
|
|
@@ -243,9 +261,11 @@ def find_dt_key(data):
|
|
|
243
261
|
|
|
244
262
|
raise ValueError("No time-related dimension or variable found in the xarray object.")
|
|
245
263
|
|
|
246
|
-
# Handle string (assumed to be file path)
|
|
264
|
+
# Handle string (assumed to be file path); xarray loaded only for this path
|
|
247
265
|
elif isinstance(data, str):
|
|
248
266
|
try:
|
|
267
|
+
import xarray as xr
|
|
268
|
+
|
|
249
269
|
ds = xr.open_dataset(data)
|
|
250
270
|
try:
|
|
251
271
|
time_key = find_dt_key(ds)
|
|
@@ -481,6 +501,9 @@ def infer_frequency(data):
|
|
|
481
501
|
not the index.
|
|
482
502
|
- For NetCDF files, the method can handle either file paths (strings) or already-opened
|
|
483
503
|
xarray.Dataset/xarray.DataArray objects.
|
|
504
|
+
- ``xarray`` and the climarraykit-backed helpers (via ``_optional_climate``) are
|
|
505
|
+
only loaded when this function enters the NetCDF / xarray branch. Install
|
|
506
|
+
``pygenutils[climate]`` for NetCDF path support.
|
|
484
507
|
"""
|
|
485
508
|
# Check input data type #
|
|
486
509
|
#########################
|
|
@@ -505,6 +528,8 @@ def infer_frequency(data):
|
|
|
505
528
|
###############################################################
|
|
506
529
|
|
|
507
530
|
elif obj_type == "str":
|
|
531
|
+
from ._optional_climate import ncfile_integrity_status
|
|
532
|
+
|
|
508
533
|
ds = ncfile_integrity_status(data)
|
|
509
534
|
elif obj_type in ["dataset", "dataarray"]:
|
|
510
535
|
ds = data.copy()
|
|
@@ -512,11 +537,9 @@ def infer_frequency(data):
|
|
|
512
537
|
raise TypeError("Unsupported data type. Must be pandas DataFrame, "
|
|
513
538
|
"Series, DatetimeIndex, TimedeltaIndex, "
|
|
514
539
|
"NetCDF file path (string), or xarray.Dataset/DataArray.")
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
import xarray as xr
|
|
519
|
-
|
|
540
|
+
|
|
541
|
+
import xarray as xr
|
|
542
|
+
|
|
520
543
|
# Infer time frequency for NetCDF data
|
|
521
544
|
date_key = find_dt_key(ds)
|
|
522
545
|
time_freq = xr.infer_freq(ds[date_key])
|
|
@@ -554,8 +577,8 @@ def infer_dt_range(data):
|
|
|
554
577
|
-----
|
|
555
578
|
- For pandas Series, the method will infer the date range based on the series values,
|
|
556
579
|
not the index.
|
|
557
|
-
- For NetCDF
|
|
558
|
-
|
|
580
|
+
- For NetCDF file paths, ``_optional_climate.ncfile_integrity_status`` is used
|
|
581
|
+
(requires ``pip install 'pygenutils[climate]'``); xarray is not loaded at module import time.
|
|
559
582
|
"""
|
|
560
583
|
# Check input data type #
|
|
561
584
|
obj_type = get_type_str(data, lowercase=True)
|
|
@@ -569,6 +592,8 @@ def infer_dt_range(data):
|
|
|
569
592
|
|
|
570
593
|
# Section 2: Handling NetCDF Files (string or xarray objects)
|
|
571
594
|
elif obj_type == "str":
|
|
595
|
+
from ._optional_climate import ncfile_integrity_status
|
|
596
|
+
|
|
572
597
|
ds = ncfile_integrity_status(data)
|
|
573
598
|
try:
|
|
574
599
|
date_key = find_dt_key(ds)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygenutils
|
|
3
|
-
Version:
|
|
3
|
+
Version: 17.1.1
|
|
4
4
|
Summary: A comprehensive Python utility library for general-purpose and specialised tasks
|
|
5
5
|
Author-email: Jon Ander Gabantxo <jagabantxo@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -43,10 +43,12 @@ Requires-Python: >=3.10
|
|
|
43
43
|
Description-Content-Type: text/markdown
|
|
44
44
|
License-File: LICENSE
|
|
45
45
|
Requires-Dist: more_itertools>=10.0.0
|
|
46
|
-
Requires-Dist: numpy
|
|
47
|
-
Requires-Dist: pandas
|
|
48
|
-
Requires-Dist: filewise>=3.
|
|
49
|
-
Requires-Dist: paramlib>=3.
|
|
46
|
+
Requires-Dist: numpy>=2.2.3
|
|
47
|
+
Requires-Dist: pandas>=2.2.3
|
|
48
|
+
Requires-Dist: filewise>=3.14.0
|
|
49
|
+
Requires-Dist: paramlib>=3.5.0
|
|
50
|
+
Provides-Extra: climate
|
|
51
|
+
Requires-Dist: climarraykit>=0.2.1; extra == "climate"
|
|
50
52
|
Provides-Extra: xarray
|
|
51
53
|
Requires-Dist: xarray>=2024.2.0; extra == "xarray"
|
|
52
54
|
Provides-Extra: arrow
|
|
@@ -58,12 +60,13 @@ Requires-Dist: black>=23.0.0; extra == "dev"
|
|
|
58
60
|
Requires-Dist: isort>=5.0.0; extra == "dev"
|
|
59
61
|
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
60
62
|
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
63
|
+
Requires-Dist: climarraykit>=0.2.1; extra == "dev"
|
|
61
64
|
Dynamic: license-file
|
|
62
65
|
|
|
63
66
|
# pygenutils
|
|
64
67
|
|
|
65
68
|
[](https://www.python.org/downloads/)
|
|
66
|
-
[](LICENSE)
|
|
69
|
+
[](https://github.com/EusDancerDev/pygenutils/blob/main/LICENSE)
|
|
67
70
|
[](https://pypi.org/project/pygenutils/)
|
|
68
71
|
|
|
69
72
|
**pygenutils** is a comprehensive Python utilities package designed to provide a wide range of general-purpose tools for data manipulation, string handling, time operations, and system interactions. It serves as a collection of commonly needed utilities for Python development.
|
|
@@ -119,15 +122,18 @@ This package has minimal external dependencies and is designed to be lightweight
|
|
|
119
122
|
|
|
120
123
|
```bash
|
|
121
124
|
pip install pygenutils # Core functionality
|
|
122
|
-
pip install pygenutils[
|
|
125
|
+
pip install 'pygenutils[climate]' # NetCDF / climarraykit features in time_handling
|
|
126
|
+
pip install pygenutils[arrow] # Arrow support (optional)
|
|
123
127
|
```
|
|
124
128
|
|
|
125
|
-
|
|
129
|
+
Core install pulls **numpy**, **pandas**, **filewise**, **paramlib**, and **more_itertools**. **climarraykit** (and thus **xarray** for those code paths) is optional.
|
|
126
130
|
|
|
127
|
-
**
|
|
131
|
+
**Optional extras**:
|
|
128
132
|
|
|
129
|
-
- `pip install pygenutils`
|
|
130
|
-
- `pip install pygenutils[
|
|
133
|
+
- `pip install pygenutils` — core only (no climarraykit)
|
|
134
|
+
- `pip install 'pygenutils[climate]'` — NetCDF helpers (`ncfile_integrity_status`, `get_file_dimensions` proxies)
|
|
135
|
+
- `pip install pygenutils[arrow]` — Arrow for enhanced time handling
|
|
136
|
+
- `pip install pygenutils[xarray]` — xarray only (rare; prefer `[climate]` for climarraykit-backed APIs)
|
|
131
137
|
|
|
132
138
|
### Package Updates
|
|
133
139
|
|
|
@@ -154,7 +160,7 @@ cd pygenutils
|
|
|
154
160
|
pip install -e .[dev]
|
|
155
161
|
```
|
|
156
162
|
|
|
157
|
-
**Note**: The `-e` flag installs the package in "editable" mode
|
|
163
|
+
**Note**: The `-e` flag installs the package in "editable" mode. The `[dev]` extra includes development tools **and** `climarraykit` so time-handling tests and NetCDF code paths work without a separate `[climate]` install.
|
|
158
164
|
|
|
159
165
|
#### Alternative Setup (Explicit Git Dependencies)
|
|
160
166
|
|
|
@@ -168,11 +174,11 @@ cd pygenutils
|
|
|
168
174
|
# Install development dependencies from requirements-dev.txt
|
|
169
175
|
pip install -r requirements-dev.txt
|
|
170
176
|
|
|
171
|
-
# Install in editable mode
|
|
172
|
-
pip install -e .
|
|
177
|
+
# Install in editable mode (add [climate] if you skip Git climarraykit and need NetCDF features)
|
|
178
|
+
pip install -e .[dev]
|
|
173
179
|
```
|
|
174
180
|
|
|
175
|
-
This approach gives you
|
|
181
|
+
This approach gives you Git checkouts of **filewise**, **climarraykit**, and **paramlib** plus pinned scientific stack; use **`pip install -e .[dev]`** so editable **pygenutils** matches **`pyproject.toml`** (including dev + climarraykit).
|
|
176
182
|
|
|
177
183
|
#### Development with Optional Dependencies
|
|
178
184
|
|
|
@@ -183,7 +189,8 @@ For full development capabilities, including testing and linting:
|
|
|
183
189
|
pip install -e ".[dev]"
|
|
184
190
|
|
|
185
191
|
# Or install specific optional dependencies
|
|
186
|
-
pip install -e ".[
|
|
192
|
+
pip install -e ".[climate]" # climarraykit / NetCDF-related time_handling
|
|
193
|
+
pip install -e ".[xarray]" # xarray only (optional; [climate] is usually preferred)
|
|
187
194
|
```
|
|
188
195
|
|
|
189
196
|
### For Multiple Package Development
|
|
@@ -194,20 +201,22 @@ If you're working on multiple interdependent packages simultaneously:
|
|
|
194
201
|
# Clone all repositories
|
|
195
202
|
git clone https://github.com/EusDancerDev/pygenutils.git
|
|
196
203
|
git clone https://github.com/EusDancerDev/filewise.git
|
|
204
|
+
git clone https://github.com/EusDancerDev/climarraykit.git
|
|
197
205
|
git clone https://github.com/EusDancerDev/paramlib.git
|
|
198
206
|
|
|
199
|
-
# Install each in editable mode
|
|
207
|
+
# Install each in editable mode (order: dependencies first)
|
|
200
208
|
pip install -e ./filewise
|
|
201
209
|
pip install -e ./paramlib
|
|
202
|
-
pip install -e ./
|
|
210
|
+
pip install -e ./climarraykit
|
|
211
|
+
pip install -e ./pygenutils[dev]
|
|
203
212
|
```
|
|
204
213
|
|
|
205
214
|
### Troubleshooting
|
|
206
215
|
|
|
207
216
|
If you encounter import errors after cloning:
|
|
208
217
|
|
|
209
|
-
1. **For regular users**: Run `pip install pygenutils` (
|
|
210
|
-
2. **For developers**: Run `pip install -e .[dev]`
|
|
218
|
+
1. **For regular users**: Run `pip install pygenutils` (core dependencies) or `pip install 'pygenutils[climate]'` for NetCDF/climarraykit features
|
|
219
|
+
2. **For developers**: Run `pip install -e .[dev]` (includes dev tools and climarraykit)
|
|
211
220
|
3. **Verify Python environment**: Make sure you're using a compatible Python version (3.10+)
|
|
212
221
|
|
|
213
222
|
### Verify Installation
|
|
@@ -227,21 +236,16 @@ try:
|
|
|
227
236
|
|
|
228
237
|
except ImportError as e:
|
|
229
238
|
print(f"❌ Import error: {e}")
|
|
230
|
-
print("💡 For regular users: pip install pygenutils")
|
|
239
|
+
print("💡 For regular users: pip install pygenutils # add [climate] for NetCDF features")
|
|
231
240
|
print("💡 For developers: pip install -e .[dev]")
|
|
232
241
|
```
|
|
233
242
|
|
|
234
243
|
### Implementation Notes
|
|
235
244
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
- **
|
|
239
|
-
- **
|
|
240
|
-
- **Installation Methods**:
|
|
241
|
-
- **Regular users**: Simple `pip install pygenutils` with all dependencies included
|
|
242
|
-
- **Developers**: `pip install -e .[dev]` for latest Git versions and development tools
|
|
243
|
-
- **PyPI Compatibility**: All packages can be published without Git dependency issues
|
|
244
|
-
- **Development Flexibility**: Contributors get access to latest versions for testing and development
|
|
245
|
+
- **Core PyPI dependencies**: **more_itertools**, **numpy**, **pandas**, **filewise**, **paramlib**.
|
|
246
|
+
- **Optional `[climate]`**: **climarraykit** (pulls **xarray**) for NetCDF-related helpers in `time_handling`.
|
|
247
|
+
- **Optional `[dev]`**: development tools plus **climarraykit** for a full local test stack.
|
|
248
|
+
- **Git-based `requirements-dev.txt`**: optional bleeding-edge **filewise**, **climarraykit**, **paramlib** before `pip install -e .[dev]`.
|
|
245
249
|
|
|
246
250
|
### Package Structure
|
|
247
251
|
|
|
@@ -284,8 +288,8 @@ The package is organised into several specialised modules:
|
|
|
284
288
|
|
|
285
289
|
For detailed version history and changes, please refer to:
|
|
286
290
|
|
|
287
|
-
-
|
|
288
|
-
-
|
|
291
|
+
- [Changelog](https://github.com/EusDancerDev/pygenutils/blob/main/pygenutils/CHANGELOG.md): comprehensive list of changes for each version
|
|
292
|
+
- [Versioning](https://github.com/EusDancerDev/pygenutils/blob/main/pygenutils/VERSIONING.md): versioning policy and guidelines
|
|
289
293
|
|
|
290
294
|
## Usage Examples
|
|
291
295
|
|
|
@@ -350,4 +354,4 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major
|
|
|
350
354
|
|
|
351
355
|
## License
|
|
352
356
|
|
|
353
|
-
This project is licensed under the MIT License
|
|
357
|
+
This project is licensed under the MIT License — see the [LICENSE](https://github.com/EusDancerDev/pygenutils/blob/main/LICENSE) file in the repository for details.
|
|
@@ -36,6 +36,7 @@ pygenutils/strings/__init__.py
|
|
|
36
36
|
pygenutils/strings/string_handler.py
|
|
37
37
|
pygenutils/strings/text_formatters.py
|
|
38
38
|
pygenutils/time_handling/__init__.py
|
|
39
|
+
pygenutils/time_handling/_optional_climate.py
|
|
39
40
|
pygenutils/time_handling/calendar_utils.py
|
|
40
41
|
pygenutils/time_handling/countdown.py
|
|
41
42
|
pygenutils/time_handling/date_and_time_maths.py
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
more_itertools>=10.0.0
|
|
2
|
-
numpy
|
|
3
|
-
pandas
|
|
4
|
-
filewise>=3.
|
|
5
|
-
paramlib>=3.
|
|
2
|
+
numpy>=2.2.3
|
|
3
|
+
pandas>=2.2.3
|
|
4
|
+
filewise>=3.14.0
|
|
5
|
+
paramlib>=3.5.0
|
|
6
6
|
|
|
7
7
|
[arrow]
|
|
8
8
|
arrow>=1.2.0
|
|
9
9
|
|
|
10
|
+
[climate]
|
|
11
|
+
climarraykit>=0.2.1
|
|
12
|
+
|
|
10
13
|
[dev]
|
|
11
14
|
pytest>=7.0.0
|
|
12
15
|
pytest-cov>=4.0.0
|
|
@@ -14,6 +17,7 @@ black>=23.0.0
|
|
|
14
17
|
isort>=5.0.0
|
|
15
18
|
mypy>=1.0.0
|
|
16
19
|
flake8>=6.0.0
|
|
20
|
+
climarraykit>=0.2.1
|
|
17
21
|
|
|
18
22
|
[xarray]
|
|
19
23
|
xarray>=2024.2.0
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pygenutils"
|
|
7
|
-
version = "
|
|
7
|
+
version = "17.1.1"
|
|
8
8
|
license = {file = "LICENSE"}
|
|
9
9
|
description = "A comprehensive Python utility library for general-purpose and specialised tasks"
|
|
10
10
|
keywords = ["utilities", "python", "general-purpose", "file handling", "string processing"]
|
|
@@ -27,13 +27,16 @@ classifiers = [
|
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
29
|
"more_itertools>=10.0.0",
|
|
30
|
-
"numpy>=
|
|
31
|
-
"pandas>=
|
|
32
|
-
"filewise>=3.
|
|
33
|
-
"paramlib>=3.
|
|
30
|
+
"numpy>=2.2.3",
|
|
31
|
+
"pandas>=2.2.3",
|
|
32
|
+
"filewise>=3.14.0",
|
|
33
|
+
"paramlib>=3.5.0",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
[project.optional-dependencies]
|
|
37
|
+
climate = [
|
|
38
|
+
"climarraykit>=0.2.1",
|
|
39
|
+
]
|
|
37
40
|
xarray = ["xarray>=2024.2.0"]
|
|
38
41
|
arrow = ["arrow>=1.2.0"]
|
|
39
42
|
dev = [
|
|
@@ -43,6 +46,7 @@ dev = [
|
|
|
43
46
|
"isort>=5.0.0",
|
|
44
47
|
"mypy>=1.0.0",
|
|
45
48
|
"flake8>=6.0.0",
|
|
49
|
+
"climarraykit>=0.2.1",
|
|
46
50
|
]
|
|
47
51
|
|
|
48
52
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/audio_and_video/audio_and_video_manipulation.py
RENAMED
|
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
|
{pygenutils-16.3.2 → pygenutils-17.1.1}/pygenutils/time_handling/program_snippet_exec_timers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|