enumerific 0.0.0__tar.gz → 1.0.0__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.0/PKG-INFO +168 -0
- enumerific-1.0.0/pyproject.toml +58 -0
- enumerific-1.0.0/setup.cfg +4 -0
- enumerific-1.0.0/source/enumerific/version.txt +1 -0
- enumerific-1.0.0/source/enumerific.egg-info/PKG-INFO +168 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/source/enumerific.egg-info/SOURCES.txt +1 -2
- enumerific-0.0.0/PKG-INFO +0 -4
- enumerific-0.0.0/pyproject.toml +0 -23
- enumerific-0.0.0/setup.cfg +0 -39
- enumerific-0.0.0/setup.py +0 -6
- enumerific-0.0.0/source/enumerific.egg-info/PKG-INFO +0 -4
- {enumerific-0.0.0 → enumerific-1.0.0}/LICENSE.md +0 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/README.md +0 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/source/enumerific/__init__.py +0 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/source/enumerific.egg-info/dependency_links.txt +0 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/source/enumerific.egg-info/top_level.txt +0 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/source/enumerific.egg-info/zip-safe +0 -0
- {enumerific-0.0.0 → enumerific-1.0.0}/tests/test_enumerific_library.py +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: enumerific
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Simplifies working with Python enums.
|
|
5
|
+
Author: Daniel Sissman
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright © 2024–2025 Daniel Sissman.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Documentation, https://github.com/bluebinary/enumerific/blob/main/README.md
|
|
28
|
+
Project-URL: Changelog, https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md
|
|
29
|
+
Project-URL: Repository, https://github.com/bluebinary/enumerific
|
|
30
|
+
Project-URL: Issues, https://github.com/bluebinary/enumerific/issues
|
|
31
|
+
Keywords: enum,enumeration,enumerations
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Requires-Python: >=3.9
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
License-File: LICENSE.md
|
|
42
|
+
|
|
43
|
+
# Enumerific Enums
|
|
44
|
+
|
|
45
|
+
The `enumerific` library provides several useful extensions to the Python built-in `enums` library.
|
|
46
|
+
|
|
47
|
+
### Requirements
|
|
48
|
+
|
|
49
|
+
The Enumerific library has been tested with Python 3.9, 3.10, 3.11, 3.12 and 3.13 but may work with some earlier versions such as 3.8, but has not been tested against this version or any earlier. The library is not compatible with Python 2.* or earlier.
|
|
50
|
+
|
|
51
|
+
### Installation
|
|
52
|
+
|
|
53
|
+
The Enumerific library is available from PyPi, so may be added to a project's dependencies via its `requirements.txt` file or similar by referencing the Enumerific library's name, `enumerific`, or the library may be installed directly into your local runtime environment using `pip install` by entering the following command, and following any prompts:
|
|
54
|
+
|
|
55
|
+
$ pip install enumerific
|
|
56
|
+
|
|
57
|
+
### Usage
|
|
58
|
+
|
|
59
|
+
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:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
import enumerific
|
|
63
|
+
|
|
64
|
+
class MyEnum(enumerific.Enum):
|
|
65
|
+
Option1 = "ABC"
|
|
66
|
+
Option2 = "DEF"
|
|
67
|
+
|
|
68
|
+
val = MyEnum.Option1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You can also import the `Enum` class directly from the `enumerific` library and use it directly:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
from enumerific import Enum
|
|
75
|
+
|
|
76
|
+
class MyEnum(Enum):
|
|
77
|
+
Option1 = "ABC"
|
|
78
|
+
...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
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:
|
|
82
|
+
|
|
83
|
+
* `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.
|
|
84
|
+
* `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.
|
|
85
|
+
* `options() -> list[Enum]` – The `options` method provides easy access to the list of the enumeration's available options.
|
|
86
|
+
|
|
87
|
+
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.
|
|
88
|
+
|
|
89
|
+
Some examples of use include the following code samples, where each make use of the example `MyEnum` class, defined as follows:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
from enumerific import Enum
|
|
93
|
+
|
|
94
|
+
class MyEnum(Enum):
|
|
95
|
+
Option1 = "ABC"
|
|
96
|
+
Option2 = "DEF"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Example 1: Reconciling a Value
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
# Given a string value in this case
|
|
103
|
+
value = "ABC"
|
|
104
|
+
|
|
105
|
+
# Reconcile it to the associated enumeration option
|
|
106
|
+
value = MyEnum.reconcile(value)
|
|
107
|
+
|
|
108
|
+
assert value == MyEnum.Option1 # asserts successfully
|
|
109
|
+
assert value is MyEnum.Option1 # asserts successfully as enums are singletons
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Example 2: Reconciling an Enumeration Option Name
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
# Given a string value in this case
|
|
116
|
+
value = "Option1"
|
|
117
|
+
|
|
118
|
+
# Reconcile it to the associated enumeration option
|
|
119
|
+
value = MyEnum.reconcile(value)
|
|
120
|
+
|
|
121
|
+
assert value == MyEnum.Option1 # asserts successfully
|
|
122
|
+
assert value is MyEnum.Option1 # asserts successfully as enums are singletons
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Example 3: Validating a Value
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
# The value can be an enumeration option's name, its value, or the enumeration option
|
|
129
|
+
value = "Option1"
|
|
130
|
+
value = "ABC"
|
|
131
|
+
value = MyEnum.Option1
|
|
132
|
+
|
|
133
|
+
if MyEnum.validate(value) is True:
|
|
134
|
+
# do something if the value could be validated
|
|
135
|
+
else:
|
|
136
|
+
# do something else if the value could not be validated
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Example 4: Iterating Over Enumeration Options
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
for option in MyEnum.options():
|
|
143
|
+
# do something with each option
|
|
144
|
+
print(option.name, option.value)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Unit Tests
|
|
148
|
+
|
|
149
|
+
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`.
|
|
150
|
+
|
|
151
|
+
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:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
$ docker compose build
|
|
155
|
+
$ docker compose run tests
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
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:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
$ docker compose run tests -vv
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
See the documentation for [PyTest](https://docs.pytest.org/en/latest/) regarding available optional command line arguments.
|
|
165
|
+
|
|
166
|
+
### Copyright & License Information
|
|
167
|
+
|
|
168
|
+
Copyright © 2024–2025 Daniel Sissman; Licensed under the MIT License.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "enumerific"
|
|
3
|
+
description = "Simplifies working with Python enums."
|
|
4
|
+
readme = {file = "README.md", content-type = "text/markdown"}
|
|
5
|
+
keywords = ["enum", "enumeration", "enumerations"]
|
|
6
|
+
authors = [{name = "Daniel Sissman"}]
|
|
7
|
+
license = {file = "LICENSE.md", content-type = "text/markdown"}
|
|
8
|
+
classifiers = [
|
|
9
|
+
"License :: OSI Approved :: MIT License",
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"Programming Language :: Python :: 3.9",
|
|
12
|
+
"Programming Language :: Python :: 3.10",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
]
|
|
17
|
+
requires-python = ">=3.9"
|
|
18
|
+
dynamic = ["version"]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Documentation = "https://github.com/bluebinary/enumerific/blob/main/README.md"
|
|
22
|
+
Changelog = "https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md"
|
|
23
|
+
Repository = "https://github.com/bluebinary/enumerific"
|
|
24
|
+
Issues = "https://github.com/bluebinary/enumerific/issues"
|
|
25
|
+
|
|
26
|
+
[build-system]
|
|
27
|
+
requires = ["setuptools", "wheel"]
|
|
28
|
+
build-backend = "setuptools.build_meta"
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.dynamic]
|
|
31
|
+
version = {file = "source/enumerific/version.txt"}
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
zip-safe = true
|
|
35
|
+
include-package-data = true
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages]
|
|
38
|
+
find = {where = ["source"]}
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
minversion = "6.0"
|
|
42
|
+
addopts = "-ra -q"
|
|
43
|
+
testpaths = [
|
|
44
|
+
"tests"
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.black]
|
|
48
|
+
line-length = 88
|
|
49
|
+
target-version = ['py310']
|
|
50
|
+
include = '\.pyi?$'
|
|
51
|
+
extend-exclude = '''
|
|
52
|
+
/(
|
|
53
|
+
# The following are specific to Black, you probably don't want those.
|
|
54
|
+
| blib2to3
|
|
55
|
+
| tests/data
|
|
56
|
+
| profiling
|
|
57
|
+
)/
|
|
58
|
+
'''
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: enumerific
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Simplifies working with Python enums.
|
|
5
|
+
Author: Daniel Sissman
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright © 2024–2025 Daniel Sissman.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Documentation, https://github.com/bluebinary/enumerific/blob/main/README.md
|
|
28
|
+
Project-URL: Changelog, https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md
|
|
29
|
+
Project-URL: Repository, https://github.com/bluebinary/enumerific
|
|
30
|
+
Project-URL: Issues, https://github.com/bluebinary/enumerific/issues
|
|
31
|
+
Keywords: enum,enumeration,enumerations
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Requires-Python: >=3.9
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
License-File: LICENSE.md
|
|
42
|
+
|
|
43
|
+
# Enumerific Enums
|
|
44
|
+
|
|
45
|
+
The `enumerific` library provides several useful extensions to the Python built-in `enums` library.
|
|
46
|
+
|
|
47
|
+
### Requirements
|
|
48
|
+
|
|
49
|
+
The Enumerific library has been tested with Python 3.9, 3.10, 3.11, 3.12 and 3.13 but may work with some earlier versions such as 3.8, but has not been tested against this version or any earlier. The library is not compatible with Python 2.* or earlier.
|
|
50
|
+
|
|
51
|
+
### Installation
|
|
52
|
+
|
|
53
|
+
The Enumerific library is available from PyPi, so may be added to a project's dependencies via its `requirements.txt` file or similar by referencing the Enumerific library's name, `enumerific`, or the library may be installed directly into your local runtime environment using `pip install` by entering the following command, and following any prompts:
|
|
54
|
+
|
|
55
|
+
$ pip install enumerific
|
|
56
|
+
|
|
57
|
+
### Usage
|
|
58
|
+
|
|
59
|
+
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:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
import enumerific
|
|
63
|
+
|
|
64
|
+
class MyEnum(enumerific.Enum):
|
|
65
|
+
Option1 = "ABC"
|
|
66
|
+
Option2 = "DEF"
|
|
67
|
+
|
|
68
|
+
val = MyEnum.Option1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You can also import the `Enum` class directly from the `enumerific` library and use it directly:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
from enumerific import Enum
|
|
75
|
+
|
|
76
|
+
class MyEnum(Enum):
|
|
77
|
+
Option1 = "ABC"
|
|
78
|
+
...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
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:
|
|
82
|
+
|
|
83
|
+
* `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.
|
|
84
|
+
* `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.
|
|
85
|
+
* `options() -> list[Enum]` – The `options` method provides easy access to the list of the enumeration's available options.
|
|
86
|
+
|
|
87
|
+
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.
|
|
88
|
+
|
|
89
|
+
Some examples of use include the following code samples, where each make use of the example `MyEnum` class, defined as follows:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
from enumerific import Enum
|
|
93
|
+
|
|
94
|
+
class MyEnum(Enum):
|
|
95
|
+
Option1 = "ABC"
|
|
96
|
+
Option2 = "DEF"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Example 1: Reconciling a Value
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
# Given a string value in this case
|
|
103
|
+
value = "ABC"
|
|
104
|
+
|
|
105
|
+
# Reconcile it to the associated enumeration option
|
|
106
|
+
value = MyEnum.reconcile(value)
|
|
107
|
+
|
|
108
|
+
assert value == MyEnum.Option1 # asserts successfully
|
|
109
|
+
assert value is MyEnum.Option1 # asserts successfully as enums are singletons
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Example 2: Reconciling an Enumeration Option Name
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
# Given a string value in this case
|
|
116
|
+
value = "Option1"
|
|
117
|
+
|
|
118
|
+
# Reconcile it to the associated enumeration option
|
|
119
|
+
value = MyEnum.reconcile(value)
|
|
120
|
+
|
|
121
|
+
assert value == MyEnum.Option1 # asserts successfully
|
|
122
|
+
assert value is MyEnum.Option1 # asserts successfully as enums are singletons
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Example 3: Validating a Value
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
# The value can be an enumeration option's name, its value, or the enumeration option
|
|
129
|
+
value = "Option1"
|
|
130
|
+
value = "ABC"
|
|
131
|
+
value = MyEnum.Option1
|
|
132
|
+
|
|
133
|
+
if MyEnum.validate(value) is True:
|
|
134
|
+
# do something if the value could be validated
|
|
135
|
+
else:
|
|
136
|
+
# do something else if the value could not be validated
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Example 4: Iterating Over Enumeration Options
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
for option in MyEnum.options():
|
|
143
|
+
# do something with each option
|
|
144
|
+
print(option.name, option.value)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Unit Tests
|
|
148
|
+
|
|
149
|
+
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`.
|
|
150
|
+
|
|
151
|
+
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:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
$ docker compose build
|
|
155
|
+
$ docker compose run tests
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
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:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
$ docker compose run tests -vv
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
See the documentation for [PyTest](https://docs.pytest.org/en/latest/) regarding available optional command line arguments.
|
|
165
|
+
|
|
166
|
+
### Copyright & License Information
|
|
167
|
+
|
|
168
|
+
Copyright © 2024–2025 Daniel Sissman; Licensed under the MIT License.
|
enumerific-0.0.0/PKG-INFO
DELETED
enumerific-0.0.0/pyproject.toml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[tool.pytest.ini_options]
|
|
6
|
-
minversion = "6.0"
|
|
7
|
-
addopts = "-ra -q"
|
|
8
|
-
testpaths = [
|
|
9
|
-
"tests"
|
|
10
|
-
]
|
|
11
|
-
|
|
12
|
-
[tool.black]
|
|
13
|
-
line-length = 88
|
|
14
|
-
target-version = ['py310']
|
|
15
|
-
include = '\.pyi?$'
|
|
16
|
-
extend-exclude = '''
|
|
17
|
-
/(
|
|
18
|
-
# The following are specific to Black, you probably don't want those.
|
|
19
|
-
| blib2to3
|
|
20
|
-
| tests/data
|
|
21
|
-
| profiling
|
|
22
|
-
)/
|
|
23
|
-
'''
|
enumerific-0.0.0/setup.cfg
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = enumerific
|
|
3
|
-
version = file: source/enumerific/version.txt
|
|
4
|
-
description = Simplifies working with Python enums.
|
|
5
|
-
long_description = file: README.md, CHANGELOG.md
|
|
6
|
-
long_description_content_type = text/markdown
|
|
7
|
-
keywords = enum, enumeration, enumerations
|
|
8
|
-
author = Daniel Sissman
|
|
9
|
-
license = MIT
|
|
10
|
-
classifiers =
|
|
11
|
-
License :: OSI Approved :: MIT License
|
|
12
|
-
Programming Language :: Python :: 3
|
|
13
|
-
Programming Language :: Python :: 3.9
|
|
14
|
-
Programming Language :: Python :: 3.10
|
|
15
|
-
Programming Language :: Python :: 3.11
|
|
16
|
-
Programming Language :: Python :: 3.12
|
|
17
|
-
requires-python = ">=3.9"
|
|
18
|
-
|
|
19
|
-
[project.urls]
|
|
20
|
-
Documentation = "https://github.com/bluebinary/enumerific/blob/main/README.md"
|
|
21
|
-
Changelog = "https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md"
|
|
22
|
-
Repository = "https://github.com/bluebinary/enumerific"
|
|
23
|
-
Issues = "https://github.com/bluebinary/enumerific/issues"
|
|
24
|
-
|
|
25
|
-
[options]
|
|
26
|
-
zip_safe = True
|
|
27
|
-
include_package_data = True
|
|
28
|
-
package_dir =
|
|
29
|
-
=source
|
|
30
|
-
packages = find:
|
|
31
|
-
install_requires =
|
|
32
|
-
|
|
33
|
-
[options.packages.find]
|
|
34
|
-
where = source
|
|
35
|
-
|
|
36
|
-
[egg_info]
|
|
37
|
-
tag_build =
|
|
38
|
-
tag_date = 0
|
|
39
|
-
|
enumerific-0.0.0/setup.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|