pygenutils 16.0.0__tar.gz → 16.1.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.
Files changed (47) hide show
  1. pygenutils-16.1.2/MANIFEST.in +7 -0
  2. {pygenutils-16.0.0 → pygenutils-16.1.2}/PKG-INFO +113 -5
  3. {pygenutils-16.0.0/pygenutils → pygenutils-16.1.2}/README.md +111 -3
  4. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/__init__.py +1 -1
  5. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/audio_and_video/audio_and_video_manipulation.py +3 -3
  6. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/audio_and_video/merge_audio_and_video.py +2 -2
  7. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/audio_and_video/merge_audio_or_video.py +6 -2
  8. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/audio_and_video/trim_media.py +13 -5
  9. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/date_and_time_maths.py +18 -13
  10. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/date_and_time_utils.py +2 -2
  11. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/time_utils.py +83 -20
  12. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils.egg-info/PKG-INFO +113 -5
  13. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils.egg-info/SOURCES.txt +2 -1
  14. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils.egg-info/requires.txt +1 -1
  15. {pygenutils-16.0.0 → pygenutils-16.1.2}/pyproject.toml +3 -3
  16. {pygenutils-16.0.0 → pygenutils-16.1.2}/setup.py +1 -1
  17. {pygenutils-16.0.0 → pygenutils-16.1.2}/LICENSE +0 -0
  18. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/arrays_and_lists/__init__.py +0 -0
  19. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/arrays_and_lists/conversions.py +0 -0
  20. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/arrays_and_lists/data_manipulation.py +0 -0
  21. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/arrays_and_lists/maths.py +0 -0
  22. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/arrays_and_lists/patterns.py +0 -0
  23. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/audio_and_video/__init__.py +0 -0
  24. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/dictionaries/__init__.py +0 -0
  25. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/dictionaries/dict_handler.py +0 -0
  26. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/dictionaries/dict_operators.py +0 -0
  27. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/number_bases/__init__.py +0 -0
  28. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/number_bases/base_converters.py +0 -0
  29. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/number_bases/binary_operations.py +0 -0
  30. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/number_bases/bitwise_operators.py +0 -0
  31. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/number_bases/mathematical_utils.py +0 -0
  32. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/operative_systems/__init__.py +0 -0
  33. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/operative_systems/os_operations.py +0 -0
  34. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/sets_and_intervals/__init__.py +0 -0
  35. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/sets_and_intervals/interval_handler.py +0 -0
  36. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/sets_and_intervals/sets_handler.py +0 -0
  37. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/strings/__init__.py +0 -0
  38. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/strings/string_handler.py +0 -0
  39. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/strings/text_formatters.py +0 -0
  40. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/__init__.py +0 -0
  41. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/calendar_utils.py +0 -0
  42. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/countdown.py +0 -0
  43. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/program_snippet_exec_timers.py +0 -0
  44. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils/time_handling/time_formatters.py +0 -0
  45. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils.egg-info/dependency_links.txt +0 -0
  46. {pygenutils-16.0.0 → pygenutils-16.1.2}/pygenutils.egg-info/top_level.txt +0 -0
  47. {pygenutils-16.0.0 → pygenutils-16.1.2}/setup.cfg +0 -0
