stouputils 1.3.17__tar.gz → 1.3.19__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 (107) hide show
  1. {stouputils-1.3.17 → stouputils-1.3.19}/PKG-INFO +1 -1
  2. {stouputils-1.3.17 → stouputils-1.3.19}/pyproject.toml +1 -1
  3. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/backup.py +17 -11
  4. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/parallel.py +5 -5
  5. {stouputils-1.3.17 → stouputils-1.3.19}/.gitignore +0 -0
  6. {stouputils-1.3.17 → stouputils-1.3.19}/LICENSE +0 -0
  7. {stouputils-1.3.17 → stouputils-1.3.19}/README.md +0 -0
  8. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/__init__.py +0 -0
  9. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/all_doctests.py +0 -0
  10. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/applications/__init__.py +0 -0
  11. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/applications/automatic_docs.py +0 -0
  12. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/applications/upscaler/__init__.py +0 -0
  13. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/applications/upscaler/config.py +0 -0
  14. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/applications/upscaler/image.py +0 -0
  15. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/applications/upscaler/video.py +0 -0
  16. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/archive.py +0 -0
  17. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/collections.py +0 -0
  18. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/continuous_delivery/__init__.py +0 -0
  19. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/continuous_delivery/cd_utils.py +0 -0
  20. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/continuous_delivery/github.py +0 -0
  21. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/continuous_delivery/pypi.py +0 -0
  22. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/continuous_delivery/pyproject.py +0 -0
  23. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/ctx.py +0 -0
  24. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/config/get.py +0 -0
  25. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/config/set.py +0 -0
  26. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/__init__.py +0 -0
  27. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
  28. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
  29. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
  30. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
  31. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/blur.py +0 -0
  32. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/brightness.py +0 -0
  33. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/canny.py +0 -0
  34. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/clahe.py +0 -0
  35. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/common.py +0 -0
  36. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/contrast.py +0 -0
  37. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
  38. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/denoise.py +0 -0
  39. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
  40. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/invert.py +0 -0
  41. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
  42. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
  43. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/noise.py +0 -0
  44. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/normalize.py +0 -0
  45. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
  46. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/resize.py +0 -0
  47. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/rotation.py +0 -0
  48. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
  49. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
  50. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/shearing.py +0 -0
  51. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/threshold.py +0 -0
  52. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/translation.py +0 -0
  53. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image/zoom.py +0 -0
  54. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
  55. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
  56. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
  57. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/data_processing/technique.py +0 -0
  58. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/dataset/__init__.py +0 -0
  59. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/dataset/dataset.py +0 -0
  60. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/dataset/dataset_loader.py +0 -0
  61. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
  62. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/dataset/image_loader.py +0 -0
  63. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/dataset/xy_tuple.py +0 -0
  64. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/metric_dictionnary.py +0 -0
  65. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/metric_utils.py +0 -0
  66. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/mlflow_utils.py +0 -0
  67. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/abstract_model.py +0 -0
  68. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/all.py +0 -0
  69. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/base_keras.py +0 -0
  70. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/all.py +0 -0
  71. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/convnext.py +0 -0
  72. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/densenet.py +0 -0
  73. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/efficientnet.py +0 -0
  74. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/mobilenet.py +0 -0
  75. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/resnet.py +0 -0
  76. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/squeezenet.py +0 -0
  77. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/vgg.py +0 -0
  78. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras/xception.py +0 -0
  79. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
  80. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
  81. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
  82. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
  83. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
  84. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
  85. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
  86. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
  87. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
  88. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/model_interface.py +0 -0
  89. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/models/sandbox.py +0 -0
  90. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/range_tuple.py +0 -0
  91. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/scripts/augment_dataset.py +0 -0
  92. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
  93. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
  94. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/scripts/routine.py +0 -0
  95. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/data_science/utils.py +0 -0
  96. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/decorators.py +0 -0
  97. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/dont_look/zip_file_override.py +0 -0
  98. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/image.py +0 -0
  99. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/installer/__init__.py +0 -0
  100. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/installer/common.py +0 -0
  101. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/installer/downloader.py +0 -0
  102. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/installer/linux.py +0 -0
  103. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/installer/main.py +0 -0
  104. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/installer/windows.py +0 -0
  105. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/io.py +0 -0
  106. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/print.py +0 -0
  107. {stouputils-1.3.17 → stouputils-1.3.19}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.3.17
3
+ Version: 1.3.19
4
4
  Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
5
5
  Project-URL: Homepage, https://github.com/Stoupy51/stouputils
6
6
  Project-URL: Issues, https://github.com/Stoupy51/stouputils/issues
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
 
6
6
  [project]
7
7
  name = "stouputils"
8
- version = "1.3.17"
8
+ version = "1.3.19"
9
9
  description = "Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more."
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.10"
@@ -15,13 +15,19 @@ import datetime
15
15
  import fnmatch
16
16
  import hashlib
17
17
  import os
18
+ import shutil
18
19
  import zipfile
19
20
 
20
21
  # Local imports
21
22
  from .decorators import handle_error, measure_time
22
23
  from .io import clean_path
24
+ from .parallel import colored_for_loop
23
25
  from .print import info, progress, warning
24
26
 
