========
richenum
========
.. image:: https://github.com/hearsaycorp/richenum/actions/workflows/python-version-tests.yml/badge.svg
:alt: Build Status
.. image:: https://img.shields.io/pypi/v/richenum.svg
:alt: Latest PyPI Version
:target: https://pypi.python.org/pypi/richenum/
.. image:: https://img.shields.io/pypi/pyversions/richenum.svg
:alt: Python versions
:target: https://pypi.org/project/richenum/
.. image:: https://img.shields.io/pypi/dm/richenum.svg
:alt: Pypi Downloads
:target: https://pypi.org/project/richenum/
=====
About
=====
A enum library for Python.
enum
A simple enum implementation that maps a "variable" to a constant.
RichEnum
An enum implementation that offers more functionality than a basic enum, hence the
name: RichEnum. Provided functionality include specifying a canonical name and a display name.
The canonical name should be used if you need to do a lookup or reference in your code.
The display name should be used if you need to display text to a user.
OrderedRichEnum
Exactly like RichEnum but also has an index specified for each enum value. Also, iteration over
an OrderedRichEnum will be sorted (ascending) by the enum value's index.
-----
Links
-----
| `GitHub <https://github.com/hearsaycorp/richenum>`__
| `PyPi <https://pypi.python.org/pypi/richenum/>`__
============
Installation
============
.. code:: bash
$ pip install richenum
=============
Example Usage
=============
----
enum
----
.. code:: python
>>> from richenum import enum
>>> MY_ENUM = enum(FOO=1, BAR=2)
>>> MY_ENUM.FOO
1
>>> MY_ENUM.BAR
2
--------
RichEnum
--------
.. code:: python
>>> from richenum import RichEnum, RichEnumValue
>>> class MyRichEnum(RichEnum):
... FOO = RichEnumValue(canonical_name="foo", display_name="Foo")
... BAR = RichEnumValue(canonical_name="bar", display_name="Bar")
...
>>> MyRichEnum.FOO
RichEnumValue - canonical_name: 'foo' display_name: 'Foo'
>>> MyRichEnum.from_canonical("foo")
RichEnumValue - canonical_name: 'foo' display_name: 'Foo'
---------------
OrderedRichEnum
---------------
.. code:: python
>>> from richenum import OrderedRichEnum, OrderedRichEnumValue
>>> class MyOrderedRichEnum(OrderedRichEnum):
... FOO = OrderedRichEnumValue(index=1, canonical_name="foo", display_name="Foo")
... BAR = OrderedRichEnumValue(index=2, canonical_name="bar", display_name="Bar")
...
>>> MyOrderedRichEnum.FOO
OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'
>>> MyOrderedRichEnum.from_canonical("foo")
OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'
>>> MyOrderedRichEnum.from_index(1)
OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'
================
Related Packages
================
django-richenum
Makes RichEnum and OrderedRichEnum available in as model fields and form fields in Django.
| `GitHub <https://github.com/hearsaycorp/django-richenum>`__
| `PyPi <https://pypi.python.org/pypi/django-richenum/>`__
enum
Starting with Python 3.4, there is a standard library for enumerations.
This class has a similar API, but is not directly compatible with that
class.
============
Contributing
============
#. Fork the repo from `GitHub <https://github.com/hearsaycorp/richenum>`__.
#. Make your changes.
#. Add unittests for your changes.
#. Run `pep8 <https://pypi.python.org/pypi/pep8>`_, `pyflakes <https://pypi.python.org/pypi/pyflakes>`_, and `pylint <https://pypi.python.org/pypi/pyflakes>`_ to make sure your changes follow the Python style guide and doesn't have any errors.
#. Add yourself to the AUTHORS file (in alphabetical order).
#. Send a pull request from your fork to the main repo.
=========
Changelog
=========
------------------
2.0.2 (2024-10-01)
------------------
- Remove unavailable link for blog post from README.rst
------------------
2.0.1 (2024-06-06)
------------------
- Fix README.rst
------------------
2.0.0 (2024-06-04)
------------------
- Remove six
- Remove python 3.7 support
- Add python 3.9 and 3.10 support
- Remove tox.ini
------------------
1.2.1 (2016-09-16)
------------------
- ``EnumLookupError`` class now inherits from built-in ``LookupError``.
------------------
1.2.0 (2016-04-15)
------------------
- added simple ``LookupError`` members that are thrown when
``RichEnum.lookup`` is called for a nonexistent attr/val pair.
Users can choose to catch either the specific ``LookupError`` or
continue to catch ``EnumLookupError``.
------------------
1.1.0 (2014-04-17)
------------------
- support for Python 3 and PyPy
------------------
1.0.4 (2013-12-03)
------------------
- Better unicode handling in ``__str__``, ``__unicode__``, and
``__repr__`` magic methods.
------------------
1.0.3 (2013-12-03)
------------------
- Stop throwing warnings.
------------------
1.0.2 (2013-11-05)
------------------
- Suppress warnings from mismatched type comparisons when generated
in RichEnum.lookup.
------------------
1.0.1 (2013-09-20)
------------------
- Raise warnings when comparing enum values to other types, but not
when checking membership or comparing to None.
------------------
1.0.0 (2013-08-16)
------------------
- Initial public release.
Developed and maintained by `Hearsay Social, Inc.
<http://hearsaysocial.com>`_.
Contributors
============
| `Adam DePue <http://github.com/adepue>`_
| `Aron radics <http://github.com/radaron>`_
| `Akshay Shah <http://github.com/akshayjshah>`_
| `Dale Hui <http://github.com/dhui>`_
| `Istvan Nemeth <http://github.com/archiezgg>`_
| `Robert MacCloy <http://github.com/rbm>`_
| `Sam Vilain <http://github.com/samv>`_
| `Wyatt Paul <http://github.com/wyguy444>`_
Raw data
{
"_id": null,
"home_page": "https://github.com/hearsaycorp/richenum",
"name": "richenum",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python enum richenum",
"author": "Hearsay Social",
"author_email": "opensource@hearsaysocial.com",
"download_url": "https://files.pythonhosted.org/packages/4e/6c/89e7e2afd05754dd2ed695a4da97ab033e642d17e04449623f74de07ab24/richenum-2.0.2.tar.gz",
"platform": null,
"description": "========\nrichenum\n========\n.. image:: https://github.com/hearsaycorp/richenum/actions/workflows/python-version-tests.yml/badge.svg\n :alt: Build Status\n\n.. image:: https://img.shields.io/pypi/v/richenum.svg\n :alt: Latest PyPI Version\n :target: https://pypi.python.org/pypi/richenum/\n\n.. image:: https://img.shields.io/pypi/pyversions/richenum.svg\n :alt: Python versions\n :target: https://pypi.org/project/richenum/\n\n.. image:: https://img.shields.io/pypi/dm/richenum.svg\n :alt: Pypi Downloads\n :target: https://pypi.org/project/richenum/\n\n=====\nAbout\n=====\nA enum library for Python.\n\nenum\n A simple enum implementation that maps a \"variable\" to a constant.\nRichEnum\n An enum implementation that offers more functionality than a basic enum, hence the\n name: RichEnum. Provided functionality include specifying a canonical name and a display name.\n The canonical name should be used if you need to do a lookup or reference in your code.\n The display name should be used if you need to display text to a user.\nOrderedRichEnum\n Exactly like RichEnum but also has an index specified for each enum value. Also, iteration over\n an OrderedRichEnum will be sorted (ascending) by the enum value's index.\n\n-----\nLinks\n-----\n| `GitHub <https://github.com/hearsaycorp/richenum>`__\n| `PyPi <https://pypi.python.org/pypi/richenum/>`__\n\n============\nInstallation\n============\n.. code:: bash\n\n $ pip install richenum\n\n=============\nExample Usage\n=============\n----\nenum\n----\n.. code:: python\n\n >>> from richenum import enum\n >>> MY_ENUM = enum(FOO=1, BAR=2)\n >>> MY_ENUM.FOO\n 1\n >>> MY_ENUM.BAR\n 2\n\n--------\nRichEnum\n--------\n.. code:: python\n\n >>> from richenum import RichEnum, RichEnumValue\n >>> class MyRichEnum(RichEnum):\n ... FOO = RichEnumValue(canonical_name=\"foo\", display_name=\"Foo\")\n ... BAR = RichEnumValue(canonical_name=\"bar\", display_name=\"Bar\")\n ...\n >>> MyRichEnum.FOO\n RichEnumValue - canonical_name: 'foo' display_name: 'Foo'\n >>> MyRichEnum.from_canonical(\"foo\")\n RichEnumValue - canonical_name: 'foo' display_name: 'Foo'\n\n\n---------------\nOrderedRichEnum\n---------------\n.. code:: python\n\n >>> from richenum import OrderedRichEnum, OrderedRichEnumValue\n >>> class MyOrderedRichEnum(OrderedRichEnum):\n ... FOO = OrderedRichEnumValue(index=1, canonical_name=\"foo\", display_name=\"Foo\")\n ... BAR = OrderedRichEnumValue(index=2, canonical_name=\"bar\", display_name=\"Bar\")\n ...\n >>> MyOrderedRichEnum.FOO\n OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'\n >>> MyOrderedRichEnum.from_canonical(\"foo\")\n OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'\n >>> MyOrderedRichEnum.from_index(1)\n OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'\n\n\n================\nRelated Packages\n================\n\ndjango-richenum\n Makes RichEnum and OrderedRichEnum available in as model fields and form fields in Django.\n\n | `GitHub <https://github.com/hearsaycorp/django-richenum>`__\n\n | `PyPi <https://pypi.python.org/pypi/django-richenum/>`__\n\nenum\n Starting with Python 3.4, there is a standard library for enumerations.\n This class has a similar API, but is not directly compatible with that\n class.\n\n\n============\nContributing\n============\n\n#. Fork the repo from `GitHub <https://github.com/hearsaycorp/richenum>`__.\n#. Make your changes.\n#. Add unittests for your changes.\n#. Run `pep8 <https://pypi.python.org/pypi/pep8>`_, `pyflakes <https://pypi.python.org/pypi/pyflakes>`_, and `pylint <https://pypi.python.org/pypi/pyflakes>`_ to make sure your changes follow the Python style guide and doesn't have any errors.\n#. Add yourself to the AUTHORS file (in alphabetical order).\n#. Send a pull request from your fork to the main repo.\n\n\n=========\nChangelog\n=========\n------------------\n2.0.2 (2024-10-01)\n------------------\n - Remove unavailable link for blog post from README.rst\n\n------------------\n2.0.1 (2024-06-06)\n------------------\n - Fix README.rst\n\n------------------\n2.0.0 (2024-06-04)\n------------------\n - Remove six\n - Remove python 3.7 support\n - Add python 3.9 and 3.10 support\n - Remove tox.ini\n\n------------------\n1.2.1 (2016-09-16)\n------------------\n - ``EnumLookupError`` class now inherits from built-in ``LookupError``.\n\n------------------\n1.2.0 (2016-04-15)\n------------------\n - added simple ``LookupError`` members that are thrown when\n ``RichEnum.lookup`` is called for a nonexistent attr/val pair.\n Users can choose to catch either the specific ``LookupError`` or\n continue to catch ``EnumLookupError``.\n\n------------------\n1.1.0 (2014-04-17)\n------------------\n - support for Python 3 and PyPy\n\n------------------\n1.0.4 (2013-12-03)\n------------------\n - Better unicode handling in ``__str__``, ``__unicode__``, and\n ``__repr__`` magic methods.\n\n------------------\n1.0.3 (2013-12-03)\n------------------\n - Stop throwing warnings.\n\n------------------\n1.0.2 (2013-11-05)\n------------------\n - Suppress warnings from mismatched type comparisons when generated\n in RichEnum.lookup.\n\n------------------\n1.0.1 (2013-09-20)\n------------------\n - Raise warnings when comparing enum values to other types, but not\n when checking membership or comparing to None.\n\n------------------\n1.0.0 (2013-08-16)\n------------------\n - Initial public release.\n\n\nDeveloped and maintained by `Hearsay Social, Inc.\n<http://hearsaysocial.com>`_.\n\nContributors\n============\n| `Adam DePue <http://github.com/adepue>`_\n| `Aron radics <http://github.com/radaron>`_\n| `Akshay Shah <http://github.com/akshayjshah>`_\n| `Dale Hui <http://github.com/dhui>`_\n| `Istvan Nemeth <http://github.com/archiezgg>`_\n| `Robert MacCloy <http://github.com/rbm>`_\n| `Sam Vilain <http://github.com/samv>`_\n| `Wyatt Paul <http://github.com/wyguy444>`_\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Enum library for python.",
"version": "2.0.2",
"project_urls": {
"Homepage": "https://github.com/hearsaycorp/richenum"
},
"split_keywords": [
"python",
"enum",
"richenum"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f355b50e4b2b673476135cc2098edc37c36cc40eb7a2858de0a97a159571da2a",
"md5": "50ebc76bc8e7d6286b3dee7bc30f7ff3",
"sha256": "60802c5d35713dc6bb767c62bb27bc4df09ac094c5b812e2cf9955041156eccf"
},
"downloads": -1,
"filename": "richenum-2.0.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "50ebc76bc8e7d6286b3dee7bc30f7ff3",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 8144,
"upload_time": "2024-10-01T12:19:40",
"upload_time_iso_8601": "2024-10-01T12:19:40.072278Z",
"url": "https://files.pythonhosted.org/packages/f3/55/b50e4b2b673476135cc2098edc37c36cc40eb7a2858de0a97a159571da2a/richenum-2.0.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4e6c89e7e2afd05754dd2ed695a4da97ab033e642d17e04449623f74de07ab24",
"md5": "7de8751ada0a04ff68f7b4dc902833ce",
"sha256": "286b83be8779b6eac6c3586d904241321eb2f7b9b5c98a1e91bf42e8b3a28b85"
},
"downloads": -1,
"filename": "richenum-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "7de8751ada0a04ff68f7b4dc902833ce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9258,
"upload_time": "2024-10-01T12:19:41",
"upload_time_iso_8601": "2024-10-01T12:19:41.554437Z",
"url": "https://files.pythonhosted.org/packages/4e/6c/89e7e2afd05754dd2ed695a4da97ab033e642d17e04449623f74de07ab24/richenum-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-01 12:19:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hearsaycorp",
"github_project": "richenum",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "richenum"
}