pymiele 0.5.1__py3-none-any.whl → 0.5.2__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.
- pymiele/code_enum.py +23 -6
- pymiele/const.py +1 -1
- {pymiele-0.5.1.dist-info → pymiele-0.5.2.dist-info}/METADATA +1 -1
- pymiele-0.5.2.dist-info/RECORD +11 -0
- pymiele-0.5.1.dist-info/RECORD +0 -11
- {pymiele-0.5.1.dist-info → pymiele-0.5.2.dist-info}/WHEEL +0 -0
- {pymiele-0.5.1.dist-info → pymiele-0.5.2.dist-info}/licenses/LICENSE +0 -0
- {pymiele-0.5.1.dist-info → pymiele-0.5.2.dist-info}/top_level.txt +0 -0
pymiele/code_enum.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Enum class for Miele intergration."""
|
2
2
|
|
3
3
|
from enum import IntEnum
|
4
4
|
import logging
|
@@ -11,10 +11,20 @@ completed_warnings: set[str] = set()
|
|
11
11
|
class MieleEnum(IntEnum):
|
12
12
|
"""Miele Enum for codes with int values."""
|
13
13
|
|
14
|
+
# Modify the behaviour of the class when detecting a missing value:
|
15
|
+
# Add a member missing2none in order to:
|
16
|
+
# - Log a warning that the code is missing
|
17
|
+
# - Return None as key name
|
18
|
+
#
|
19
|
+
# Add a member unknown_code in order to:
|
20
|
+
# - Log a warning that the code is missing
|
21
|
+
# - Return 'unknown_value' as key name
|
22
|
+
|
14
23
|
@property
|
15
|
-
def name(self) -> str:
|
24
|
+
def name(self) -> str | None:
|
16
25
|
"""Force to lower case."""
|
17
|
-
|
26
|
+
_name = super().name.lower()
|
27
|
+
return _name if _name != "missing2none" else None
|
18
28
|
|
19
29
|
@classmethod
|
20
30
|
def _missing_(cls, value: object) -> Any | None:
|
@@ -25,7 +35,14 @@ class MieleEnum(IntEnum):
|
|
25
35
|
if warning not in completed_warnings:
|
26
36
|
completed_warnings.add(warning)
|
27
37
|
_LOGGER.warning(warning)
|
28
|
-
return cls.unknown_code
|
38
|
+
return cls.unknown_code # pylint: disable=no-member
|
39
|
+
if hasattr(cls, "missing2none"):
|
40
|
+
warning = f"Missing {cls.__name__} code: {value} - defaulting to Unknown"
|
41
|
+
if warning not in completed_warnings:
|
42
|
+
completed_warnings.add(warning)
|
43
|
+
_LOGGER.warning(warning)
|
44
|
+
return cls.missing2none # pylint: disable=no-member
|
45
|
+
|
29
46
|
return None
|
30
47
|
|
31
48
|
def __new__(cls, value: int, *values: list[int]) -> Any:
|
@@ -39,12 +56,12 @@ class MieleEnum(IntEnum):
|
|
39
56
|
@classmethod
|
40
57
|
def as_dict(cls) -> dict[str, int]:
|
41
58
|
"""Return a dict of enum names and values."""
|
42
|
-
return {i.name: i.value for i in cls if i.name
|
59
|
+
return {i.name: i.value for i in cls if i.name is not None}
|
43
60
|
|
44
61
|
@classmethod
|
45
62
|
def as_enum_dict(cls) -> dict[int, Any]:
|
46
63
|
"""Return a dict of enum values and enum names."""
|
47
|
-
return {i.value: i for i in cls if i.name
|
64
|
+
return {i.value: i for i in cls if i.name is not None}
|
48
65
|
|
49
66
|
@classmethod
|
50
67
|
def values(cls) -> list[int]:
|
pymiele/const.py
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
pymiele/__init__.py,sha256=yaR_pvVA5HfAxQ9oHCk8CsoHfEkskdZLmxbY1QgrMBE,260
|
2
|
+
pymiele/code_enum.py,sha256=fagb4d114ZgMKcVZuITZNpwrJOUReYpkf3qLEmabqLQ,2603
|
3
|
+
pymiele/const.py,sha256=8zzTh8sdNUoWzuKJsmpXnkzRFNR7HmnbG0mWDBQm-rM,237
|
4
|
+
pymiele/model.py,sha256=oMf8CVnCrbrzvs66mVXNjilDolkRQV4UedtEVoOrD8A,21726
|
5
|
+
pymiele/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
pymiele/pymiele.py,sha256=yGL4rekRPGzwXziZ5ydVrsEN-XPN110dmuWygbXF148,9405
|
7
|
+
pymiele-0.5.2.dist-info/licenses/LICENSE,sha256=scGm4_U2pd-rsGa6Edf6zsXFebrMT4RoyQz7-904_Wg,1072
|
8
|
+
pymiele-0.5.2.dist-info/METADATA,sha256=8QVtr2txJTjFWjAk5-_0qGbL8Sr6R5BgQ9-iHrudu7s,747
|
9
|
+
pymiele-0.5.2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
10
|
+
pymiele-0.5.2.dist-info/top_level.txt,sha256=BwkHrSO2w_Bfxh6s8Ikcao5enEuQOpQhJ3SwUXBqY10,8
|
11
|
+
pymiele-0.5.2.dist-info/RECORD,,
|
pymiele-0.5.1.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
pymiele/__init__.py,sha256=yaR_pvVA5HfAxQ9oHCk8CsoHfEkskdZLmxbY1QgrMBE,260
|
2
|
-
pymiele/code_enum.py,sha256=w-meA0nIdhqqqg_qPDXB9ksFhAkz6mjim7SwHhZJTl0,1829
|
3
|
-
pymiele/const.py,sha256=B-ityORYZEBbwF6kEZueOC-pBXcLOt9Frn5Un586QIE,237
|
4
|
-
pymiele/model.py,sha256=oMf8CVnCrbrzvs66mVXNjilDolkRQV4UedtEVoOrD8A,21726
|
5
|
-
pymiele/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
pymiele/pymiele.py,sha256=yGL4rekRPGzwXziZ5ydVrsEN-XPN110dmuWygbXF148,9405
|
7
|
-
pymiele-0.5.1.dist-info/licenses/LICENSE,sha256=scGm4_U2pd-rsGa6Edf6zsXFebrMT4RoyQz7-904_Wg,1072
|
8
|
-
pymiele-0.5.1.dist-info/METADATA,sha256=XlsB6119QcBVnrdIpicz73bOKuMXmHEiFqC0yZ5JVXo,747
|
9
|
-
pymiele-0.5.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
10
|
-
pymiele-0.5.1.dist-info/top_level.txt,sha256=BwkHrSO2w_Bfxh6s8Ikcao5enEuQOpQhJ3SwUXBqY10,8
|
11
|
-
pymiele-0.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|