enumerific 1.0.5__tar.gz → 1.0.6__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.
- {enumerific-1.0.5/source/enumerific.egg-info → enumerific-1.0.6}/PKG-INFO +6 -1
- {enumerific-1.0.5 → enumerific-1.0.6}/README.md +5 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific/extensible.py +22 -0
- enumerific-1.0.6/source/enumerific/version.txt +1 -0
- {enumerific-1.0.5 → enumerific-1.0.6/source/enumerific.egg-info}/PKG-INFO +6 -1
- {enumerific-1.0.5 → enumerific-1.0.6}/tests/test_extensible_enums.py +37 -4
- enumerific-1.0.5/source/enumerific/version.txt +0 -1
- {enumerific-1.0.5 → enumerific-1.0.6}/LICENSE.md +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/pyproject.toml +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/requirements.development.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/requirements.distribution.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/requirements.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/setup.cfg +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific/__init__.py +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific/exceptions.py +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific/logging.py +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific/standard.py +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific.egg-info/SOURCES.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific.egg-info/dependency_links.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific.egg-info/requires.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific.egg-info/top_level.txt +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/source/enumerific.egg-info/zip-safe +0 -0
- {enumerific-1.0.5 → enumerific-1.0.6}/tests/test_enumerific_library.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: enumerific
|
|
3
|
-
Version: 1.0.
|
|
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
|
|
@@ -438,6 +438,11 @@ assert Colors.BLUE.aliased is False
|
|
|
438
438
|
assert Colors.RED.aliases == [Colors.ROUGE]
|
|
439
439
|
assert Colors.GREEN.aliases == [Colors.VERTE]
|
|
440
440
|
assert Colors.BLUE.aliases == [] # BLUE has not been aliased
|
|
441
|
+
|
|
442
|
+
# The names including any aliases for an option can be obtained via the .named property
|
|
443
|
+
assert Colors.RED.named == ["RED", "ROUGE"]
|
|
444
|
+
assert Colors.GREEN.named == ["GREEN", "VERTE"]
|
|
445
|
+
assert Colors.BLUE.named == ["BLUE"]
|
|
441
446
|
```
|
|
442
447
|
|
|
443
448
|
#### Example 15: Non-Unique Options
|
|
@@ -1797,6 +1797,28 @@ class Enumeration(metaclass=EnumerationMetaClass):
|
|
|
1797
1797
|
|
|
1798
1798
|
return aliases
|
|
1799
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
|
+
|
|
1800
1822
|
|
|
1801
1823
|
class EnumerationType(Enumeration, typecast=False):
|
|
1802
1824
|
"""The EnumerationType class represents the type of value held by an enumeration."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.6
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: enumerific
|
|
3
|
-
Version: 1.0.
|
|
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
|
|
@@ -380,24 +380,57 @@ def test_extensible_enumeration_integer_non_unique():
|
|
|
380
380
|
BLUE = 3
|
|
381
381
|
ROUGE = 1
|
|
382
382
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
) # while there are only 3 distinct values, there are 4 options
|
|
383
|
+
# While there are only 3 distinct values, there are 4 options, due the alias for RED
|
|
384
|
+
assert len(Colors) == 4
|
|
386
385
|
|
|
387
|
-
|
|
386
|
+
# Ensure that the keys, names, values, items and options methods return as expected
|
|
387
|
+
assert Colors.keys() == ["RED", "GREEN", "BLUE", "ROUGE"]
|
|
388
|
+
assert Colors.names() == ["RED", "GREEN", "BLUE", "ROUGE"]
|
|
389
|
+
assert Colors.values() == [1, 2, 3, 1]
|
|
390
|
+
assert Colors.items() == [("RED", 1), ("GREEN", 2), ("BLUE", 3), ("ROUGE", 1)]
|
|
391
|
+
assert Colors.options() == {"RED": 1, "GREEN": 2, "BLUE": 3, "ROUGE": 1}
|
|
388
392
|
|
|
393
|
+
# Ensure that the aliased option has the expected identity and equality
|
|
394
|
+
assert Colors.RED is Colors.ROUGE # As ROUGE is an alias of RED, identity matches
|
|
395
|
+
assert Colors.RED == Colors.ROUGE # As ROUGE is an alias of RED, equality matches
|
|
396
|
+
|
|
397
|
+
# Ensure that the property values of RED are as expected
|
|
389
398
|
assert Colors.RED.name == "RED"
|
|
390
399
|
assert Colors.RED.value == 1
|
|
400
|
+
assert Colors.RED.aliased is True
|
|
401
|
+
assert Colors.RED.aliases == [Colors.ROUGE]
|
|
402
|
+
assert Colors.RED.named == ["RED", "ROUGE"]
|
|
391
403
|
|
|
404
|
+
# Ensure that the property values of ROUGE are as expected (as an alias of RED)
|
|
392
405
|
assert Colors.ROUGE.name == "RED"
|
|
393
406
|
assert Colors.ROUGE.value == 1
|
|
407
|
+
assert Colors.ROUGE.aliased is True
|
|
408
|
+
assert Colors.ROUGE.aliases == [Colors.RED]
|
|
409
|
+
assert Colors.ROUGE.named == ["RED", "ROUGE"]
|
|
410
|
+
|
|
411
|
+
# Ensure that the property values of GREEN are as expected
|
|
412
|
+
assert Colors.GREEN.name == "GREEN"
|
|
413
|
+
assert Colors.GREEN.value == 2
|
|
414
|
+
assert Colors.GREEN.aliased is False
|
|
415
|
+
assert Colors.GREEN.aliases == []
|
|
416
|
+
assert Colors.GREEN.named == ["GREEN"]
|
|
417
|
+
|
|
418
|
+
# Ensure that the property values of BLUE are as expected
|
|
419
|
+
assert Colors.BLUE.name == "BLUE"
|
|
420
|
+
assert Colors.BLUE.value == 3
|
|
421
|
+
assert Colors.BLUE.aliased is False
|
|
422
|
+
assert Colors.BLUE.aliases == []
|
|
423
|
+
assert Colors.BLUE.named == ["BLUE"]
|
|
394
424
|
|
|
425
|
+
# We can find the aliases for the Colors enumeration by finding the options with
|
|
426
|
+
# names that do no match their associated enumeration option name:
|
|
395
427
|
assert [
|
|
396
428
|
name for name, option in Colors.__options__.items() if option.name != name
|
|
397
429
|
] == [
|
|
398
430
|
"ROUGE"
|
|
399
431
|
] # ROUGE is an alias, so its name does not match the option it maps to
|
|
400
432
|
|
|
433
|
+
# Ensure that the aliases map is as expected
|
|
401
434
|
assert len(Colors.__aliases__) == 1
|
|
402
435
|
assert Colors.__aliases__ == {"ROUGE": Colors.RED}
|
|
403
436
|
assert list(Colors.__aliases__.items()) == [("ROUGE", Colors.RED)]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.5
|
|
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
|