27
+ # Constants
28
+ CHUNK_SIZE = 1048576 # 1MB chunks for I/O operations
29
+ LARGE_CHUNK_SIZE = 8388608 # 8MB chunks for large file operations
30
+
25
31
 
26
32
  # Function to compute the SHA-256 hash of a file
27
33
  def get_file_hash(file_path: str) -> str | None:
@@ -37,7 +43,7 @@ def get_file_hash(file_path: str) -> str | None:
37
43
  with open(file_path, "rb") as f:
38
44
  # Use larger chunks for better I/O performance
39
45
  while True:
40
- chunk = f.read(65536) # 64KB chunks
46
+ chunk = f.read(CHUNK_SIZE)
41
47
  if not chunk:
42
48
  break
43
49
  sha256_hash.update(chunk)
@@ -183,7 +189,7 @@ def create_delta_backup(source_path: str, destination_folder: str, exclude_patte
183
189
  with open(full_path, "rb") as f:
184
190
  with zipf.open(zip_info, "w", force_zip64=True) as zf:
185
191
  while True:
186
- chunk = f.read(65536) # 64KB chunks for better performance
192
+ chunk = f.read(CHUNK_SIZE)
187
193
  if not chunk:
188
194
  break
189
195
  zf.write(chunk)
@@ -207,7 +213,7 @@ def create_delta_backup(source_path: str, destination_folder: str, exclude_patte
207
213
  with open(source_path, "rb") as f:
208
214
  with zipf.open(zip_info, "w", force_zip64=True) as zf:
209
215
  while True:
210
- chunk = f.read(65536) # 64KB chunks for better performance
216
+ chunk = f.read(CHUNK_SIZE)
211
217
  if not chunk:
212
218
  break
213
219
  zf.write(chunk)
@@ -288,7 +294,7 @@ def consolidate_backups(zip_path: str, destination_zip: str) -> None:
288
294
 
289
295
  try:
290
296
  with zipfile.ZipFile(destination_zip, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zipf_out:
291
- for filename, (backup_path, inf) in file_registry.items():
297
+ for filename, (backup_path, inf) in colored_for_loop(file_registry.items(), desc="Making consolidated backup"):
292
298
  try:
293
299
  # Open ZIP file if not already open
294
300
  if backup_path not in open_zips:
@@ -296,15 +302,15 @@ def consolidate_backups(zip_path: str, destination_zip: str) -> None:
296
302
 
297
303
  zipf_in = open_zips[backup_path]
298
304
 
299
- # Copy file with larger chunks for better performance
305
+ # Copy file with optimized strategy based on file size
300
306
  with zipf_in.open(inf, "r") as source:
301
307
  with zipf_out.open(inf, "w", force_zip64=True) as target:
302
- # Use larger chunk size (64KB) for better I/O performance
303
- while True:
304
- chunk = source.read(65536)
305
- if not chunk:
306
- break
307
- target.write(chunk)
308
+ # Use shutil.copyfileobj with larger chunks for files >50MB
309
+ if inf.file_size > 52428800: # 50MB threshold
310
+ shutil.copyfileobj(source, target, length=LARGE_CHUNK_SIZE)
311
+ else:
312
+ # Use shutil.copyfileobj with standard chunks for smaller files
313
+ shutil.copyfileobj(source, target, length=CHUNK_SIZE)
308
314
  except Exception as e:
309
315
  warning(f"Error copying file {filename} from {backup_path}: {e}")
310
316
  continue
@@ -11,9 +11,9 @@ I highly encourage you to read the function docstrings to understand when to use
11
11
  """
12
12
 
13
13
  # Imports
14
- import time
15
14
  import multiprocessing as mp
16
- from collections.abc import Callable, Iterator
15
+ import time
16
+ from collections.abc import Callable, Iterable, Iterator
17
17
  from concurrent.futures import ThreadPoolExecutor
18
18
  from multiprocessing import Pool, cpu_count
19
19
  from typing import Any, TypeVar
@@ -179,7 +179,7 @@ def multiprocessing(
179
179
  old_method: str | None = mp.get_start_method(allow_none=True)
180
180
  new_method: str = "spawn" if old_method in (None, "fork") else "fork"
181
181
  mp.set_start_method(new_method, force=True)
182
-
182
+
183
183
  try:
184
184
  return process()
185
185
  finally:
@@ -278,7 +278,7 @@ def multithreading(
278
278
 
279
279
 
280
280
  def colored_for_loop(
281
- iterable: list[T],
281
+ iterable: Iterable[T],
282
282
  desc: str = "Processing",
283
283
  color: str = MAGENTA,
284
284
  bar_format: str = BAR_FORMAT,
@@ -288,7 +288,7 @@ def colored_for_loop(
288
288
  """ Function to iterate over a list with a colored TQDM progress bar like the other functions in this module.
289
289
 
290
290
  Args:
291
- iterable (list): List to iterate over
291
+ iterable (Iterable): List to iterate over
292
292
  desc (str): Description of the function execution displayed in the progress bar
293
293
  color (str): Color of the progress bar (Defaults to MAGENTA)
294
294
  bar_format (str): Format of the progress bar (Defaults to BAR_FORMAT)
File without changes
File without changes
File without changes