EnhancedEnum
============
``EnhancedEnum`` is a generic, enhanced enumeration class that extends
the functionality of Python’s standard ``Enum`` class. It provides
additional convenience methods for a more user-friendly approach to
handling enumerations. This class utilizes Python’s generics to ensure
type safety and clarity.
Features
--------
- **User-Friendly String Representation**: Override the ``__str__``
method to return the name of the enum member.
- **Listing Members**: Easily list all members of the enumeration.
- **Validation**: Check if a given value is part of the enumeration.
- **Tuple Conversion**: Convert enum members into a tuple.
- **Navigation**: Navigate to the next or previous enum members in
sequence.
- **Creation from String**: Instantiate an enum member from its string
name.
- **Creation from Value**: Instantiate an enum member from its value.
Installation
------------
You can copy the ``EnhancedEnum`` class code into your project, or
import it if you’ve saved it as a separate Python file.
Usage
-----
Below is an example of how you might define and use the
``EnhancedEnum``:
.. code:: python
from enum import Enum, auto
from enhanced_enum import EnhancedEnum
class Color(EnhancedEnum):
RED = auto()
GREEN = auto()
BLUE = auto()
# List all members
print(Color.list_all())
# Validate a member
print(Color.validate(Color.RED))
# Get next and previous members
print(Color.RED.next())
print(Color.RED.previous())
# Create a member from a string
print(Color.from_string('RED'))
# Create a member from a value
print(Color.from_value(1))
Methods
-------
- ``__str__``: Return a more user-friendly string representation of the
enum member.
- ``list_all``: Return a list of all enum members.
- ``validate``: Check if a given value is a valid member of the enum.
- ``as_tuple``: Return the enum members as a tuple.
- ``next``: Return the next enum member in sequence.
- ``previous``: Return the previous enum member in sequence.
- ``from_string``: Return the corresponding enum member for a given
name.
- ``from_value``: Return the corresponding enum member for a given
numeric value.
Contributing
------------
Contributions, issues, and feature requests are welcome. Feel free to
check `issues
page <https://github.com/m-ghiani/ENHANCED_ENUMS/issues>`__ if you want
to contribute.
License
-------
Distributed under the MIT License. See ``LICENSE`` for more information.
Contact
-------
Massimo Ghiani - m.ghiani@gmail.com
Project Link: https://github.com/m-ghiani/ENHANCED_ENUMS
Raw data
{
"_id": null,
"home_page": "https://github.com/m-ghiani/ENHANCED_ENUMS",
"name": "enhanced-enums",
"maintainer": "Massimo Ghiani <m.ghiani@gmail.com>",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "m.ghiani@gmail.com",
"keywords": "enum,enums,enhanced,enhanced enums,enhanced enum,enhanced-enums,enhanced-enum,enhancedenums,enhancedenum,enhancedenum,enhanced_enums,enhanced_enum,enhancedenums,enhancedenum,enhancedenum,enhanced-enums-package,enhanced-enums-package,enhanced_enums_package,enhanced_enums_package,enhanced-enums,enhanced-enums,enhanced_enums,enhanced_enums,enhanced,en",
"author": "Massimo Ghiani",
"author_email": "m.ghiani@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/76/53/889192b23721661a26f0e4bb6124dcd12f4bd448b8ad6a8f80b6ce151d15/enhanced-enums-1.0.2.tar.gz",
"platform": null,
"description": "EnhancedEnum\n============\n\n``EnhancedEnum`` is a generic, enhanced enumeration class that extends\nthe functionality of Python\u2019s standard ``Enum`` class. It provides\nadditional convenience methods for a more user-friendly approach to\nhandling enumerations. This class utilizes Python\u2019s generics to ensure\ntype safety and clarity.\n\nFeatures\n--------\n\n- **User-Friendly String Representation**: Override the ``__str__``\n method to return the name of the enum member.\n- **Listing Members**: Easily list all members of the enumeration.\n- **Validation**: Check if a given value is part of the enumeration.\n- **Tuple Conversion**: Convert enum members into a tuple.\n- **Navigation**: Navigate to the next or previous enum members in\n sequence.\n- **Creation from String**: Instantiate an enum member from its string\n name.\n- **Creation from Value**: Instantiate an enum member from its value.\n\nInstallation\n------------\n\nYou can copy the ``EnhancedEnum`` class code into your project, or\nimport it if you\u2019ve saved it as a separate Python file.\n\nUsage\n-----\n\nBelow is an example of how you might define and use the\n``EnhancedEnum``:\n\n.. code:: python\n\n from enum import Enum, auto\n from enhanced_enum import EnhancedEnum\n\n class Color(EnhancedEnum):\n RED = auto()\n GREEN = auto()\n BLUE = auto()\n\n # List all members\n print(Color.list_all())\n\n # Validate a member\n print(Color.validate(Color.RED))\n\n # Get next and previous members\n print(Color.RED.next())\n print(Color.RED.previous())\n\n # Create a member from a string\n print(Color.from_string('RED'))\n\n # Create a member from a value\n print(Color.from_value(1))\n\nMethods\n-------\n\n- ``__str__``: Return a more user-friendly string representation of the\n enum member.\n- ``list_all``: Return a list of all enum members.\n- ``validate``: Check if a given value is a valid member of the enum.\n- ``as_tuple``: Return the enum members as a tuple.\n- ``next``: Return the next enum member in sequence.\n- ``previous``: Return the previous enum member in sequence.\n- ``from_string``: Return the corresponding enum member for a given\n name.\n- ``from_value``: Return the corresponding enum member for a given\n numeric value.\n\nContributing\n------------\n\nContributions, issues, and feature requests are welcome. Feel free to\ncheck `issues\npage <https://github.com/m-ghiani/ENHANCED_ENUMS/issues>`__ if you want\nto contribute.\n\nLicense\n-------\n\nDistributed under the MIT License. See ``LICENSE`` for more information.\n\nContact\n-------\n\nMassimo Ghiani - m.ghiani@gmail.com\n\nProject Link: https://github.com/m-ghiani/ENHANCED_ENUMS\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A package that provides enhanced enums for Python.",
"version": "1.0.2",
"project_urls": {
"Bug Reports": "https://github.com/m-ghiani/ENHANCED_ENUMS/issues",
"Homepage": "https://github.com/m-ghiani/ENHANCED_ENUMS",
"Source": "https://github.com/m-ghiani/ENHANCED_ENUMS"
},
"split_keywords": [
"enum",
"enums",
"enhanced",
"enhanced enums",
"enhanced enum",
"enhanced-enums",
"enhanced-enum",
"enhancedenums",
"enhancedenum",
"enhancedenum",
"enhanced_enums",
"enhanced_enum",
"enhancedenums",
"enhancedenum",
"enhancedenum",
"enhanced-enums-package",
"enhanced-enums-package",
"enhanced_enums_package",
"enhanced_enums_package",
"enhanced-enums",
"enhanced-enums",
"enhanced_enums",
"enhanced_enums",
"enhanced",
"en"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bdfe5102ea66e714d817a0b6da88c6cf3ba1f023c10a28bbdd95e5c6943fb4a6",
"md5": "89c6804351a3dcc4fecb05726581fae8",
"sha256": "708947bf03a255c9eac937337d35044bec143308f9ce1aa7b86b8c518b0586ea"
},
"downloads": -1,
"filename": "enhanced_enums-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "89c6804351a3dcc4fecb05726581fae8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 5564,
"upload_time": "2024-01-03T03:24:37",
"upload_time_iso_8601": "2024-01-03T03:24:37.465955Z",
"url": "https://files.pythonhosted.org/packages/bd/fe/5102ea66e714d817a0b6da88c6cf3ba1f023c10a28bbdd95e5c6943fb4a6/enhanced_enums-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7653889192b23721661a26f0e4bb6124dcd12f4bd448b8ad6a8f80b6ce151d15",
"md5": "6d1832defd04da3df2e1b28464744800",
"sha256": "8ce258ae05a08676ebdb421646b5229a05a3b3006af335e2126044f77e7889b6"
},
"downloads": -1,
"filename": "enhanced-enums-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "6d1832defd04da3df2e1b28464744800",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 5014,
"upload_time": "2024-01-03T03:24:39",
"upload_time_iso_8601": "2024-01-03T03:24:39.496075Z",
"url": "https://files.pythonhosted.org/packages/76/53/889192b23721661a26f0e4bb6124dcd12f4bd448b8ad6a8f80b6ce151d15/enhanced-enums-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-03 03:24:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "m-ghiani",
"github_project": "ENHANCED_ENUMS",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "enhanced-enums"
}