stouputils 1.2.39__tar.gz → 1.2.40__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 (35) hide show
  1. {stouputils-1.2.39 → stouputils-1.2.40}/PKG-INFO +1 -1
  2. {stouputils-1.2.39 → stouputils-1.2.40}/pyproject.toml +1 -1
  3. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/decorators.py +9 -2
  4. {stouputils-1.2.39 → stouputils-1.2.40}/.gitignore +0 -0
  5. {stouputils-1.2.39 → stouputils-1.2.40}/LICENSE +0 -0
  6. {stouputils-1.2.39 → stouputils-1.2.40}/README.md +0 -0
  7. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/__init__.py +0 -0
  8. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/all_doctests.py +0 -0
  9. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/applications/__init__.py +0 -0
  10. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/applications/automatic_docs.py +0 -0
  11. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/applications/upscaler/__init__.py +0 -0
  12. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/applications/upscaler/config.py +0 -0
  13. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/applications/upscaler/image.py +0 -0
  14. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/applications/upscaler/video.py +0 -0
  15. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/archive.py +0 -0
  16. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/backup.py +0 -0
  17. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/collections.py +0 -0
  18. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/continuous_delivery/__init__.py +0 -0
  19. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/continuous_delivery/cd_utils.py +0 -0
  20. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/continuous_delivery/github.py +0 -0
  21. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/continuous_delivery/pypi.py +0 -0
  22. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/continuous_delivery/pyproject.py +0 -0
  23. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/ctx.py +0 -0
  24. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/dont_look/zip_file_override.py +0 -0
  25. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/image.py +0 -0
  26. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/installer/__init__.py +0 -0
  27. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/installer/common.py +0 -0
  28. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/installer/downloader.py +0 -0
  29. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/installer/linux.py +0 -0
  30. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/installer/main.py +0 -0
  31. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/installer/windows.py +0 -0
  32. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/io.py +0 -0
  33. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/parallel.py +0 -0
  34. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/print.py +0 -0
  35. {stouputils-1.2.39 → stouputils-1.2.40}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.2.39
3
+ Version: 1.2.40
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.2.39"
8
+ version = "1.2.40"
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"
@@ -21,6 +21,7 @@ from functools import wraps
21
21
  from pickle import dumps as pickle_dumps
22
22
  from traceback import format_exc
23
23
  from typing import Any, Literal
24
+ import time
24
25
 
25
26
  from .print import debug, error, warning
26
27
  from .ctx import Muffle, MeasureTime
@@ -134,12 +135,13 @@ def handle_error(
134
135
  *,
135
136
  exceptions: tuple[type[BaseException], ...] | type[BaseException] = (Exception,),
136
137
  message: str = "",
137
- error_log: LogLevels = LogLevels.WARNING_TRACEBACK
138
+ error_log: LogLevels = LogLevels.WARNING_TRACEBACK,
139
+ sleep_time: float = 0.0
138
140
  ) -> Callable[..., Any]:
139
141
  """ Decorator that handle an error with different log levels.
140
142
 
141
143
  Args:
142
- func (Callable[..., Any] | None): Function to decorate
144
+ func (Callable[..., Any] | None): Function to decorate
143
145
  exceptions (tuple[type[BaseException]], ...): Exceptions to handle
144
146
  message (str): Message to display with the error. (e.g. "Error during something")
145
147
  error_log (LogLevels): Log level for the errors
@@ -148,6 +150,7 @@ def handle_error(
148
150
  LogLevels.WARNING_TRACEBACK: Show as warning with traceback
149
151
  LogLevels.ERROR_TRACEBACK: Show as error with traceback
150
152
  LogLevels.RAISE_EXCEPTION: Raise exception
153
+ sleep_time (float): Time to sleep after the error (e.g. 0.0 to not sleep, 1.0 to sleep for 1 second)
151
154
 
152
155
  Examples:
153
156
  >>> @handle_error
@@ -182,6 +185,10 @@ def handle_error(
182
185
  error(f"{msg}Error during {get_func_name(func)}:\n{format_exc()}", exit=True)
183
186
  elif error_log == LogLevels.RAISE_EXCEPTION:
184
187
  raise e
188
+
189
+ # Sleep for the specified time, only if the error_log is not ERROR_TRACEBACK (because it's blocking)
190
+ if sleep_time > 0.0 and error_log != LogLevels.ERROR_TRACEBACK:
191
+ time.sleep(sleep_time)
185
192
  return wrapper
186
193
 
187
194
  # Handle both @handle_error and @handle_error(exceptions=..., message=..., error_log=...)
File without changes
File without changes
File without changes