enumerific 1.0.6__py3-none-any.whl → 1.0.7__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.
- enumerific/extensible.py +18 -1
- enumerific/version.txt +1 -1
- {enumerific-1.0.6.dist-info → enumerific-1.0.7.dist-info}/METADATA +27 -1
- enumerific-1.0.7.dist-info/RECORD +12 -0
- enumerific-1.0.6.dist-info/RECORD +0 -12
- {enumerific-1.0.6.dist-info → enumerific-1.0.7.dist-info}/WHEEL +0 -0
- {enumerific-1.0.6.dist-info → enumerific-1.0.7.dist-info}/licenses/LICENSE.md +0 -0
- {enumerific-1.0.6.dist-info → enumerific-1.0.7.dist-info}/top_level.txt +0 -0
- {enumerific-1.0.6.dist-info → enumerific-1.0.7.dist-info}/zip-safe +0 -0
enumerific/extensible.py
CHANGED
|
@@ -1458,6 +1458,7 @@ class EnumerationMetaClass(type):
|
|
|
1458
1458
|
value: Enumeration | object = None,
|
|
1459
1459
|
name: str = None,
|
|
1460
1460
|
caselessly: bool = False,
|
|
1461
|
+
annotation: str = None,
|
|
1461
1462
|
) -> Enumeration | None:
|
|
1462
1463
|
"""The 'reconcile' method can be used to reconcile Enumeration type, enumeration
|
|
1463
1464
|
values, or enumeration names to their matching Enumeration type instances. If a
|
|
@@ -1480,7 +1481,23 @@ class EnumerationMetaClass(type):
|
|
|
1480
1481
|
reconciled: Enumeration = None
|
|
1481
1482
|
|
|
1482
1483
|
for attribute, enumeration in self._enumerations.items():
|
|
1483
|
-
if isinstance(
|
|
1484
|
+
if isinstance(annotation, str):
|
|
1485
|
+
if annotation in enumeration._annotations:
|
|
1486
|
+
if enumeration._annotations[annotation] is value:
|
|
1487
|
+
reconciled = enumeration
|
|
1488
|
+
break
|
|
1489
|
+
elif enumeration._annotations[annotation] == value:
|
|
1490
|
+
reconciled = enumeration
|
|
1491
|
+
break
|
|
1492
|
+
else:
|
|
1493
|
+
raise EnumerationOptionError(
|
|
1494
|
+
"The enumeration option, %s, has no '%s' annotation!"
|
|
1495
|
+
% (
|
|
1496
|
+
enumeration,
|
|
1497
|
+
annotation,
|
|
1498
|
+
)
|
|
1499
|
+
)
|
|
1500
|
+
elif isinstance(value, Enumeration):
|
|
1484
1501
|
if enumeration is value:
|
|
1485
1502
|
reconciled = enumeration
|
|
1486
1503
|
break
|
enumerific/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.7
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: enumerific
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Simplifies working with Python enums.
|
|
5
5
|
Author: Daniel Sissman
|
|
6
6
|
License-Expression: MIT
|
|
@@ -675,6 +675,32 @@ assert Colors.PURPLE.rgb == (255, 0, 255)
|
|
|
675
675
|
assert Colors.PURPLE.primary is False
|
|
676
676
|
```
|
|
677
677
|
|
|
678
|
+
#### Example 19: Reconciling Enumeration Options via Annotations
|
|
679
|
+
|
|
680
|
+
```python
|
|
681
|
+
from enumerific import Enumeration, auto
|
|
682
|
+
|
|
683
|
+
class Colors(Enumeration):
|
|
684
|
+
"""Create a test Color enumeration based on the Enumeration class"""
|
|
685
|
+
|
|
686
|
+
RED = auto(RGB=(255, 0, 0))
|
|
687
|
+
GREEN = auto(RGB=(0, 255, 0))
|
|
688
|
+
BLUE = auto(RGB=(0, 0, 255))
|
|
689
|
+
|
|
690
|
+
# Ensure that the Colors enumeration subclass is of the expected types
|
|
691
|
+
assert issubclass(Colors, Enumeration)
|
|
692
|
+
|
|
693
|
+
# Attempt to reconcile a Color against one of its annotations
|
|
694
|
+
color = Colors.reconcile(value=(255, 0, 0), annotation="RGB")
|
|
695
|
+
|
|
696
|
+
assert isinstance(color, Colors)
|
|
697
|
+
assert isinstance(color, Enumeration)
|
|
698
|
+
|
|
699
|
+
assert color.name == "RED"
|
|
700
|
+
assert color.value == 1
|
|
701
|
+
assert color.RGB == (255, 0, 0)
|
|
702
|
+
```
|
|
703
|
+
|
|
678
704
|
# Enumerific Library Enumerations: Classes & Methods
|
|
679
705
|
|
|
680
706
|
The Enumerific library's `Enumeration` class is a greenfield implementation of enumerations
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
enumerific/__init__.py,sha256=K9iFirgxSkrHgXfhocOvgRkskGe0VfWRgxEvppnVWBM,587
|
|
2
|
+
enumerific/exceptions.py,sha256=lvfcH1cz43hDjzSUpgm1-OZjKzxo--fyZ8UsBS-GiZA,359
|
|
3
|
+
enumerific/extensible.py,sha256=HX-oZ91XtTLk5dmlqFOSFCO71_TEj1zGaO4KSKGwwoY,86507
|
|
4
|
+
enumerific/logging.py,sha256=zz1Phnot1BFWMoxwvZ0FlZDsiYZZYhz-_S4IzgPYc40,97
|
|
5
|
+
enumerific/standard.py,sha256=xQhhwlcYZ6-8DmgscbV38g2Ol5Z8_vvBwonz-Ww0I40,3254
|
|
6
|
+
enumerific/version.txt,sha256=6fmB8RVMkjgdY7ZTz7_Hm-ksP2zJXgkVpeXBnzkkylg,5
|
|
7
|
+
enumerific-1.0.7.dist-info/licenses/LICENSE.md,sha256=j1XidOCGUhPx7CyXA31uC0XGKDRnvUcZpMp161qHI6g,1077
|
|
8
|
+
enumerific-1.0.7.dist-info/METADATA,sha256=AnTj6l-xLoVxh1rQ1dFw1t8_v3Aq2slvwgiL458SBGs,33923
|
|
9
|
+
enumerific-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
enumerific-1.0.7.dist-info/top_level.txt,sha256=hyemsMgPYZgSx71XHmFRF-gvc_2Y4rDAESR8e0hbYHU,11
|
|
11
|
+
enumerific-1.0.7.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
12
|
+
enumerific-1.0.7.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
enumerific/__init__.py,sha256=K9iFirgxSkrHgXfhocOvgRkskGe0VfWRgxEvppnVWBM,587
|
|
2
|
-
enumerific/exceptions.py,sha256=lvfcH1cz43hDjzSUpgm1-OZjKzxo--fyZ8UsBS-GiZA,359
|
|
3
|
-
enumerific/extensible.py,sha256=9OodW6krNAd2B85QesBNUl3T5tcfsEJf_UhZ5sbNvyE,85763
|
|
4
|
-
enumerific/logging.py,sha256=zz1Phnot1BFWMoxwvZ0FlZDsiYZZYhz-_S4IzgPYc40,97
|
|
5
|
-
enumerific/standard.py,sha256=xQhhwlcYZ6-8DmgscbV38g2Ol5Z8_vvBwonz-Ww0I40,3254
|
|
6
|
-
enumerific/version.txt,sha256=4ct5uLutDTkkmV0uFpcf40QM4kZNWdiGBJJcDWsLbF0,5
|
|
7
|
-
enumerific-1.0.6.dist-info/licenses/LICENSE.md,sha256=j1XidOCGUhPx7CyXA31uC0XGKDRnvUcZpMp161qHI6g,1077
|
|
8
|
-
enumerific-1.0.6.dist-info/METADATA,sha256=DgcRl0DM_TlaRkBg7fIaMBl4wfKUydvjIzYsgLFJpL4,33208
|
|
9
|
-
enumerific-1.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
enumerific-1.0.6.dist-info/top_level.txt,sha256=hyemsMgPYZgSx71XHmFRF-gvc_2Y4rDAESR8e0hbYHU,11
|
|
11
|
-
enumerific-1.0.6.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
12
|
-
enumerific-1.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|