enumerific 1.0.4__py3-none-any.whl → 1.0.6__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 CHANGED
@@ -1195,7 +1195,7 @@ class EnumerationMetaClass(type):
1195
1195
 
1196
1196
  logger.debug("+" * 100)
1197
1197
 
1198
- def __getattr__(self, name) -> object:
1198
+ def __getattr__(self, name: str) -> object:
1199
1199
  # logger.debug("%s.__getattr__(name: %s)", self.__class__.__name__, name)
1200
1200
 
1201
1201
  if name.startswith("_") or name in self._special:
@@ -1651,7 +1651,7 @@ class Enumeration(metaclass=EnumerationMetaClass):
1651
1651
  )
1652
1652
 
1653
1653
  if annotations is None:
1654
- pass
1654
+ self._annotations = anno(value=self.value)
1655
1655
  elif isinstance(annotations, anno):
1656
1656
  self._annotations = annotations
1657
1657
  else:
@@ -1704,8 +1704,6 @@ class Enumeration(metaclass=EnumerationMetaClass):
1704
1704
  return object.__getattribute__(self, name)
1705
1705
  elif self._enumerations and name in self._enumerations:
1706
1706
  return self._enumerations[name]
1707
- elif self._annotations and name in self._annotations:
1708
- return self._annotations[name]
1709
1707
  elif self._context and name in dir(self._context):
1710
1708
  # Handle class methods, instance methods and properties here; because we are
1711
1709
  # performing some special handling for enumerations, we need to reintroduce
@@ -1719,6 +1717,8 @@ class Enumeration(metaclass=EnumerationMetaClass):
1719
1717
  return attribute.__get__(self)
1720
1718
  else:
1721
1719
  return attribute
1720
+ elif self._annotations and name in self._annotations:
1721
+ return self._annotations[name]
1722
1722
  else:
1723
1723
  # EnumerationOptionError subclasses AttributeError so we adhere to convention
1724
1724
  raise EnumerationOptionError(
@@ -1753,6 +1753,10 @@ class Enumeration(metaclass=EnumerationMetaClass):
1753
1753
  def value(self) -> object:
1754
1754
  return self._value
1755
1755
 
1756
+ @property
1757
+ def annotations(self) -> anno:
1758
+ return self._annotations
1759
+
1756
1760
  @property
1757
1761
  def aliased(self) -> bool:
1758
1762
  logger.debug(
@@ -1793,6 +1797,28 @@ class Enumeration(metaclass=EnumerationMetaClass):
1793
1797
 
1794
1798
  return aliases
1795
1799
 
1800
+ @property
1801
+ def named(self) -> list[str]:
1802
+ logger.debug(
1803
+ "%s.names() >>> id(%s) => %s (%s)",
1804
+ self.__class__.__name__,
1805
+ self,
1806
+ id(self._enumerations),
1807
+ type(self._enumerations),
1808
+ )
1809
+
1810
+ names: list[Enumeration] = [self.name]
1811
+
1812
+ for name, enumeration in self._enumerations.items():
1813
+ logger.debug(" >>> checking for alias: %s => %s", name, enumeration)
1814
+
1815
+ if isinstance(enumeration, Enumeration):
1816
+ if self is enumeration and enumeration.name != name:
1817
+ if not name in names:
1818
+ names.append(name)
1819
+
1820
+ return names
1821
+
1796
1822
 
1797
1823
  class EnumerationType(Enumeration, typecast=False):
1798
1824
  """The EnumerationType class represents the type of value held by an enumeration."""
enumerific/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.6
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enumerific
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Simplifies working with Python enums.
5
5
  Author: Daniel Sissman
6
6
  License-Expression: MIT
@@ -468,6 +468,11 @@ assert Colors.BLUE.aliased is False
468
468
  assert Colors.RED.aliases == [Colors.ROUGE]
469
469
  assert Colors.GREEN.aliases == [Colors.VERTE]
470
470
  assert Colors.BLUE.aliases == [] # BLUE has not been aliased
471
+
472
+ # The names including any aliases for an option can be obtained via the .named property
473
+ assert Colors.RED.named == ["RED", "ROUGE"]
474
+ assert Colors.GREEN.named == ["GREEN", "VERTE"]
475
+ assert Colors.BLUE.named == ["BLUE"]
471
476
  ```
472
477
 
473
478
  #### Example 15: Non-Unique Options
@@ -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=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,,
@@ -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=nf82wPMWSzfpjF-LB5-UxreDji01cztG8rLWJe50SXE,84958
4
- enumerific/logging.py,sha256=zz1Phnot1BFWMoxwvZ0FlZDsiYZZYhz-_S4IzgPYc40,97
5
- enumerific/standard.py,sha256=xQhhwlcYZ6-8DmgscbV38g2Ol5Z8_vvBwonz-Ww0I40,3254
6
- enumerific/version.txt,sha256=rqWtvvV0eFJzxPOcG3aHz4AZk-DLa_Z4GkFonk7bsgw,5
7
- enumerific-1.0.4.dist-info/licenses/LICENSE.md,sha256=j1XidOCGUhPx7CyXA31uC0XGKDRnvUcZpMp161qHI6g,1077
8
- enumerific-1.0.4.dist-info/METADATA,sha256=WjQvIzsJYm4D75GhiF703QwI39Ph6TP55DfcNY18xP8,32990
9
- enumerific-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- enumerific-1.0.4.dist-info/top_level.txt,sha256=hyemsMgPYZgSx71XHmFRF-gvc_2Y4rDAESR8e0hbYHU,11
11
- enumerific-1.0.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
- enumerific-1.0.4.dist-info/RECORD,,