@@ -0,0 +1,7 @@
1
+ exclude recipe/
2
+ exclude recipe/*
3
+ global-exclude *.pyc
4
+ global-exclude *.pyo
5
+ global-exclude __pycache__
6
+ global-exclude .git*
7
+ global-exclude .DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygenutils
3
- Version: 16.0.0
3
+ Version: 16.1.2
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
@@ -45,7 +45,7 @@ License-File: LICENSE
45
45
  Requires-Dist: more_itertools>=10.0.0
46
46
  Requires-Dist: numpy<2.0.0,>=1.21.0
47
47
  Requires-Dist: pandas<2.0.0,>=1.3.0
48
- Requires-Dist: filewise>=3.11.1
48
+ Requires-Dist: filewise>=3.11.0
49
49
  Requires-Dist: paramlib>=3.4.0
50
50
  Requires-Dist: arrow>=1.2.0
51
51
  Provides-Extra: xarray
@@ -61,7 +61,7 @@ Dynamic: license-file
61
61
 
62
62
  # pygenutils
63
63
 
64
- [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
64
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
65
65
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
66
66
  [![PyPI Version](https://img.shields.io/pypi/v/pygenutils.svg)](https://pypi.org/project/pygenutils/)
67
67
 
@@ -114,12 +114,14 @@ This package has minimal external dependencies and is designed to be lightweight
114
114
 
115
115
  ### Installation Instructions
116
116
 
117
- Install the package using pip:
117
+ **For regular users** who want to use the package in their projects:
118
118
 
119
119
  ```bash
120
120
  pip install pygenutils
121
121
  ```
122
122
 
123
+ This automatically installs `pygenutils` and all its dependencies with version constraints.
124
+
123
125
  ### Package Updates
124
126
 
125
127
  To stay up-to-date with the latest version of this package, simply run:
@@ -128,7 +130,113 @@ To stay up-to-date with the latest version of this package, simply run:
128
130
  pip install --upgrade pygenutils
129
131
  ```
130
132
 
131
- ## Project Structure
133
+ ## Development Setup
134
+
135
+ ### For Contributors and Developers
136
+
137
+ If you're planning to contribute to the project or work with the source code, follow these setup instructions:
138
+
139
+ #### Quick Setup (Recommended)
140
+
141
+ ```bash
142
+ # Clone the repository
143
+ git clone https://github.com/EusDancerDev/pygenutils.git
144
+ cd pygenutils
145
+
146
+ # Install with development dependencies (includes latest Git versions)
147
+ pip install -e .[dev]
148
+ ```
149
+
150
+ **Note**: The `-e` flag installs the package in "editable" mode, meaning changes to the source code are immediately reflected without reinstalling. The `[dev]` flag includes the latest Git versions of interdependent packages.
151
+
152
+ #### Alternative Setup (Explicit Git Dependencies)
153
+
154
+ If you prefer to use the explicit development requirements file:
155
+
156
+ ```bash
157
+ # Clone the repository
158
+ git clone https://github.com/EusDancerDev/pygenutils.git
159
+ cd pygenutils
160
+
161
+ # Install development dependencies from requirements-dev.txt
162
+ pip install -r requirements-dev.txt
163
+
164
+ # Install in editable mode
165
+ pip install -e .
166
+ ```
167
+
168
+ This approach gives you the latest development versions of all interdependent packages for testing and development.
169
+
170
+ #### Development with Optional Dependencies
171
+
172
+ For full development capabilities, including testing and linting:
173
+
174
+ ```bash
175
+ # Install with development dependencies
176
+ pip install -e ".[dev]"
177
+
178
+ # Or install specific optional dependencies
179
+ pip install -e ".[xarray]" # For xarray support
180
+ ```
181
+
182
+ ### For Multiple Package Development
183
+
184
+ If you're working on multiple interdependent packages simultaneously:
185
+
186
+ ```bash
187
+ # Clone all repositories
188
+ git clone https://github.com/EusDancerDev/pygenutils.git
189
+ git clone https://github.com/EusDancerDev/filewise.git
190
+ git clone https://github.com/EusDancerDev/paramlib.git
191
+
192
+ # Install each in editable mode
193
+ pip install -e ./filewise
194
+ pip install -e ./paramlib
195
+ pip install -e ./pygenutils
196
+ ```
197
+
198
+ ### Troubleshooting
199
+
200
+ If you encounter import errors after cloning:
201
+
202
+ 1. **For regular users**: Run `pip install pygenutils` (all dependencies included)
203
+ 2. **For developers**: Run `pip install -e .[dev]` to include development dependencies
204
+ 3. **Verify Python environment**: Make sure you're using a compatible Python version (3.10+)
205
+
206
+ ### Verify Installation
207
+
208
+ To verify that your installation is working correctly, you can run this quick test:
209
+
210
+ ```python
211
+ # Test script to verify installation
212
+ try:
213
+ import pygenutils
214
+ from filewise.general.introspection_utils import get_type_str
215
+ from paramlib.global_parameters import BASIC_ARITHMETIC_OPERATORS
216
+
217
+ print("✅ All imports successful!")
218
+ print(f"✅ pygenutils version: {pygenutils.__version__}")
219
+ print("✅ Installation is working correctly.")
220
+
221
+ except ImportError as e:
222
+ print(f"❌ Import error: {e}")
223
+ print("💡 For regular users: pip install pygenutils")
224
+ print("💡 For developers: pip install -e .[dev]")
225
+ ```
226
+
227
+ ### Implementation Notes
228
+
229
+ This project implements a **dual-approach dependency management** system:
230
+
231
+ - **Production Dependencies**: Version-constrained dependencies for PyPI compatibility
232
+ - **Development Dependencies**: Git-based dependencies for latest development versions
233
+ - **Installation Methods**:
234
+ - **Regular users**: Simple `pip install pygenutils` with all dependencies included
235
+ - **Developers**: `pip install -e .[dev]` for latest Git versions and development tools
236
+ - **PyPI Compatibility**: All packages can be published without Git dependency issues
237
+ - **Development Flexibility**: Contributors get access to latest versions for testing and development
238
+
239
+ ### Package Structure
132
240
 
133
241
  The package is organised into several specialised modules:
134
242
 
@@ -1,6 +1,6 @@
1
1
  # pygenutils
2
2
 
3
- [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
3
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
4
4
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
5
  [![PyPI Version](https://img.shields.io/pypi/v/pygenutils.svg)](https://pypi.org/project/pygenutils/)
6
6
 
@@ -53,12 +53,14 @@ This package has minimal external dependencies and is designed to be lightweight
53
53
 
54
54
  ### Installation Instructions
55
55
 
56
- Install the package using pip:
56
+ **For regular users** who want to use the package in their projects:
57
57
 
58
58
  ```bash
59
59
  pip install pygenutils
60
60
  ```
61
61
 
62
+ This automatically installs `pygenutils` and all its dependencies with version constraints.
63
+
62
64
  ### Package Updates
63
65
 
64
66
  To stay up-to-date with the latest version of this package, simply run:
@@ -67,7 +69,113 @@ To stay up-to-date with the latest version of this package, simply run:
67
69
  pip install --upgrade pygenutils
68
70
  ```
69
71
 
70
- ## Project Structure
72
+ ## Development Setup
73
+
74
+ ### For Contributors and Developers
75
+
76
+ If you're planning to contribute to the project or work with the source code, follow these setup instructions:
77
+
78
+ #### Quick Setup (Recommended)
79
+
80
+ ```bash
81
+ # Clone the repository
82
+ git clone https://github.com/EusDancerDev/pygenutils.git
83
+ cd pygenutils
84
+
85
+ # Install with development dependencies (includes latest Git versions)
86
+ pip install -e .[dev]
87
+ ```
88
+
89
+ **Note**: The `-e` flag installs the package in "editable" mode, meaning changes to the source code are immediately reflected without reinstalling. The `[dev]` flag includes the latest Git versions of interdependent packages.
90
+
91
+ #### Alternative Setup (Explicit Git Dependencies)
92
+
93
+ If you prefer to use the explicit development requirements file:
94
+
95
+ ```bash
96
+ # Clone the repository
97
+ git clone https://github.com/EusDancerDev/pygenutils.git
98
+ cd pygenutils
99
+
100
+ # Install development dependencies from requirements-dev.txt
101
+ pip install -r requirements-dev.txt
102
+
103
+ # Install in editable mode
104
+ pip install -e .
105
+ ```
106
+
107
+ This approach gives you the latest development versions of all interdependent packages for testing and development.
108
+
109
+ #### Development with Optional Dependencies
110
+
111
+ For full development capabilities, including testing and linting:
112
+
113
+ ```bash
114
+ # Install with development dependencies
115
+ pip install -e ".[dev]"
116
+
117
+ # Or install specific optional dependencies
118
+ pip install -e ".[xarray]" # For xarray support
119
+ ```
120
+
121
+ ### For Multiple Package Development
122
+
123
+ If you're working on multiple interdependent packages simultaneously:
124
+
125
+ ```bash
126
+ # Clone all repositories
127
+ git clone https://github.com/EusDancerDev/pygenutils.git
128
+ git clone https://github.com/EusDancerDev/filewise.git
129
+ git clone https://github.com/EusDancerDev/paramlib.git
130
+
131
+ # Install each in editable mode
132
+ pip install -e ./filewise
133
+ pip install -e ./paramlib
134
+ pip install -e ./pygenutils
135
+ ```
136
+
137
+ ### Troubleshooting
138
+
139
+ If you encounter import errors after cloning:
140
+
141
+ 1. **For regular users**: Run `pip install pygenutils` (all dependencies included)
142
+ 2. **For developers**: Run `pip install -e .[dev]` to include development dependencies
143
+ 3. **Verify Python environment**: Make sure you're using a compatible Python version (3.10+)
144
+
145
+ ### Verify Installation
146
+
147
+ To verify that your installation is working correctly, you can run this quick test:
148
+
149
+ ```python
150
+ # Test script to verify installation
151
+ try:
152
+ import pygenutils
153
+ from filewise.general.introspection_utils import get_type_str
154
+ from paramlib.global_parameters import BASIC_ARITHMETIC_OPERATORS
155
+
156
+ print("✅ All imports successful!")
157
+ print(f"✅ pygenutils version: {pygenutils.__version__}")
158
+ print("✅ Installation is working correctly.")
159
+
160
+ except ImportError as e:
161
+ print(f"❌ Import error: {e}")
162
+ print("💡 For regular users: pip install pygenutils")
163
+ print("💡 For developers: pip install -e .[dev]")
164
+ ```
165
+
166
+ ### Implementation Notes
167
+
168
+ This project implements a **dual-approach dependency management** system:
169
+
170
+ - **Production Dependencies**: Version-constrained dependencies for PyPI compatibility
171
+ - **Development Dependencies**: Git-based dependencies for latest development versions
172
+ - **Installation Methods**:
173
+ - **Regular users**: Simple `pip install pygenutils` with all dependencies included
174
+ - **Developers**: `pip install -e .[dev]` for latest Git versions and development tools
175
+ - **PyPI Compatibility**: All packages can be published without Git dependency issues
176
+ - **Development Flexibility**: Contributors get access to latest versions for testing and development
177
+
178
+ ### Package Structure
71
179
 
72
180
  The package is organised into several specialised modules:
73
181
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  # pygenutils/__init__.py
5
5
 
6
- __version__ = "16.0.0"
6
+ __version__ = "16.1.2"
7
7
 
8
8
  # Define what should be available when using 'from pygenutils import *'
9
9
  __all__ = [
@@ -631,10 +631,10 @@ def cut_media_files(media_inputs,
631
631
  A list of media file paths or a path to a text file containing file names.
632
632
  Can also be a nested list for recursive processing.
633
633
  start_time_list : str | list[str]
634
- The start time in the format '%H:%M:%S' or '%H:%M:%S.%f'.
634
+ The start time in the format '%T' or '%T.%f'.
635
635
  If any set to 'start', cutting starts from the beginning.
636
636
  end_time_list : str | list[str]
637
- The end time in the format '%H:%M:%S' or '%H:%M:%S.%f'.
637
+ The end time in the format '%T' or '%T.%f'.
638
638
  If any set to 'end', cutting proceeds until the end of the file.
639
639
  output_file_list : list[str] | None, optional
640
640
  A list of output file names. If not provided, default names will be generated.
@@ -871,7 +871,7 @@ def cut_media_files(media_inputs,
871
871
  #-------------------#
872
872
 
873
873
  # Time format strings #
874
- TIME_FMT_STR_LIST = ['%H:%M:%S', '%H:%M:%S.%f']
874
+ TIME_FMT_STR_LIST = ['%T', '%T.%f']
875
875
 
876
876
  # Common audio and video formats #
877
877
  COMMON_AUDIO_FORMATS = ('.mp3', '.aac', '.wav')
@@ -35,7 +35,7 @@ VIDEO_EXTENSION = "mp4"
35
35
  VIDEO_FILE_PATTERN = f"_{VIDEO_DELIMITER}.{VIDEO_EXTENSION}"
36
36
 
37
37
  # Path to walk into for file searching #
38
- SEARCH_PATH = "../Curso_superior_ML/"
38
+ SEARCH_PATH = "(default_search_path)"
39
39
 
40
40
  # Input media #
41
41
  #-------------#
@@ -73,7 +73,7 @@ AUDIO_BITRATE_FRACTION = 4
73
73
  VIDEO_BITRATE_FRACTION = 4
74
74
 
75
75
  # Codec settings #
76
- #-----------------#
76
+ #----------------#
77
77
 
78
78
  # Video codec to use (None = no re-encoding, "copy" = stream copy, "libx264" = H.264, etc.)
79
79
  VIDEO_CODEC = None
@@ -29,7 +29,11 @@ OUTPUT_EXT = "mp4"
29
29
  #-------------#
30
30
 
31
31
  # Media input can be a list of files or a single file containing file names
32
- MEDIA_INPUT = []
32
+ MEDIA_INPUT = [
33
+ "media_file_name_1.mp3",
34
+ "media_file_name_2.mp4",
35
+ "media_file_name_3.mp3"
36
+ ]
33
37
  # MEDIA_INPUT = "media_name_containing_file.txt"
34
38
 
35
39
  # Output media #
@@ -51,7 +55,7 @@ AUDIO_BITRATE_FRACTION = 4
51
55
  VIDEO_BITRATE_FRACTION = 4
52
56
 
53
57
  # Codec settings #
54
- #-----------------#
58
+ #----------------#
55
59
 
56
60
  # Video codec to use (None = no re-encoding, "copy" = stream copy, "libx264" = H.264, etc.)
57
61
  VIDEO_CODEC = None
@@ -24,14 +24,22 @@ from pygenutils.audio_and_video.audio_and_video_manipulation import cut_media_fi
24
24
  #-------------#
25
25
 
26
26
  # Media input can be a list of files or a single file containing file names
27
- MEDIA_INPUT = []
27
+ MEDIA_INPUT = [
28
+ "media_file_name_1.mp3",
29
+ "media_file_name_2.mp4",
30
+ "media_file_name_3.mp3"
31
+ ]
28
32
  # MEDIA_INPUT = "media_name_containing_file.txt"
29
-
33
+
30
34
  # Output media #
31
35
  #--------------#
32
36
 
33
37
  # Merged media file #
34
- OUTPUT_FILE_LIST = []
38
+ OUTPUT_FILE_LIST = [
39
+ "media_file_name_1_trimmed.mp3",
40
+ "media_file_name_2_trimmed.mp4",
41
+ "media_file_name_3_trimmed.mp3"
42
+ ]
35
43
  # OUTPUT_FILE_LIST = None
36
44
 
37
45
  # Starting and ending times #
@@ -39,7 +47,7 @@ START_TIME_LIST = ["start", "00:01:28", "00:02:28.345"]
39
47
  END_TIME_LIST = ["00:05:21", "end", "00:07:56.851"]
40
48
 
41
49
  # Zero-padding and bitrate fractions #
42
- #-------------------------------------#
50
+ #------------------------------------#
43
51
 
44
52
  ZERO_PADDING = 1
45
53
 
@@ -52,7 +60,7 @@ AUDIO_BITRATE_FRACTION = 4
52
60
  VIDEO_BITRATE_FRACTION = 4
53
61
 
54
62
  # Codec settings #
55
- #-----------------#
63
+ #----------------#
56
64
 
57
65
  # Video codec to use (None = no re-encoding, "copy" = stream copy, "libx264" = H.264, etc.)
58
66
  VIDEO_CODEC = None
@@ -84,9 +84,9 @@ def _validate_option(arg_iterable, error_class, error_str):
84
84
 
85
85
  # Main method #
86
86
  def sum_dt_objects(dt_obj_list,
87
- dt_fmt_str="%H:%M:%S",
88
- operation="sum",
89
- output_format="standard"):
87
+ dt_fmt_str="%T",
88
+ operation="sum",
89
+ output_format="standard"):
90
90
  """
91
91
  Calculate the sum or difference of a list of clock times
92
92
  and format the output accordingly.
@@ -101,7 +101,7 @@ def sum_dt_objects(dt_obj_list,
101
101
  are "sum" (default) and "subtr" for subtraction.
102
102
  dt_fmt_str : str, optional
103
103
  A format string that defines the structure of each object in 'dt_obj_list'.
104
- Default is '%H:%M:%S'.
104
+ Default is '%T'.
105
105
  output_format : str, optional
106
106
  The format of the output. Supported options:
107
107
  - 'standard': Returns the total time as a pandas.Timedelta object (default).
@@ -214,8 +214,8 @@ def extract_dt_part(datetime_obj, part="time", arg_list=None):
214
214
  ###############
215
215
 
216
216
  def dt_average(dt_obj_list,
217
- time_fmt_str="%H:%M:%S",
218
- output_format="standard"):
217
+ time_fmt_str="%T",
218
+ output_format="standard"):
219
219
  """
220
220
  Calculate the average time from a list of time objects
221
221
  and format the output accordingly.
@@ -227,7 +227,7 @@ def dt_average(dt_obj_list,
227
227
  the format specified in 'time_fmt_str'.
228
228
  time_fmt_str : str, optional
229
229
  The format string that specifies the format of the time objects.
230
- This only affects objects that are strings. Default is "%H:%M:%S".
230
+ This only affects objects that are strings. Default is "%T".
231
231
  Note that all strings must have at least the detectable part
232
232
  specified by the given format string.
233
233
  output_format : str, optional
@@ -273,7 +273,7 @@ def dt_average(dt_obj_list,
273
273
  # Operations #
274
274
  ##############
275
275
 
276
- angles = [_dt_to_radians(dt_obj) for dt_obj in dt_obj_list]
276
+ angles = [_dt_to_radians(dt_obj, "datetime", time_fmt_str) for dt_obj in dt_obj_list]
277
277
  avg_angle = _average_angle(angles)
278
278
  time_average = _radians_to_time_of_day(avg_angle)
279
279
 
@@ -403,7 +403,10 @@ def _radians_to_time_of_day(rads):
403
403
  # Sum and subtract operations #
404
404
  #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
405
405
 
406
- def sum_date_objects(date_list, operation="sum", dt_fmt_str="%Y-%m-%d", output_format="default"):
406
+ def sum_date_objects(date_list,
407
+ operation="sum",
408
+ dt_fmt_str="%F",
409
+ output_format="default"):
407
410
  """
408
411
  Calculate the sum or difference of a list of dates
409
412
  and format the output accordingly.
@@ -418,7 +421,7 @@ def sum_date_objects(date_list, operation="sum", dt_fmt_str="%Y-%m-%d", output_f
418
421
  are "sum" (default) and "subtr" for subtraction.
419
422
  dt_fmt_str : str, optional
420
423
  A format string that defines the structure of each object in 'date_list'.
421
- Default is '%Y-%m-%d'.
424
+ Default is '%F'.
422
425
  output_format : str, optional
423
426
  The format of the output. Supported options:
424
427
  - 'default': Returns the total date as a datetime.date object (default).
@@ -598,7 +601,9 @@ def natural_year(dt_start, dt_end, dt_fmt_str=None,
598
601
  dt_fmt_str : str, optional
599
602
  The format string for parsing dates if dt_start or dt_end are strings.
600
603
  method : str, optional
601
- The method for converting the date objects, default is "pandas".
604
+ The method for converting the date objects. Supported values are:
605
+ "datetime", "timestamp", "datetime64", "arrow", "str".
606
+ Default is "datetime".
602
607
  output_format : str, optional
603
608
  The format of the output. Supported options are "default", "string", and "tuple".
604
609
  "default" returns datetime objects, "string" returns formatted date strings, and
@@ -642,8 +647,8 @@ def natural_year(dt_start, dt_end, dt_fmt_str=None,
642
647
  # Convert input objects to datetime objects #
643
648
  #############################################
644
649
 
645
- dt_start_std = datetime_obj_converter(dt_start, "datetime", dt_fmt_str=dt_fmt_str)
646
- dt_end_std = datetime_obj_converter(dt_end, "datetime", dt_fmt_str=dt_fmt_str)
650
+ dt_start_std = datetime_obj_converter(dt_start, method, dt_fmt_str=dt_fmt_str)
651
+ dt_end_std = datetime_obj_converter(dt_end, method, dt_fmt_str=dt_fmt_str)
647
652
 
648
653
  # Check if there is at least a whole year gap between the two objects #
649
654
  #######################################################################
@@ -595,7 +595,7 @@ def infer_dt_range(data):
595
595
 
596
596
  def get_obj_operation_datetime(obj_list,
597
597
  attr="modification",
598
- time_fmt_str="%Y-%m-%d %H:%M:%S",
598
+ time_fmt_str="%F %T",
599
599
  want_numpy_array=True):
600
600
  """
601
601
  Returns a 2D numpy array where each row contains an object (file path)
@@ -610,7 +610,7 @@ def get_obj_operation_datetime(obj_list,
610
610
  Type of time attribute to retrieve. Defaults to 'modification'.
611
611
  time_fmt_str : str, optional
612
612
  Format string for formatting the time attribute using .strftime().
613
- Defaults to '%Y-%m-%d %H:%M:%S'.
613
+ Defaults to '%F %T'.
614
614
  want_numpy_array : bool
615
615
  Determines whether to convert the final object to a 2D Numpy array.
616
616
  If True, a 2D Numpy array is returned, else a list composed of lists.
@@ -116,14 +116,25 @@ def _convert_floated_time_to_datetime(floated_time, module):
116
116
  seconds = int(floated_time)
117
117
  nanoseconds = int((floated_time - seconds) * 1_000_000_000)
118
118
 
119
- # Convert the seconds part into a datetime object
120
- dt = datetime.fromtimestamp(seconds)
119
+ # Convert the seconds part into a datetime object using the specified module
120
+ if module == "datetime":
121
+ dt = datetime.fromtimestamp(seconds)
122
+ elif module == "pandas":
123
+ dt = pd.Timestamp.fromtimestamp(seconds).to_pydatetime()
124
+ elif module == "numpy":
125
+ dt = pd.Timestamp.fromtimestamp(seconds).to_pydatetime() # Convert via pandas for compatibility
126
+ elif module == "arrow":
127
+ dt = arrow.get(seconds).datetime
128
+ elif module == "time":
129
+ dt = datetime.fromtimestamp(seconds) # time module uses same as datetime
130
+ else:
131
+ raise ValueError(f"Unsupported module: {module}")
121
132
 
122
133
  # Add the nanoseconds part and return the formatted string
123
134
  dt_with_nanos = dt + timedelta(microseconds=nanoseconds / 1_000)
124
135
  dt_with_nanos_str = datetime_obj_converter(dt_with_nanos,
125
- convert_to="str",
126
- dt_fmt_str='%Y-%m-%dT%H:%M:%S')
136
+ convert_to="str",
137
+ dt_fmt_str='%FT%T')
127
138
  nano_dt_str = f"{dt_with_nanos_str}.{nanoseconds:09d}"
128
139
  return nano_dt_str
129
140
 
@@ -149,11 +160,11 @@ def _nano_floated_time_str(time_ns):
149
160
  return f"{seconds}.{nanoseconds:09d}"
150
161
 
151
162
  def datetime_obj_converter(datetime_obj,
152
- convert_to,
153
- unit="s",
154
- float_class="d",
155
- int_class="int",
156
- dt_fmt_str=None):
163
+ convert_to,
164
+ unit="s",
165
+ float_class="d",
166
+ int_class="int",
167
+ dt_fmt_str=None):
157
168
  """
158
169
  Convert a date/time object to another, including float and string representation.
159
170
  If float, it represents seconds since the Unix epoch.
@@ -172,18 +183,22 @@ def datetime_obj_converter(datetime_obj,
172
183
 
173
184
  convert_to : str
174
185
  The target type to convert `datetime_obj` to.
175
- Accepted values depend on the input type.
186
+ Supported values: "datetime", "timestamp", "datetime64", "arrow", "str", "float", "int".
176
187
  For example, if `datetime_obj` is a `datetime`, `convert_to` could be
177
- `datetime64`, `Timestamp`, etc.
188
+ "datetime64", "timestamp", "float", etc.
178
189
  unit : str
179
- The date unit for conversion, applicable to certain types.
190
+ The date unit for conversion, used with numpy datetime64 and pandas Timestamp conversions.
180
191
  Default is `"s"` (seconds).
181
192
  float_class : str | np.floating
182
- The float precision class. Default is `"d"` (double precision).
193
+ The float precision class used when `convert_to="float"`.
194
+ Supported values: "d"/"float" (double), "f" (float32), numpy float types.
195
+ Default is `"d"` (double precision).
183
196
  int_class : str | np.integer
184
- The integer precision class. Default is `"int"` (signed integer type).
197
+ The integer precision class used when `convert_to="int"`.
198
+ Supported values: "int" (Python int), "i" (int32), numpy integer types.
199
+ Default is `"int"` (Python integer type).
185
200
  dt_fmt_str : str
186
- Format string to convert the date/time object to a string.
201
+ Format string to convert the date/time object to a string when `convert_to="str"`.
187
202
 
188
203
  Returns
189
204
  -------
@@ -228,7 +243,7 @@ def datetime_obj_converter(datetime_obj,
228
243
  if isinstance(datetime_obj, datetime):
229
244
  return pd.Timestamp(datetime_obj)
230
245
  if isinstance(datetime_obj, np.datetime64):
231
- return pd.Timestamp(datetime_obj)
246
+ return pd.Timestamp(datetime_obj, unit=unit)
232
247
  if isinstance(datetime_obj, arrow.Arrow):
233
248
  return pd.Timestamp(datetime_obj.datetime)
234
249
  raise ValueError(f"Cannot convert {obj_type} to Timestamp")
@@ -236,11 +251,11 @@ def datetime_obj_converter(datetime_obj,
236
251
  # Convert to numpy datetime64 if requested
237
252
  if convert_to == "datetime64":
238
253
  if isinstance(datetime_obj, np.datetime64):
239
- return datetime_obj
254
+ return datetime_obj.astype(f'datetime64[{unit}]')
240
255
  if isinstance(datetime_obj, (datetime, pd.Timestamp)):
241
- return np.datetime64(datetime_obj)
256
+ return np.datetime64(datetime_obj, unit)
242
257
  if isinstance(datetime_obj, arrow.Arrow):
243
- return np.datetime64(datetime_obj.datetime)
258
+ return np.datetime64(datetime_obj.datetime, unit)
244
259
  raise ValueError(f"Cannot convert {obj_type} to datetime64")
245
260
 
246
261
  # Convert to arrow if requested
@@ -255,4 +270,52 @@ def datetime_obj_converter(datetime_obj,
255
270
  return arrow.get(pd.Timestamp(datetime_obj).to_pydatetime())
256
271
  raise ValueError(f"Cannot convert {obj_type} to arrow")
257
272
 
258
- raise ValueError(f"Unsupported conversion target: {convert_to}")
273
+ # Convert to float if requested
274
+ if convert_to == "float":
275
+ if hasattr(datetime_obj, 'timestamp'):
276
+ # For datetime and pandas objects
277
+ timestamp = datetime_obj.timestamp()
278
+ elif isinstance(datetime_obj, np.datetime64):
279
+ # For numpy datetime64 objects
280
+ timestamp = datetime_obj.astype(f'datetime64[{unit}]').astype(float_class)
281
+ return timestamp
282
+ elif isinstance(datetime_obj, arrow.Arrow):
283
+ timestamp = datetime_obj.float_timestamp
284
+ else:
285
+ raise ValueError(f"Cannot convert {obj_type} to float")
286
+
287
+ # Apply float precision class
288
+ if float_class == "d" or float_class == "float":
289
+ return float(timestamp)
290
+ elif float_class == "f":
291
+ return np.float32(timestamp)
292
+ elif isinstance(float_class, type) and issubclass(float_class, np.floating):
293
+ return float_class(timestamp)
294
+ else:
295
+ return np.dtype(float_class).type(timestamp)
296
+
297
+ # Convert to int if requested
298
+ if convert_to == "int":
299
+ if hasattr(datetime_obj, 'timestamp'):
300
+ # For datetime and pandas objects
301
+ timestamp = int(datetime_obj.timestamp())
302
+ elif isinstance(datetime_obj, np.datetime64):
303
+ # For numpy datetime64 objects
304
+ timestamp = datetime_obj.astype(f'datetime64[{unit}]').astype(int_class)
305
+ return timestamp
306
+ elif isinstance(datetime_obj, arrow.Arrow):
307
+ timestamp = int(datetime_obj.float_timestamp)
308
+ else:
309
+ raise ValueError(f"Cannot convert {obj_type} to int")
310
+
311
+ # Apply int precision class
312
+ if int_class == "int":
313
+ return int(timestamp)
314
+ elif int_class == "i":
315
+ return np.int32(timestamp)
316
+ elif isinstance(int_class, type) and issubclass(int_class, np.integer):
317
+ return int_class(timestamp)
318
+ else:
319
+ return np.dtype(int_class).type(timestamp)
320
+
321
+ raise ValueError(f"Unsupported conversion target: {convert_to}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygenutils
3
- Version: 16.0.0
3
+ Version: 16.1.2
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
@@ -45,7 +45,7 @@ License-File: LICENSE
45
45
  Requires-Dist: more_itertools>=10.0.0
46
46
  Requires-Dist: numpy<2.0.0,>=1.21.0
47
47
  Requires-Dist: pandas<2.0.0,>=1.3.0
48
- Requires-Dist: filewise>=3.11.1
48
+ Requires-Dist: filewise>=3.11.0
49
49
  Requires-Dist: paramlib>=3.4.0
50
50
  Requires-Dist: arrow>=1.2.0
51
51
  Provides-Extra: xarray
@@ -61,7 +61,7 @@ Dynamic: license-file
61
61
 
62
62
  # pygenutils
63
63
 
64
- [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
64
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
65
65
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
66
66
  [![PyPI Version](https://img.shields.io/pypi/v/pygenutils.svg)](https://pypi.org/project/pygenutils/)
67
67
 
@@ -114,12 +114,14 @@ This package has minimal external dependencies and is designed to be lightweight
114
114
 
115
115
  ### Installation Instructions
116
116
 
117
- Install the package using pip:
117
+ **For regular users** who want to use the package in their projects:
118
118
 
119
119
  ```bash
120
120
  pip install pygenutils
121
121
  ```
122
122
 
123
+ This automatically installs `pygenutils` and all its dependencies with version constraints.
124
+
123
125
  ### Package Updates
124
126
 
125
127
  To stay up-to-date with the latest version of this package, simply run:
@@ -128,7 +130,113 @@ To stay up-to-date with the latest version of this package, simply run:
128
130
  pip install --upgrade pygenutils
129
131
  ```
130
132
 
131
- ## Project Structure
133
+ ## Development Setup
134
+
135
+ ### For Contributors and Developers
136
+
137
+ If you're planning to contribute to the project or work with the source code, follow these setup instructions:
138
+
139
+ #### Quick Setup (Recommended)
140
+
141
+ ```bash
142
+ # Clone the repository
143
+ git clone https://github.com/EusDancerDev/pygenutils.git
144
+ cd pygenutils
145
+
146
+ # Install with development dependencies (includes latest Git versions)
147
+ pip install -e .[dev]
148
+ ```
149
+
150
+ **Note**: The `-e` flag installs the package in "editable" mode, meaning changes to the source code are immediately reflected without reinstalling. The `[dev]` flag includes the latest Git versions of interdependent packages.
151
+
152
+ #### Alternative Setup (Explicit Git Dependencies)
153
+
154
+ If you prefer to use the explicit development requirements file:
155
+
156
+ ```bash
157
+ # Clone the repository
158
+ git clone https://github.com/EusDancerDev/pygenutils.git
159
+ cd pygenutils
160
+
161
+ # Install development dependencies from requirements-dev.txt
162
+ pip install -r requirements-dev.txt
163
+
164
+ # Install in editable mode
165
+ pip install -e .
166
+ ```
167
+
168
+ This approach gives you the latest development versions of all interdependent packages for testing and development.
169
+
170
+ #### Development with Optional Dependencies
171
+
172
+ For full development capabilities, including testing and linting:
173
+
174
+ ```bash
175
+ # Install with development dependencies
176
+ pip install -e ".[dev]"
177
+
178
+ # Or install specific optional dependencies
179
+ pip install -e ".[xarray]" # For xarray support
180
+ ```
181
+
182
+ ### For Multiple Package Development
183
+
184
+ If you're working on multiple interdependent packages simultaneously:
185
+
186
+ ```bash
187
+ # Clone all repositories
188
+ git clone https://github.com/EusDancerDev/pygenutils.git
189
+ git clone https://github.com/EusDancerDev/filewise.git
190
+ git clone https://github.com/EusDancerDev/paramlib.git
191
+
192
+ # Install each in editable mode
193
+ pip install -e ./filewise
194
+ pip install -e ./paramlib
195
+ pip install -e ./pygenutils
196
+ ```
197
+
198
+ ### Troubleshooting
199
+
200
+ If you encounter import errors after cloning:
201
+
202
+ 1. **For regular users**: Run `pip install pygenutils` (all dependencies included)
203
+ 2. **For developers**: Run `pip install -e .[dev]` to include development dependencies
204
+ 3. **Verify Python environment**: Make sure you're using a compatible Python version (3.10+)
205
+
206
+ ### Verify Installation
207
+
208
+ To verify that your installation is working correctly, you can run this quick test:
209
+
210
+ ```python
211
+ # Test script to verify installation
212
+ try:
213
+ import pygenutils
214
+ from filewise.general.introspection_utils import get_type_str
215
+ from paramlib.global_parameters import BASIC_ARITHMETIC_OPERATORS
216
+
217
+ print("✅ All imports successful!")
218
+ print(f"✅ pygenutils version: {pygenutils.__version__}")
219
+ print("✅ Installation is working correctly.")
220
+
221
+ except ImportError as e:
222
+ print(f"❌ Import error: {e}")
223
+ print("💡 For regular users: pip install pygenutils")
224
+ print("💡 For developers: pip install -e .[dev]")
225
+ ```
226
+
227
+ ### Implementation Notes
228
+
229
+ This project implements a **dual-approach dependency management** system:
230
+
231
+ - **Production Dependencies**: Version-constrained dependencies for PyPI compatibility
232
+ - **Development Dependencies**: Git-based dependencies for latest development versions
233
+ - **Installation Methods**:
234
+ - **Regular users**: Simple `pip install pygenutils` with all dependencies included
235
+ - **Developers**: `pip install -e .[dev]` for latest Git versions and development tools
236
+ - **PyPI Compatibility**: All packages can be published without Git dependency issues
237
+ - **Development Flexibility**: Contributors get access to latest versions for testing and development
238
+
239
+ ### Package Structure
132
240
 
133
241
  The package is organised into several specialised modules:
134
242
 
@@ -1,7 +1,8 @@
1
1
  LICENSE
2
+ MANIFEST.in
3
+ README.md
2
4
  pyproject.toml
3
5
  setup.py
4
- pygenutils/README.md
5
6
  pygenutils/__init__.py
6
7
  pygenutils.egg-info/PKG-INFO
7
8
  pygenutils.egg-info/SOURCES.txt
@@ -1,7 +1,7 @@
1
1
  more_itertools>=10.0.0
2
2
  numpy<2.0.0,>=1.21.0
3
3
  pandas<2.0.0,>=1.3.0
4
- filewise>=3.11.1
4
+ filewise>=3.11.0
5
5
  paramlib>=3.4.0
6
6
  arrow>=1.2.0
7
7
 
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pygenutils"
7
- version = "16.0.0"
7
+ version = "16.1.2"
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"]
11
- readme = {file = "pygenutils/README.md", content-type = "text/markdown"}
11
+ readme = {file = "README.md", content-type = "text/markdown"}
12
12
  requires-python = ">=3.10"
13
13
  authors = [
14
14
  {name = "Jon Ander Gabantxo", email = "jagabantxo@gmail.com"}
@@ -29,7 +29,7 @@ dependencies = [
29
29
  "more_itertools>=10.0.0",
30
30
  "numpy>=1.21.0,<2.0.0",
31
31
  "pandas>=1.3.0,<2.0.0",
32
- "filewise>=3.11.1",
32
+ "filewise>=3.11.0",
33
33
  "paramlib>=3.4.0",
34
34
  "arrow>=1.2.0",
35
35
  ]
@@ -4,7 +4,7 @@
4
4
  from datetime import datetime as dt
5
5
 
6
6
  # Generate creation date
7
- CREATION_DATE = dt.now().strftime("%Y-%m-%d %H:%M:%S")
7
+ CREATION_DATE = dt.now().strftime("%F %T")
8
8
 
9
9
  """
10
10
  **Note**
File without changes
File without changes