nya-extract-error 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,13 @@
1
+ from .extract_error import (
2
+ extract_error,
3
+ extract_error_to_tuple,
4
+ extract_traceback,
5
+ print_exception_with_traceback,
6
+ )
7
+
8
+ __all__ = [
9
+ "extract_error",
10
+ "extract_error_to_tuple",
11
+ "extract_traceback",
12
+ "print_exception_with_traceback",
13
+ ]
File without changes
@@ -0,0 +1 @@
1
+ __version__: str = "0.1.0"
@@ -0,0 +1,29 @@
1
+ import traceback
2
+ from collections.abc import Callable
3
+
4
+
5
+ def extract_error_to_tuple(e: BaseException) -> tuple[str, str]:
6
+ return (
7
+ e.__class__.__name__,
8
+ str(e),
9
+ )
10
+
11
+
12
+ def extract_error(e: BaseException, *, pattern: str = "%s: %s") -> str:
13
+ return pattern % extract_error_to_tuple(e)
14
+
15
+
16
+ def extract_traceback(e: BaseException) -> str:
17
+ traceback_details = traceback.format_tb(e.__traceback__)
18
+ return "".join(traceback_details)
19
+
20
+
21
+ def print_exception_with_traceback(
22
+ e: BaseException,
23
+ *,
24
+ print: Callable[[str], None] = print, # ruff:ignore[builtin-argument-shadowing]
25
+ ) -> None:
26
+ """Re-enact the traceback printing when an exception is raised, without actually raising the exception."""
27
+ print("Traceback (most recent call last):")
28
+ print(extract_traceback(e))
29
+ print(extract_error(e))
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: nya-extract-error
3
+ Version: 0.1.0
4
+ Summary: Provide helpful functions to convert python Exceptions and tracebacks into str. Ported from my own package, tcrutils.
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+
8
+ # nya-extract-error
9
+
10
+ Provide helpful functions to convert python Exceptions and tracebacks into str. Ported from my own package, tcrutils.
@@ -0,0 +1,7 @@
1
+ nya_extract_error/__init__.py,sha256=dTt8-ow162aWHT7X4wTrr9Ii7RRDVDJOMhCYGzWJ71Q,242
2
+ nya_extract_error/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ nya_extract_error/_version.py,sha256=5HYXODBNk5J9vVbUrfu716lCND-BNE2LCfb2Jp8jsXs,26
4
+ nya_extract_error/extract_error.py,sha256=NOnFD5XQFYJyATN4NWDDOUJmY2sKdvi8xaw11-zcEBI,790
5
+ nya_extract_error-0.1.0.dist-info/METADATA,sha256=2lScZpOXqtrZflPhD5aUtUfJ5v89duBoW_ZvIxo8dfA,391
6
+ nya_extract_error-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
7
+ nya_extract_error-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any