errortools 2.1.0__tar.gz → 2.2.0__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.
- {errortools-2.1.0/errortools.egg-info → errortools-2.2.0}/PKG-INFO +1 -1
- errortools-2.2.0/_errortools/descriptor/__init__.py +2 -0
- errortools-2.2.0/_errortools/descriptor/errormsg.py +37 -0
- errortools-2.2.0/_errortools/descriptor/nonblankmsg.py +52 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/version.py +2 -2
- errortools-2.2.0/_errortools/wrappers/__init__.py +2 -0
- {errortools-2.1.0 → errortools-2.2.0/errortools.egg-info}/PKG-INFO +1 -1
- {errortools-2.1.0 → errortools-2.2.0}/errortools.egg-info/SOURCES.txt +3 -0
- {errortools-2.1.0 → errortools-2.2.0}/setup.py +1 -1
- errortools-2.1.0/_errortools/wrappers/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/AUTHORS.txt +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/LICENSE.txt +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/README.md +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/_cli.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/classes/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/classes/abc.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/classes/errorcodes.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/classes/group.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/classes/warn.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/cli.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/const.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/decorator/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/decorator/cache.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/decorator/deprecated.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/future.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/ignore.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/logging/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/logging/base.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/logging/level.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/logging/logger.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/logging/record.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/logging/sink.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/metadata.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/methods/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/methods/errorattr.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/methods/errordelattr.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/methods/errorhasattr.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/methods/errorsetattr.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/partial.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/py.typed +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/raises.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/typing.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/wrappers/cache.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/_errortools/wrappers/ignore.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/errortools/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/errortools/__main__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/errortools.egg-info/dependency_links.txt +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/errortools.egg-info/entry_points.txt +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/errortools.egg-info/requires.txt +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/errortools.egg-info/top_level.txt +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/setup.cfg +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/__init__.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/conftest.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/run_tests.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_abc.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_cache.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_const.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_decorator.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_descriptor.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_errorcodes.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_groups.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_ignore.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_logging.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_mixins.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_partials.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_raises.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_typing.py +0 -0
- {errortools-2.1.0 → errortools-2.2.0}/tests/test_warnings.py +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from typing import Optional, NoReturn
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# NOTE: The attribute returns the preset message when accessed.
|
|
5
|
+
# Any attempt to modify or delete it raises an ``AttributeError``.
|
|
6
|
+
class ErrorMsg:
|
|
7
|
+
"""Descriptor that creates a read-only attribute with a fixed message.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
message: The fixed string returned when the attribute is accessed.
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
|
|
14
|
+
>>> class MyClass:
|
|
15
|
+
... status = ErrorMsg("This attribute is read-only")
|
|
16
|
+
>>> obj = MyClass()
|
|
17
|
+
>>> obj.status
|
|
18
|
+
'This attribute is read-only'
|
|
19
|
+
>>> obj.status = "new" # doctest: +SKIP
|
|
20
|
+
AttributeError: Modification of this attribute is not allowed!
|
|
21
|
+
>>> del obj.status # doctest: +SKIP
|
|
22
|
+
AttributeError: Deletion of this attribute is not allowed!
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__slots__ = ("_message",)
|
|
26
|
+
|
|
27
|
+
def __init__(self, message: str) -> None:
|
|
28
|
+
self._message = message
|
|
29
|
+
|
|
30
|
+
def __get__(self, instance: Optional[object], owner: type[object]) -> str:
|
|
31
|
+
return self._message
|
|
32
|
+
|
|
33
|
+
def __set__(self, instance: object, value: object) -> NoReturn:
|
|
34
|
+
raise AttributeError("Modification of this attribute is not allowed!")
|
|
35
|
+
|
|
36
|
+
def __delete__(self, instance: object) -> NoReturn:
|
|
37
|
+
raise AttributeError("Deletion of this attribute is not allowed!")
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# NOTE: Validates the value is a string and not empty
|
|
5
|
+
# after trimming leading/trailing whitespace.
|
|
6
|
+
# Stores the cleaned (stripped) value on the instance.
|
|
7
|
+
class NonBlankErrorMsg:
|
|
8
|
+
"""Descriptor that validates an attribute is a non-blank string after stripping whitespace.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
message: Name/label used in error messages for validation failures.
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
>>> class ApiError:
|
|
15
|
+
... message = NonBlankErrorMsg("Error message")
|
|
16
|
+
... def __init__(self, msg: str):
|
|
17
|
+
... self.message = msg
|
|
18
|
+
>>> err = ApiError("Invalid token")
|
|
19
|
+
>>> err.message
|
|
20
|
+
'Invalid token'
|
|
21
|
+
>>> err = ApiError(" ") # doctest: +SKIP
|
|
22
|
+
ValueError: Error message can't be blank, must provide a valid error message
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__slots__ = ("_message",)
|
|
26
|
+
|
|
27
|
+
def __init__(self, message: str) -> None:
|
|
28
|
+
self._message = message
|
|
29
|
+
|
|
30
|
+
def __get__(self, instance: Optional[object], owner: type[object]) -> str:
|
|
31
|
+
if instance is None:
|
|
32
|
+
return self._message
|
|
33
|
+
return instance.__dict__[self._message] # type: ignore
|
|
34
|
+
|
|
35
|
+
def __set__(self, instance: object, value: Any) -> None:
|
|
36
|
+
validated_value = self.validate(self._message, value)
|
|
37
|
+
instance.__dict__[self._message] = validated_value
|
|
38
|
+
|
|
39
|
+
def __delete__(self, instance: object) -> None:
|
|
40
|
+
raise AttributeError("Deletion of this attribute is not allowed!")
|
|
41
|
+
|
|
42
|
+
def validate(self, name: str, value: str) -> str:
|
|
43
|
+
if not isinstance(value, str):
|
|
44
|
+
raise ValueError(f"{name} must be a string type")
|
|
45
|
+
|
|
46
|
+
stripped_value = value.strip()
|
|
47
|
+
if not stripped_value:
|
|
48
|
+
raise ValueError(
|
|
49
|
+
f"{name} can't be blank, must provide a valid error message"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
return stripped_value
|
|
@@ -22,6 +22,9 @@ _errortools/classes/warn.py
|
|
|
22
22
|
_errortools/decorator/__init__.py
|
|
23
23
|
_errortools/decorator/cache.py
|
|
24
24
|
_errortools/decorator/deprecated.py
|
|
25
|
+
_errortools/descriptor/__init__.py
|
|
26
|
+
_errortools/descriptor/errormsg.py
|
|
27
|
+
_errortools/descriptor/nonblankmsg.py
|
|
25
28
|
_errortools/logging/__init__.py
|
|
26
29
|
_errortools/logging/base.py
|
|
27
30
|
_errortools/logging/level.py
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="errortools",
|
|
5
|
-
version="2.
|
|
5
|
+
version="2.2.0",
|
|
6
6
|
description="errortools - a toolset for working with Python exceptions and warnings and logging.",
|
|
7
7
|
long_description=open("README.md", encoding="utf-8").read(),
|
|
8
8
|
long_description_content_type="text/markdown",
|
|
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
|
|
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
|