catchlib 1.0.2__tar.gz → 1.0.5__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.
- {catchlib-1.0.2 → catchlib-1.0.5}/LICENSE.txt +1 -1
- {catchlib-1.0.2/src/catchlib.egg-info → catchlib-1.0.5}/PKG-INFO +36 -6
- catchlib-1.0.5/README.rst +37 -0
- {catchlib-1.0.2 → catchlib-1.0.5}/pyproject.toml +4 -7
- {catchlib-1.0.2 → catchlib-1.0.5}/src/catchlib/__init__.py +3 -0
- catchlib-1.0.5/src/catchlib/__main__.py +4 -0
- catchlib-1.0.5/src/catchlib/core/__init__.py +8 -0
- {catchlib-1.0.2 → catchlib-1.0.5}/src/catchlib/tests/__init__.py +3 -3
- catchlib-1.0.5/src/catchlib/tests/test_1984.py +11 -0
- {catchlib-1.0.2 → catchlib-1.0.5/src/catchlib.egg-info}/PKG-INFO +36 -6
- {catchlib-1.0.2 → catchlib-1.0.5}/src/catchlib.egg-info/SOURCES.txt +2 -2
- catchlib-1.0.2/README.rst +0 -5
- catchlib-1.0.2/src/catchlib/core/__init__.py +0 -54
- catchlib-1.0.2/src/catchlib/tests/test_0.py +0 -76
- catchlib-1.0.2/src/catchlib.egg-info/requires.txt +0 -1
- {catchlib-1.0.2 → catchlib-1.0.5}/MANIFEST.in +0 -0
- {catchlib-1.0.2 → catchlib-1.0.5}/setup.cfg +0 -0
- {catchlib-1.0.2 → catchlib-1.0.5}/src/catchlib.egg-info/dependency_links.txt +0 -0
- {catchlib-1.0.2 → catchlib-1.0.5}/src/catchlib.egg-info/top_level.txt +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: catchlib
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0.5
|
|
4
|
+
Summary: catchlib
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
7
7
|
|
|
8
|
-
Copyright (c)
|
|
8
|
+
Copyright (c) 2026 Johannes
|
|
9
9
|
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
11
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -27,7 +27,6 @@ License: The MIT License (MIT)
|
|
|
27
27
|
Project-URL: Download, https://pypi.org/project/catchlib/#files
|
|
28
28
|
Project-URL: Index, https://pypi.org/project/catchlib/
|
|
29
29
|
Project-URL: Source, https://github.com/johannes-programming/catchlib/
|
|
30
|
-
Project-URL: Website, https://catchlib.johannes-programming.online/
|
|
31
30
|
Classifier: Development Status :: 5 - Production/Stable
|
|
32
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
33
32
|
Classifier: Natural Language :: English
|
|
@@ -39,11 +38,42 @@ Classifier: Typing :: Typed
|
|
|
39
38
|
Requires-Python: >=3.11
|
|
40
39
|
Description-Content-Type: text/x-rst
|
|
41
40
|
License-File: LICENSE.txt
|
|
42
|
-
Requires-Dist: overloadable<2,>=1.0.9
|
|
43
41
|
Dynamic: license-file
|
|
44
42
|
|
|
45
43
|
========
|
|
46
44
|
catchlib
|
|
47
45
|
========
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
Overview
|
|
48
|
+
--------
|
|
49
|
+
|
|
50
|
+
catchlib
|
|
51
|
+
|
|
52
|
+
Installation
|
|
53
|
+
------------
|
|
54
|
+
|
|
55
|
+
To install ``catchlib``, you can use ``pip``. Open your terminal and run:
|
|
56
|
+
|
|
57
|
+
.. code-block:: bash
|
|
58
|
+
|
|
59
|
+
pip install catchlib
|
|
60
|
+
|
|
61
|
+
License
|
|
62
|
+
-------
|
|
63
|
+
|
|
64
|
+
This project is licensed under the MIT License.
|
|
65
|
+
|
|
66
|
+
Links
|
|
67
|
+
-----
|
|
68
|
+
|
|
69
|
+
* `Download <https://pypi.org/project/catchlib/#files>`_
|
|
70
|
+
* `Index <https://pypi.org/project/catchlib/>`_
|
|
71
|
+
* `Source <https://github.com/johannes-programming/catchlib/>`_
|
|
72
|
+
|
|
73
|
+
Credits
|
|
74
|
+
-------
|
|
75
|
+
|
|
76
|
+
* Author: Johannes
|
|
77
|
+
* Email: `johannes.programming@gmail.com <mailto:johannes.programming@gmail.com>`_
|
|
78
|
+
|
|
79
|
+
Thank you for using ``catchlib``!
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
========
|
|
2
|
+
catchlib
|
|
3
|
+
========
|
|
4
|
+
|
|
5
|
+
Overview
|
|
6
|
+
--------
|
|
7
|
+
|
|
8
|
+
catchlib
|
|
9
|
+
|
|
10
|
+
Installation
|
|
11
|
+
------------
|
|
12
|
+
|
|
13
|
+
To install ``catchlib``, you can use ``pip``. Open your terminal and run:
|
|
14
|
+
|
|
15
|
+
.. code-block:: bash
|
|
16
|
+
|
|
17
|
+
pip install catchlib
|
|
18
|
+
|
|
19
|
+
License
|
|
20
|
+
-------
|
|
21
|
+
|
|
22
|
+
This project is licensed under the MIT License.
|
|
23
|
+
|
|
24
|
+
Links
|
|
25
|
+
-----
|
|
26
|
+
|
|
27
|
+
* `Download <https://pypi.org/project/catchlib/#files>`_
|
|
28
|
+
* `Index <https://pypi.org/project/catchlib/>`_
|
|
29
|
+
* `Source <https://github.com/johannes-programming/catchlib/>`_
|
|
30
|
+
|
|
31
|
+
Credits
|
|
32
|
+
-------
|
|
33
|
+
|
|
34
|
+
* Author: Johannes
|
|
35
|
+
* Email: `johannes.programming@gmail.com <mailto:johannes.programming@gmail.com>`_
|
|
36
|
+
|
|
37
|
+
Thank you for using ``catchlib``!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "setuptools.build_meta"
|
|
3
3
|
requires = [
|
|
4
|
-
"setuptools>=
|
|
4
|
+
"setuptools>=64.0",
|
|
5
5
|
]
|
|
6
6
|
|
|
7
7
|
[project]
|
|
@@ -18,15 +18,13 @@ classifiers = [
|
|
|
18
18
|
"Programming Language :: Python :: 3 :: Only",
|
|
19
19
|
"Typing :: Typed",
|
|
20
20
|
]
|
|
21
|
-
dependencies = [
|
|
22
|
-
|
|
23
|
-
]
|
|
24
|
-
description = "This project allows to catch exceptions easily."
|
|
21
|
+
dependencies = []
|
|
22
|
+
description = "catchlib"
|
|
25
23
|
keywords = []
|
|
26
24
|
name = "catchlib"
|
|
27
25
|
readme = "README.rst"
|
|
28
26
|
requires-python = ">=3.11"
|
|
29
|
-
version = "1.0.
|
|
27
|
+
version = "1.0.5"
|
|
30
28
|
|
|
31
29
|
[project.license]
|
|
32
30
|
file = "LICENSE.txt"
|
|
@@ -35,4 +33,3 @@ file = "LICENSE.txt"
|
|
|
35
33
|
Download = "https://pypi.org/project/catchlib/#files"
|
|
36
34
|
Index = "https://pypi.org/project/catchlib/"
|
|
37
35
|
Source = "https://github.com/johannes-programming/catchlib/"
|
|
38
|
-
Website = "https://catchlib.johannes-programming.online/"
|
|
@@ -6,11 +6,11 @@ __all__ = ["test"]
|
|
|
6
6
|
def test() -> unittest.TextTestRunner:
|
|
7
7
|
"This function runs all the tests."
|
|
8
8
|
loader: unittest.TestLoader
|
|
9
|
-
|
|
9
|
+
suite: unittest.TestSuite
|
|
10
10
|
runner: unittest.TextTestRunner
|
|
11
11
|
result: unittest.TextTestResult
|
|
12
12
|
loader = unittest.TestLoader()
|
|
13
|
-
|
|
13
|
+
suite = loader.discover(start_dir="catchlib.tests")
|
|
14
14
|
runner = unittest.TextTestRunner()
|
|
15
|
-
result = runner.run(
|
|
15
|
+
result = runner.run(suite)
|
|
16
16
|
return result
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: catchlib
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0.5
|
|
4
|
+
Summary: catchlib
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
7
7
|
|
|
8
|
-
Copyright (c)
|
|
8
|
+
Copyright (c) 2026 Johannes
|
|
9
9
|
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
11
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -27,7 +27,6 @@ License: The MIT License (MIT)
|
|
|
27
27
|
Project-URL: Download, https://pypi.org/project/catchlib/#files
|
|
28
28
|
Project-URL: Index, https://pypi.org/project/catchlib/
|
|
29
29
|
Project-URL: Source, https://github.com/johannes-programming/catchlib/
|
|
30
|
-
Project-URL: Website, https://catchlib.johannes-programming.online/
|
|
31
30
|
Classifier: Development Status :: 5 - Production/Stable
|
|
32
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
33
32
|
Classifier: Natural Language :: English
|
|
@@ -39,11 +38,42 @@ Classifier: Typing :: Typed
|
|
|
39
38
|
Requires-Python: >=3.11
|
|
40
39
|
Description-Content-Type: text/x-rst
|
|
41
40
|
License-File: LICENSE.txt
|
|
42
|
-
Requires-Dist: overloadable<2,>=1.0.9
|
|
43
41
|
Dynamic: license-file
|
|
44
42
|
|
|
45
43
|
========
|
|
46
44
|
catchlib
|
|
47
45
|
========
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
Overview
|
|
48
|
+
--------
|
|
49
|
+
|
|
50
|
+
catchlib
|
|
51
|
+
|
|
52
|
+
Installation
|
|
53
|
+
------------
|
|
54
|
+
|
|
55
|
+
To install ``catchlib``, you can use ``pip``. Open your terminal and run:
|
|
56
|
+
|
|
57
|
+
.. code-block:: bash
|
|
58
|
+
|
|
59
|
+
pip install catchlib
|
|
60
|
+
|
|
61
|
+
License
|
|
62
|
+
-------
|
|
63
|
+
|
|
64
|
+
This project is licensed under the MIT License.
|
|
65
|
+
|
|
66
|
+
Links
|
|
67
|
+
-----
|
|
68
|
+
|
|
69
|
+
* `Download <https://pypi.org/project/catchlib/#files>`_
|
|
70
|
+
* `Index <https://pypi.org/project/catchlib/>`_
|
|
71
|
+
* `Source <https://github.com/johannes-programming/catchlib/>`_
|
|
72
|
+
|
|
73
|
+
Credits
|
|
74
|
+
-------
|
|
75
|
+
|
|
76
|
+
* Author: Johannes
|
|
77
|
+
* Email: `johannes.programming@gmail.com <mailto:johannes.programming@gmail.com>`_
|
|
78
|
+
|
|
79
|
+
Thank you for using ``catchlib``!
|
|
@@ -4,11 +4,11 @@ README.rst
|
|
|
4
4
|
pyproject.toml
|
|
5
5
|
setup.cfg
|
|
6
6
|
src/catchlib/__init__.py
|
|
7
|
+
src/catchlib/__main__.py
|
|
7
8
|
src/catchlib.egg-info/PKG-INFO
|
|
8
9
|
src/catchlib.egg-info/SOURCES.txt
|
|
9
10
|
src/catchlib.egg-info/dependency_links.txt
|
|
10
|
-
src/catchlib.egg-info/requires.txt
|
|
11
11
|
src/catchlib.egg-info/top_level.txt
|
|
12
12
|
src/catchlib/core/__init__.py
|
|
13
13
|
src/catchlib/tests/__init__.py
|
|
14
|
-
src/catchlib/tests/
|
|
14
|
+
src/catchlib/tests/test_1984.py
|
catchlib-1.0.2/README.rst
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
from contextlib import contextmanager
|
|
2
|
-
from typing import *
|
|
3
|
-
|
|
4
|
-
from overloadable import Overloadable
|
|
5
|
-
|
|
6
|
-
__all__ = ["Catcher"]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Catcher:
|
|
10
|
-
"This class catches exceptions."
|
|
11
|
-
|
|
12
|
-
__slots__ = ("_caught",)
|
|
13
|
-
|
|
14
|
-
caught: Optional[BaseException]
|
|
15
|
-
|
|
16
|
-
def __init__(self: Self) -> None:
|
|
17
|
-
"This magic method initializes the current instance."
|
|
18
|
-
self._caught = None
|
|
19
|
-
|
|
20
|
-
@contextmanager
|
|
21
|
-
def catch(self: Self, *args: type[BaseException]) -> Generator[Self, None, None]:
|
|
22
|
-
"This contextmanager catches exceptions."
|
|
23
|
-
self._caught = None
|
|
24
|
-
exc: BaseException
|
|
25
|
-
try:
|
|
26
|
-
yield self
|
|
27
|
-
except args as exc:
|
|
28
|
-
self._caught = exc
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def caught(self: Self) -> Optional[BaseException]:
|
|
32
|
-
"This property stores the caught exception."
|
|
33
|
-
return self._caught
|
|
34
|
-
|
|
35
|
-
@Overloadable
|
|
36
|
-
def release(self: Self, *args: Any, **kwargs: Any) -> bool:
|
|
37
|
-
"This method raises the caught exception."
|
|
38
|
-
return bool(len(args) + len(kwargs))
|
|
39
|
-
|
|
40
|
-
@release.overload(False)
|
|
41
|
-
def release(self: Self) -> None:
|
|
42
|
-
"This method raises the caught exception."
|
|
43
|
-
exc: BaseException = self.caught
|
|
44
|
-
self._caught = None
|
|
45
|
-
if exc is not None:
|
|
46
|
-
raise exc
|
|
47
|
-
|
|
48
|
-
@release.overload(True)
|
|
49
|
-
def release(self: Self, cause: Optional[BaseException]) -> None:
|
|
50
|
-
"This method raises the caught exception."
|
|
51
|
-
exc: BaseException = self.caught
|
|
52
|
-
self._caught = None
|
|
53
|
-
if exc is not None:
|
|
54
|
-
raise exc from cause
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from typing import *
|
|
3
|
-
|
|
4
|
-
from catchlib.core import Catcher
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class TestCatcher(unittest.TestCase):
|
|
8
|
-
def test_captures_matching_exception(self: Self) -> None:
|
|
9
|
-
catcher: Catcher
|
|
10
|
-
catcher = Catcher()
|
|
11
|
-
with catcher.catch(ValueError):
|
|
12
|
-
raise ValueError("bad value")
|
|
13
|
-
self.assertIsNotNone(catcher.caught)
|
|
14
|
-
self.assertIsInstance(catcher.caught, ValueError)
|
|
15
|
-
self.assertEqual(str(catcher.caught), "bad value")
|
|
16
|
-
|
|
17
|
-
def test_no_exception_leaves_caught_none(self: Self) -> None:
|
|
18
|
-
catcher: Catcher
|
|
19
|
-
catcher = Catcher()
|
|
20
|
-
with catcher.catch(ValueError):
|
|
21
|
-
pass
|
|
22
|
-
self.assertIsNone(catcher.caught)
|
|
23
|
-
|
|
24
|
-
def test_captures_one_of_multiple_types(self: Self) -> None:
|
|
25
|
-
catcher: Catcher
|
|
26
|
-
catcher = Catcher()
|
|
27
|
-
with catcher.catch(ValueError, KeyError):
|
|
28
|
-
raise KeyError("missing")
|
|
29
|
-
self.assertIsNotNone(catcher.caught)
|
|
30
|
-
self.assertIsInstance(catcher.caught, KeyError)
|
|
31
|
-
self.assertEqual(
|
|
32
|
-
str(catcher.caught), "'missing'"
|
|
33
|
-
) # KeyError stringifies with quotes
|
|
34
|
-
|
|
35
|
-
def test_non_matching_exception_propagates_and_does_not_set_caught(
|
|
36
|
-
self: Self,
|
|
37
|
-
) -> None:
|
|
38
|
-
catcher: Catcher
|
|
39
|
-
catcher = Catcher()
|
|
40
|
-
with self.assertRaises(ZeroDivisionError):
|
|
41
|
-
with catcher.catch(ValueError, KeyError):
|
|
42
|
-
1 / 0 # ZeroDivisionError not in capture set
|
|
43
|
-
# Since the exception propagated out, Catcher should not have recorded anything
|
|
44
|
-
self.assertIsNone(catcher.caught)
|
|
45
|
-
|
|
46
|
-
def test_reuse_and_reset_semantics(self: Self) -> None:
|
|
47
|
-
catcher: Catcher
|
|
48
|
-
catcher = Catcher()
|
|
49
|
-
|
|
50
|
-
# First, capture an exception
|
|
51
|
-
with catcher.catch(RuntimeError):
|
|
52
|
-
raise RuntimeError("first")
|
|
53
|
-
self.assertIsInstance(catcher.caught, RuntimeError)
|
|
54
|
-
|
|
55
|
-
# Next, a clean block should reset caught to None
|
|
56
|
-
with catcher.catch(RuntimeError):
|
|
57
|
-
pass
|
|
58
|
-
self.assertIsNone(catcher.caught)
|
|
59
|
-
|
|
60
|
-
# Finally, capture another (different) exception type by passing multiple
|
|
61
|
-
with catcher.catch(RuntimeError, TypeError):
|
|
62
|
-
raise TypeError("second")
|
|
63
|
-
self.assertIsInstance(catcher.caught, TypeError)
|
|
64
|
-
|
|
65
|
-
def test_empty_type_tuple_never_catches(self: Self) -> None:
|
|
66
|
-
catcher: Catcher
|
|
67
|
-
catcher = Catcher()
|
|
68
|
-
# Passing no types should behave like catching nothing: exception propagates
|
|
69
|
-
with self.assertRaises(ValueError):
|
|
70
|
-
with catcher.catch():
|
|
71
|
-
raise ValueError("won't be caught")
|
|
72
|
-
self.assertIsNone(catcher.caught)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if __name__ == "__main__":
|
|
76
|
-
unittest.main()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
overloadable<2,>=1.0.9
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|