jetpytools 1.6.3__tar.gz → 1.6.4__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.
Potentially problematic release.
This version of jetpytools might be problematic. Click here for more details.
- {jetpytools-1.6.3 → jetpytools-1.6.4}/PKG-INFO +1 -1
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/_metadata.py +1 -1
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/base.py +61 -2
- {jetpytools-1.6.3 → jetpytools-1.6.4}/.gitignore +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/LICENSE +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/README.md +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/__init__.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/enums/__init__.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/enums/base.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/enums/other.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/__init__.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/enum.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/file.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/generic.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/module.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/__init__.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/funcs.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/normalize.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/other.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/py.typed +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/__init__.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/builtins.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/check.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/file.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/funcs.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/generic.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/supports.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/utils.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/__init__.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/file.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/funcs.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/math.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/ranges.py +0 -0
- {jetpytools-1.6.3 → jetpytools-1.6.4}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jetpytools
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.4
|
|
4
4
|
Summary: Collection of stuff that's useful in general python programming
|
|
5
5
|
Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/jetpytools
|
|
6
6
|
Project-URL: Contact, https://discord.gg/XTpc6Fa9eB
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Collection of stuff that's useful in general python programming"""
|
|
2
2
|
|
|
3
|
-
__version__ = "1.6.
|
|
3
|
+
__version__ = "1.6.4"
|
|
4
4
|
|
|
5
5
|
__author_name__, __author_email__ = "Jaded Encoding Thaumaturgy", "jaded.encoding.thaumaturgy@gmail.com"
|
|
6
6
|
__maintainer_name__, __maintainer_email__ = __author_name__, __author_email__
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
|
+
from contextlib import AbstractContextManager
|
|
4
5
|
from copy import deepcopy
|
|
5
|
-
from
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
from typing import TYPE_CHECKING, Any, Generic, TypeVar
|
|
6
8
|
|
|
7
9
|
from typing_extensions import Self
|
|
8
10
|
|
|
@@ -166,12 +168,69 @@ class CustomError(ExceptionError, metaclass=CustomErrorMeta):
|
|
|
166
168
|
else:
|
|
167
169
|
reason = ""
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
out = f"{func_header}{self.message!s}{reason}".format(**self.kwargs).strip()
|
|
172
|
+
|
|
173
|
+
if sys.version_info < (3, 13) and hasattr(self, "__notes__"):
|
|
174
|
+
out += "\n" + "\n".join(self.__notes__)
|
|
175
|
+
|
|
176
|
+
return out
|
|
177
|
+
|
|
178
|
+
if sys.version_info < (3, 13):
|
|
179
|
+
__notes__: list[str]
|
|
180
|
+
|
|
181
|
+
def add_note(self, note: str, /) -> None:
|
|
182
|
+
if not hasattr(self, "__notes__"):
|
|
183
|
+
self.__notes__ = []
|
|
184
|
+
|
|
185
|
+
self.__notes__.append(note)
|
|
186
|
+
|
|
187
|
+
@classmethod
|
|
188
|
+
def catch(cls) -> CatchError[Self]:
|
|
189
|
+
"""
|
|
190
|
+
Create a context manager that catches exceptions of this class type.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
CatchError[Self]: A context manager that will catch and store exceptions of type `cls`
|
|
194
|
+
when used in a `with` block.
|
|
195
|
+
"""
|
|
196
|
+
return CatchError(cls)
|
|
170
197
|
|
|
171
198
|
|
|
172
199
|
SelfError = TypeVar("SelfError", bound=CustomError)
|
|
173
200
|
|
|
174
201
|
|
|
202
|
+
class CatchError(AbstractContextManager["CatchError[SelfError]"], Generic[SelfError]):
|
|
203
|
+
"""
|
|
204
|
+
Context manager for catching a specific exception type.
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
error: SelfError | None
|
|
208
|
+
"""The caught exception instance, if any."""
|
|
209
|
+
tb: TracebackType | None
|
|
210
|
+
"""The traceback object associated with the caught exception."""
|
|
211
|
+
|
|
212
|
+
def __init__(self, error: type[SelfError]) -> None:
|
|
213
|
+
self.error = None
|
|
214
|
+
self.tb = None
|
|
215
|
+
self._to_catch_error = error
|
|
216
|
+
|
|
217
|
+
def __enter__(self) -> Self:
|
|
218
|
+
return self
|
|
219
|
+
|
|
220
|
+
def __exit__(
|
|
221
|
+
self,
|
|
222
|
+
exc_type: type[BaseException] | None,
|
|
223
|
+
exc_value: BaseException | None,
|
|
224
|
+
traceback: TracebackType | None,
|
|
225
|
+
) -> bool | None:
|
|
226
|
+
if isinstance(exc_value, self._to_catch_error):
|
|
227
|
+
self.error = exc_value
|
|
228
|
+
self.tb = traceback
|
|
229
|
+
return True
|
|
230
|
+
|
|
231
|
+
return None
|
|
232
|
+
|
|
233
|
+
|
|
175
234
|
class CustomValueError(CustomError, ValueError):
|
|
176
235
|
"""Thrown when a specified value is invalid."""
|
|
177
236
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|