stouputils 1.2.37__tar.gz → 1.2.39__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.37 → stouputils-1.2.39}/PKG-INFO +1 -1
  2. {stouputils-1.2.37 → stouputils-1.2.39}/pyproject.toml +1 -1
  3. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/__init__.py +8 -0
  4. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/ctx.py +11 -4
  5. {stouputils-1.2.37 → stouputils-1.2.39}/.gitignore +0 -0
  6. {stouputils-1.2.37 → stouputils-1.2.39}/LICENSE +0 -0
  7. {stouputils-1.2.37 → stouputils-1.2.39}/README.md +0 -0
  8. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/all_doctests.py +0 -0
  9. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/applications/__init__.py +0 -0
  10. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/applications/automatic_docs.py +0 -0
  11. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/applications/upscaler/__init__.py +0 -0
  12. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/applications/upscaler/config.py +0 -0
  13. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/applications/upscaler/image.py +0 -0
  14. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/applications/upscaler/video.py +0 -0
  15. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/archive.py +0 -0
  16. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/backup.py +0 -0
  17. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/collections.py +0 -0
  18. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/continuous_delivery/__init__.py +0 -0
  19. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/continuous_delivery/cd_utils.py +0 -0
  20. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/continuous_delivery/github.py +0 -0
  21. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/continuous_delivery/pypi.py +0 -0
  22. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/continuous_delivery/pyproject.py +0 -0
  23. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/decorators.py +0 -0
  24. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/dont_look/zip_file_override.py +0 -0
  25. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/image.py +0 -0
  26. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/installer/__init__.py +0 -0
  27. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/installer/common.py +0 -0
  28. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/installer/downloader.py +0 -0
  29. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/installer/linux.py +0 -0
  30. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/installer/main.py +0 -0
  31. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/installer/windows.py +0 -0
  32. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/io.py +0 -0
  33. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/parallel.py +0 -0
  34. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/print.py +0 -0
  35. {stouputils-1.2.37 → stouputils-1.2.39}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.2.37
3
+ Version: 1.2.39
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.37"
8
+ version = "1.2.39"
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"
@@ -31,3 +31,11 @@ from .io import *
31
31
  from .parallel import *
32
32
  from .print import *
33
33
 
34
+ # Version (handle case where the package is not installed)
35
+ import importlib.metadata
36
+
37
+ try:
38
+ __version__: str = importlib.metadata.version("stouputils")
39
+ except importlib.metadata.PackageNotFoundError:
40
+ __version__: str = "0.0.0-dev"
41
+
@@ -9,6 +9,7 @@ This module provides context managers for temporarily silencing output.
9
9
  """
10
10
 
11
11
  # Imports
12
+ from __future__ import annotations
12
13
  import os
13
14
  import sys
14
15
  import time
@@ -37,7 +38,7 @@ class Muffle:
37
38
  self.original_stderr: TextIO = sys.stderr
38
39
  """ Attribute remembering original stderr """
39
40
 
40
- def __enter__(self) -> None:
41
+ def __enter__(self) -> Muffle:
41
42
  """ Enter context manager which redirects stdout and stderr to devnull """
42
43
  # Redirect stdout to devnull
43
44
  sys.stdout = open(os.devnull, "w", encoding="utf-8")
@@ -46,6 +47,9 @@ class Muffle:
46
47
  if self.mute_stderr:
47
48
  sys.stderr = open(os.devnull, "w", encoding="utf-8")
48
49
 
50
+ # Return self
51
+ return self
52
+
49
53
  def __exit__(self, exc_type: type[BaseException]|None, exc_val: BaseException|None, exc_tb: Any|None) -> None:
50
54
  """ Exit context manager which restores original stdout and stderr """
51
55
  # Restore original stdout
@@ -110,15 +114,17 @@ class LogToFile:
110
114
  self.original_stderr: TextIO = sys.stderr
111
115
  """ Original stderr before redirection """
112
116
 
113
- def __enter__(self) -> None:
117
+ def __enter__(self) -> LogToFile:
114
118
  """ Enter context manager which opens the log file and redirects stdout/stderr """
115
119
  # Redirect stdout and stderr if requested
116
120
  if self.tee_stdout:
117
121
  sys.stdout = TeeMultiOutput(self.original_stdout, self.file, ignore_lineup=self.ignore_lineup)
118
-
119
122
  if self.tee_stderr:
120
123
  sys.stderr = TeeMultiOutput(self.original_stderr, self.file, ignore_lineup=self.ignore_lineup)
121
124
 
125
+ # Return self
126
+ return self
127
+
122
128
  def __exit__(self, exc_type: type[BaseException]|None, exc_val: BaseException|None, exc_tb: Any|None) -> None:
123
129
  """ Exit context manager which closes the log file and restores stdout/stderr """
124
130
  # Restore original stdout and stderr
@@ -204,9 +210,10 @@ class MeasureTime:
204
210
  self.start_ns: int = 0
205
211
  """ Start time in nanoseconds """
206
212
 
207
- def __enter__(self) -> None:
213
+ def __enter__(self) -> MeasureTime:
208
214
  """ Enter context manager, record start time """
209
215
  self.start_ns = self.ns()
216
+ return self
210
217
 
211
218
  def __exit__(self, exc_type: type[BaseException]|None, exc_val: BaseException|None, exc_tb: Any|None) -> None:
212
219
  """ Exit context manager, calculate duration and print """
File without changes
File without changes
File without changes