enumerific 1.0.1__py3-none-any.whl → 1.0.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.
@@ -0,0 +1,12 @@
1
+ enumerific/__init__.py,sha256=Qe_3I0e4a_eA4quVKz05eufYtX4soq1Ku-pnXiQxxAQ,429
2
+ enumerific/exceptions.py,sha256=u0-efY2ufY__DZPs56L_SblvhnFZjUb2AcMjL_AxtKw,293
3
+ enumerific/extensible.py,sha256=YSYyVi8oUzQuNUBmdJcqtMd-Fs15cjvMqEMHi2F4JcA,80452
4
+ enumerific/logging.py,sha256=zz1Phnot1BFWMoxwvZ0FlZDsiYZZYhz-_S4IzgPYc40,97
5
+ enumerific/standard.py,sha256=xQhhwlcYZ6-8DmgscbV38g2Ol5Z8_vvBwonz-Ww0I40,3254
6
+ enumerific/version.txt,sha256=v-wuNFg62n5q8stzmT-3Wj9xR6bJQ-X_X1xClPxXe5A,5
7
+ enumerific-1.0.2.dist-info/licenses/LICENSE.md,sha256=j1XidOCGUhPx7CyXA31uC0XGKDRnvUcZpMp161qHI6g,1077
8
+ enumerific-1.0.2.dist-info/METADATA,sha256=F632r_SiMpT5u4nskU8K_c4fDDxDbaOgrIoiGYZfNmA,30755
9
+ enumerific-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ enumerific-1.0.2.dist-info/top_level.txt,sha256=hyemsMgPYZgSx71XHmFRF-gvc_2Y4rDAESR8e0hbYHU,11
11
+ enumerific-1.0.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
+ enumerific-1.0.2.dist-info/RECORD,,
@@ -1,198 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: enumerific
3
- Version: 1.0.1
4
- Summary: Simplifies working with Python enums.
5
- Author: Daniel Sissman
6
- License-Expression: MIT
7
- Project-URL: documentation, https://github.com/bluebinary/enumerific/blob/main/README.md
8
- Project-URL: changelog, https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md
9
- Project-URL: repository, https://github.com/bluebinary/enumerific
10
- Project-URL: issues, https://github.com/bluebinary/enumerific/issues
11
- Project-URL: homepage, https://github.com/bluebinary/enumerific
12
- Keywords: enum,enumeration,enumerations
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Classifier: Programming Language :: Python :: 3.13
18
- Requires-Python: >=3.10
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE.md
21
- Provides-Extra: development
22
- Requires-Dist: black==24.10.*; extra == "development"
23
- Requires-Dist: pytest==8.3.*; extra == "development"
24
- Requires-Dist: pytest-codeblocks==0.17.0; extra == "development"
25
- Provides-Extra: distribution
26
- Requires-Dist: build; extra == "distribution"
27
- Requires-Dist: twine; extra == "distribution"
28
- Requires-Dist: wheel; extra == "distribution"
29
- Dynamic: license-file
30
-
31
- # Enumerific Enums
32
-
33
- The `enumerific` library provides several useful extensions to the Python built-in `enums` library.
34
-
35
- ### Requirements
36
-
37
- The Enumerific library has been tested with Python 3.10, 3.11, 3.12 and 3.13, and is not
38
- compatible with Python 3.9 or earlier.
39
-
40
- ### Installation
41
-
42
- Enumerific is available from the PyPI, so may be added to a project's dependencies via
43
- its `requirements.txt` file or similar by referencing the library's name, `enumerific`,
44
- or the library may be installed directly into your local runtime environment using `pip`
45
- by entering the following command, and following any prompts:
46
-
47
- $ pip install enumerific
48
-
49
- ### Usage
50
-
51
- To use the Enumerific library, simply import the library and use it like you would the built-in `enum` library as a drop-in replacement:
52
-
53
- ```python
54
- from enumerific import Enum
55
-
56
- class MyEnum(Enum):
57
- Option1 = "ABC"
58
- Option2 = "DEF"
59
-
60
- val = MyEnum.Option1
61
- ```
62
-
63
- Alternatively, to make use of the extra functionality for the standard library's `Enum`
64
- class, import the `Enum` class from the Enumerific library:
65
-
66
- ```python
67
- from enumerific import Enum
68
-
69
- class MyEnum(Enum):
70
- Option1 = "ABC"
71
- Option2 = "DEF"
72
-
73
- val = MyEnum.Option1
74
- ```
75
-
76
- You can also import the `Enum` class directly from the `enumerific` library and use it directly:
77
-
78
- ```python
79
- from enumerific import Enum
80
-
81
- class MyEnum(Enum):
82
- Option1 = "ABC"
83
- ```
84
-
85
- The Enumerific library's own `Enum` class is a subclass of the built-in `enum.Enum` class, so all of the built-in functionality of `enum.Enum` is available, as well as several additional class methods:
86
-
87
- * `reconcile(value: object, default: Enum = None, raises: bool = False) -> Enum` – The `reconcile` method allows for an enumeration's value or an enumeration option's name to be reconciled against a matching enumeration option. If the provided value can be matched against one of the enumeration's available options, that option will be returned, otherwise there are two possible behaviours: if the `raises` keyword argument has been set to or left as `False` (its default), the value assigned to the `default` keyword argument will be returned, which may be `None` if no default value has been specified; if the `raises` argument has been set to `True` an `EnumValueError` exception will be raised as an alert that the provided value could not be matched. One can also provide an enumeration option as the input value to the `reconcile` method, and these will be validated and returned as-is.
88
- * `validate(value: object) -> bool` – The `validate` method takes the same range of input values as the `reconcile` method, and returns `True` when the provided value can be reconciled against an enumeration option, or `False` otherwise.
89
- * `options() -> list[Enum]` – The `options` method provides easy access to the list of the enumeration's available options.
90
-
91
- The benefits of being able to validate and reconcile various input values against an enumeration, include allowing for a controlled vocabulary of options to be checked against, and the ability to convert enumeration values into their corresponding enumeration option. This can be especially useful when working with input data where you need to convert those values to their corresponding enumeration options, and to be able to do so without maintaining boilerplate code to perform the matching and assignment.
92
-
93
- Some examples of use include the following code samples, where each make use of the example `MyEnum` class, defined as follows:
94
-
95
- ```python
96
- from enumerific import Enum
97
-
98
- class MyEnum(Enum):
99
- Option1 = "ABC"
100
- Option2 = "DEF"
101
- ```
102
-
103
- #### Example 1: Reconciling a Value
104
-
105
- ```python
106
- from enumerific import Enum
107
-
108
- class MyEnum(Enum):
109
- Option1 = "ABC"
110
- Option2 = "DEF"
111
-
112
- # Given a string value in this case
113
- value = "ABC"
114
-
115
- # Reconcile it to the associated enumeration option
116
- value = MyEnum.reconcile(value)
117
-
118
- assert value == MyEnum.Option1 # asserts successfully
119
- assert value is MyEnum.Option1 # asserts successfully as enums are singletons
120
- ```
121
-
122
- #### Example 2: Reconciling an Enumeration Option Name
123
-
124
- ```python
125
- from enumerific import Enum
126
-
127
- class MyEnum(Enum):
128
- Option1 = "ABC"
129
- Option2 = "DEF"
130
-
131
- # Given a string value in this case
132
- value = "Option1"
133
-
134
- # Reconcile it to the associated enumeration option
135
- value = MyEnum.reconcile(value)
136
-
137
- assert value == MyEnum.Option1 # asserts successfully
138
- assert value is MyEnum.Option1 # asserts successfully as enums are singletons
139
- ```
140
-
141
- #### Example 3: Validating a Value
142
-
143
- ```python
144
- from enumerific import Enum
145
-
146
- class MyEnum(Enum):
147
- Option1 = "ABC"
148
- Option2 = "DEF"
149
-
150
- # The value can be an enumeration option's name, its value, or the enumeration option
151
- value = "Option1"
152
- value = "ABC"
153
- value = MyEnum.Option1
154
-
155
- if MyEnum.validate(value) is True:
156
- # do something if the value could be validated
157
- pass
158
- else:
159
- # do something else if the value could not be validated
160
- pass
161
- ```
162
-
163
- #### Example 4: Iterating Over Enumeration Options
164
-
165
- ```python
166
- from enumerific import Enum
167
-
168
- class MyEnum(Enum):
169
- Option1 = "ABC"
170
- Option2 = "DEF"
171
-
172
- for option in MyEnum.options():
173
- # do something with each option
174
- print(option.name, option.value)
175
- ```
176
-
177
- ### Unit Tests
178
-
179
- The Enumerific library includes a suite of comprehensive unit tests which ensure that the library functionality operates as expected. The unit tests were developed with and are run via `pytest`.
180
-
181
- To ensure that the unit tests are run within a predictable runtime environment where all of the necessary dependencies are available, a [Docker](https://www.docker.com) image is created within which the tests are run. To run the unit tests, ensure Docker and Docker Compose is [installed](https://docs.docker.com/engine/install/), and perform the following commands, which will build the Docker image via `docker compose build` and then run the tests via `docker compose run` – the output of running the tests will be displayed:
182
-
183
- ```shell
184
- $ docker compose build
185
- $ docker compose run tests
186
- ```
187
-
188
- To run the unit tests with optional command line arguments being passed to `pytest`, append the relevant arguments to the `docker compose run tests` command, as follows, for example passing `-vv` to enable verbose output:
189
-
190
- ```shell
191
- $ docker compose run tests -vv
192
- ```
193
-
194
- See the documentation for [PyTest](https://docs.pytest.org/en/latest/) regarding available optional command line arguments.
195
-
196
- ### Copyright & License Information
197
-
198
- Copyright © 2024–2025 Daniel Sissman; licensed under the MIT License.
@@ -1,12 +0,0 @@
1
- enumerific/__init__.py,sha256=YUGW74YNx4ZNtjmtRAJS8zTjn9z0zM1QCAa985kTAjk,419
2
- enumerific/exceptions.py,sha256=u0-efY2ufY__DZPs56L_SblvhnFZjUb2AcMjL_AxtKw,293
3
- enumerific/extensible.py,sha256=QCud2izNd5EEvjJWM2GO_U7QHiuDDkGU-5M7s3igpaY,68493
4
- enumerific/logging.py,sha256=zz1Phnot1BFWMoxwvZ0FlZDsiYZZYhz-_S4IzgPYc40,97
5
- enumerific/standard.py,sha256=xQhhwlcYZ6-8DmgscbV38g2Ol5Z8_vvBwonz-Ww0I40,3254
6
- enumerific/version.txt,sha256=1R5uyUBYVUqEVYpbQC7m71_fVFXjXJAv7aYc2odSlDo,5
7
- enumerific-1.0.1.dist-info/licenses/LICENSE.md,sha256=j1XidOCGUhPx7CyXA31uC0XGKDRnvUcZpMp161qHI6g,1077
8
- enumerific-1.0.1.dist-info/METADATA,sha256=_fsZpLq6PjDyaBNRMToy8bOJqCbgwAOF3j6oBoHde3Q,7721
9
- enumerific-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- enumerific-1.0.1.dist-info/top_level.txt,sha256=hyemsMgPYZgSx71XHmFRF-gvc_2Y4rDAESR8e0hbYHU,11
11
- enumerific-1.0.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
- enumerific-1.0.1.dist-info/RECORD,,