stouputils 1.2.28__tar.gz → 1.2.29__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 (25) hide show
  1. {stouputils-1.2.28 → stouputils-1.2.29}/PKG-INFO +1 -1
  2. {stouputils-1.2.28 → stouputils-1.2.29}/pyproject.toml +1 -1
  3. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/decorators.py +11 -6
  4. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/parallel.py +2 -2
  5. {stouputils-1.2.28 → stouputils-1.2.29}/.gitignore +0 -0
  6. {stouputils-1.2.28 → stouputils-1.2.29}/LICENSE +0 -0
  7. {stouputils-1.2.28 → stouputils-1.2.29}/README.md +0 -0
  8. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/__init__.py +0 -0
  9. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/all_doctests.py +0 -0
  10. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/applications/__init__.py +0 -0
  11. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/applications/automatic_docs.py +0 -0
  12. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/archive.py +0 -0
  13. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/backup.py +0 -0
  14. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/collections.py +0 -0
  15. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/continuous_delivery/__init__.py +0 -0
  16. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/continuous_delivery/cd_utils.py +0 -0
  17. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/continuous_delivery/github.py +0 -0
  18. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/continuous_delivery/pypi.py +0 -0
  19. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/continuous_delivery/pyproject.py +0 -0
  20. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/ctx.py +0 -0
  21. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/dont_look/zip_file_override.py +0 -0
  22. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/image.py +0 -0
  23. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/io.py +0 -0
  24. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/print.py +0 -0
  25. {stouputils-1.2.28 → stouputils-1.2.29}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.2.28
3
+ Version: 1.2.29
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.28"
8
+ version = "1.2.29"
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"
@@ -25,6 +25,11 @@ from typing import Callable, Literal, Any
25
25
  from functools import wraps
26
26
  from .print import debug, warning, error
27
27
 
28
+ def get_func_name(func: Callable[..., Any]) -> str:
29
+ try:
30
+ return func.__name__
31
+ except:
32
+ return "<unknown>"
28
33
 
29
34
  # Decorator that make a function silent (disable stdout)
30
35
  def silent(
@@ -113,7 +118,7 @@ def measure_time(
113
118
  # Set the message if not specified
114
119
  nonlocal message
115
120
  if not message:
116
- message = f"Execution time of {func.__name__}"
121
+ message = f"Execution time of {get_func_name(func)}"
117
122
 
118
123
  @wraps(func)
119
124
  def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> Any:
@@ -213,11 +218,11 @@ def handle_error(
213
218
  return func(*args, **kwargs)
214
219
  except exceptions as e:
215
220
  if error_log == LogLevels.WARNING:
216
- warning(f"{msg}Error during {func.__name__}: ({type(e).__name__}) {e}")
221
+ warning(f"{msg}Error during {get_func_name(func)}: ({type(e).__name__}) {e}")
217
222
  elif error_log == LogLevels.WARNING_TRACEBACK:
218
- warning(f"{msg}Error during {func.__name__}:\n{format_exc()}")
223
+ warning(f"{msg}Error during {get_func_name(func)}:\n{format_exc()}")
219
224
  elif error_log == LogLevels.ERROR_TRACEBACK:
220
- error(f"{msg}Error during {func.__name__}:\n{format_exc()}", exit=True)
225
+ error(f"{msg}Error during {get_func_name(func)}:\n{format_exc()}", exit=True)
221
226
  elif error_log == LogLevels.RAISE_EXCEPTION:
222
227
  raise e
223
228
  return wrapper
@@ -327,7 +332,7 @@ def deprecated(
327
332
  @wraps(func)
328
333
  def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> Any:
329
334
  # Build deprecation message
330
- msg: str = f"Function '{func.__name__}()' is deprecated"
335
+ msg: str = f"Function '{get_func_name(func)}()' is deprecated"
331
336
  if message:
332
337
  msg += f". {message}"
333
338
 
@@ -385,7 +390,7 @@ def abstract(
385
390
  NotImplementedError: Function 'method' is abstract and must be implemented by a subclass
386
391
  """
387
392
  def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
388
- message: str = f"Function '{func.__name__}' is abstract and must be implemented by a subclass"
393
+ message: str = f"Function '{get_func_name(func)}' is abstract and must be implemented by a subclass"
389
394
  if not func.__doc__:
390
395
  func.__doc__ = message
391
396
 
@@ -12,7 +12,7 @@ I highly encourage you to read the function docstrings to understand when to use
12
12
 
13
13
  # Imports
14
14
  from .print import MAGENTA, RESET
15
- from .decorators import handle_error, LogLevels
15
+ from .decorators import handle_error, LogLevels, get_func_name
16
16
  from multiprocessing import Pool, cpu_count
17
17
  from typing import Callable, TypeVar
18
18
  from tqdm.auto import tqdm
@@ -67,7 +67,7 @@ def __handle_parameters(
67
67
  tuple[str, Callable[[T], R], list[T]]: Tuple containing the description, function, and arguments
68
68
  """
69
69
  if not desc:
70
- desc = func.__name__
70
+ desc = get_func_name(func)
71
71
  desc = color + desc
72
72
 
73
73
  # If use_starmap is True, we use the __starmap function
File without changes
File without changes
File without changes