{ "info": { "author": "Michael T Bacon", "author_email": "michael@sorreltree.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development" ], "description": "MultiEnum\n=========\n\nAn enumeration type supporting multiple equivalent names.\n\nRationale\n---------\n\nI find the types defined in the built-in ``enum`` type in Python 3 to be\nclumsy and hard to use for my purposes. Further, I have a project which\nrepeatedly requires me to resolve strings to numbers and then back to\nsometimes different strings, based on the context. This module is the\nresult of that.\n\nThe implementation subclasses ``int``, which allows for the value of the\nenumeration to be stored in a minimal amount of space, while providing a\nnumber of attributes of the object for converting it to different names.\n\nUsage\n-----\n\nSubclasses should define the class attribute ``_members`` as a tuple of\ntuples. [#]_ Every member of ``_members`` should be a tuple of strings\ncontaining a name which equates to the enumerated value. The value will be\ninferred from the member's position in the tuple (equal to the\nsubscript). Optionally, a subclass may define ``_fields``, a tuple of field\nnames which correspond to the order the enumeration names appear in within the\n``_members`` attribute.\n\nThe enumerated value can be instantiated with a plain int value or with any of\nthe names provided in ``_members``, either using the appropriate field name as\na keyword or, so long as it is unique across all fields, as an un-keyworded\nargument. There is no test to ensure that names are unique -- if a name\nappears multiple times in the ``_members`` tuples, the behavior is undefined.\n\n\nBy default, the first in each individual enumerated tuple will be returned if\nthe value is cast as a string (using the str() function, for instance). For\ncompatability with the types in the ``enum`` module, the same value will be\nreturned using the ``name`` attribute. The other names are available as a\ntuple in the ``_names`` attribute, and if ``_fields`` was defined, will be\navailable as the value of attributes corresponding to the relevant field name\nin ``_fields``.\n\nIf more than one argument is given on instantiation, either keyworded or not,\na ``ValueError`` exception will be raised unless all arguments resolve to the\nsame value.\n\nThe ``MultiEnum`` type makes an attempt to be idempotent -- i.e., if ``x`` is\nan ``MultiEnum``, ``x is MultiEnum(x)`` should be true. However, in the case\nof multiple init values, idempotency is only preserved for the first\npositional parameter. ``x is MultiEnum(a, x)`` will not be true, even if\n``a`` and ``x`` are equal.\n\n\n.. [#] Techincally, the ``_members`` attribute, all members of ``_members``,\n and the ``_fields`` attribute can be any iterable sequence. I strongly\n recommend tuples unless you have a reason not to, because in addition\n to being lightweight and simple, they're immutable, which saves the\n interpreter a lot of work.\n\nExample\n-------\n\n >>> from multienum import MultiEnum\n >>> class SampleEnum(MultiEnum):\n ... _members = ((\"zero\", \"zip\", \"z\u00e9ro\", \"cero\"),\n ... (\"one\", \"ace\", \"une\", \"uno\"),\n ... (\"two\", \"deuce\", \"deux\", \"dos\"))\n ... _fields = ('english', 'slang', 'french', 'spanish')\n >>> val1 = SampleEnum(\"one\")\n >>> int(val1)\n 1\n >>> str(val1)\n 'one'\n >>> val1.name\n 'one'\n >>> val1.spanish\n 'uno'\n >>> val2 = SampleEnum(slang=\"deuce\")\n >>> int(val2)\n 2\n >>> try:\n ... se = SampleEnum(\"two\", spanish=\"cero\")\n ... except ValueError:\n ... print(\"Value mismatch\")\n Value mismatch", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sorreltree/multienum", "keywords": "enumeration enum", "license": "Apache License 2.0", "maintainer": null, "maintainer_email": null, "name": "multienum", "package_url": "https://pypi.org/project/multienum/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/multienum/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/sorreltree/multienum" }, "release_url": "https://pypi.org/project/multienum/0.2.5/", "requires_dist": null, "requires_python": null, "summary": "Enumerator type supporting multiple equivalent names", "version": "0.2.5" }, "last_serial": 2959354, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "bac7f7189f200c52aec11dbb7fb86439", "sha256": "bc48f310fdb5399143c203d10f4290c8db3be2f380a6157e4f5e19c438bda116" }, "downloads": -1, "filename": "multienum-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "bac7f7189f200c52aec11dbb7fb86439", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6407, "upload_time": "2015-02-02T21:13:30", "url": "https://files.pythonhosted.org/packages/29/27/fed6ba98797dc6702c934441db55452ba436ab26ace7929a0ee2bb128a43/multienum-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8de89701040779f958343a654d8b7035", "sha256": "359b2486b35f839aefa10f78ecd32751a278de39db3b821c8b3aeb3a2835bb10" }, "downloads": -1, "filename": "multienum-0.1.tar.gz", "has_sig": false, "md5_digest": "8de89701040779f958343a654d8b7035", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8813, "upload_time": "2015-02-02T21:13:35", "url": "https://files.pythonhosted.org/packages/56/ca/426c285f943256a82782515287fcbf6ff403ed47c85d359a979c3e5928e5/multienum-0.1.tar.gz" } ], "0.1b": [ { "comment_text": "", "digests": { "md5": "0c2bcb644b37949c896b894860761dd3", "sha256": "096eb828ab83ee0af49aeede19b7e8f2e2a91b4d56a7d5023e7117cb6604f366" }, "downloads": -1, "filename": "multienum-0.1b-cp34-cp34m-macosx_10_6_intel.whl", "has_sig": false, "md5_digest": "0c2bcb644b37949c896b894860761dd3", "packagetype": "bdist_wheel", "python_version": "cp34", "requires_python": null, "size": 5114, "upload_time": "2015-02-02T20:56:43", "url": "https://files.pythonhosted.org/packages/eb/da/6fd16f45a22c90687c612256bf28f1381808b2f37e288ee761d6483cb659/multienum-0.1b-cp34-cp34m-macosx_10_6_intel.whl" }, { "comment_text": "", "digests": { "md5": "2df5a458daed2f6a443c8e38d2907254", "sha256": "cc745a365e9aa3f953763263643e5b4fa2ff10761863eb2879a456a0396d6cdf" }, "downloads": -1, "filename": "multienum-0.1b.tar.gz", "has_sig": false, "md5_digest": "2df5a458daed2f6a443c8e38d2907254", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4338, "upload_time": "2015-02-02T20:56:46", "url": "https://files.pythonhosted.org/packages/41/33/6c0b86f53e0d695be86ad9ebc6449acb6bb191b9e06b4d60fb305d9e7fd4/multienum-0.1b.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "14a2572e143ab9ccde7016a9e6d794b7", "sha256": "460fcd4d160b79b6574b4117dbd4d59e7a1e5f3d430d12eb1922db5f81ea0d90" }, "downloads": -1, "filename": "multienum-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "14a2572e143ab9ccde7016a9e6d794b7", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 6709, "upload_time": "2015-05-16T05:46:38", "url": "https://files.pythonhosted.org/packages/67/58/3ed2b3c1d6e1363d04efacbc232d41aa3a7487a851f62d1c6680eec9939f/multienum-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ee17c7deea5c2356dda30c83658db5d1", "sha256": "76708f2c32836d21be96f09496205692dfcd40e585843df33a25c2348cdc4c7c" }, "downloads": -1, "filename": "multienum-0.2.tar.gz", "has_sig": false, "md5_digest": "ee17c7deea5c2356dda30c83658db5d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9092, "upload_time": "2015-05-16T05:46:18", "url": "https://files.pythonhosted.org/packages/fb/7f/56cfa3d4980e306d53113b7868b5283ffbc9e284abefaab01dded0f173e0/multienum-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f6d78b6441e29ba107fd0edb0e3121bf", "sha256": "b85f40101bd156c93b5fd98fe9fccb80cc0912546450d6e89e25dcf26eae7f78" }, "downloads": -1, "filename": "multienum-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f6d78b6441e29ba107fd0edb0e3121bf", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 7104, "upload_time": "2015-05-18T18:18:16", "url": "https://files.pythonhosted.org/packages/d9/3d/8583563abe020c3ac51e6ccb137d04fd851cc5f8b34e88973ea565301444/multienum-0.2.1-py3-none-any.whl" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "a5883380e87c890c3856aceaad3350b1", "sha256": "a0b2049c8fdb43ba8d039bc03cb34d0cf15c11f7009e9c901bc857756e35fa8f" }, "downloads": -1, "filename": "multienum-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a5883380e87c890c3856aceaad3350b1", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 7106, "upload_time": "2015-06-08T20:54:08", "url": "https://files.pythonhosted.org/packages/a9/9d/3b503e6142a19aa09931f3838b8369f4a785550ae64fa918bd609747a104/multienum-0.2.2-py2.py3-none-any.whl" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "75b0a5625dcf78028eaebd5c2b0bfe62", "sha256": "941711e16f5e95427c5bbead4452890bd9a14490081c445026aebdacca741dcd" }, "downloads": -1, "filename": "multienum-0.2.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "75b0a5625dcf78028eaebd5c2b0bfe62", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 7214, "upload_time": "2015-06-09T15:50:19", "url": "https://files.pythonhosted.org/packages/ae/03/ffadcdc8cf69d6a20c7db28682a13ee7852e178fbd7d7ac21d6226e3e622/multienum-0.2.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5c34404933d4cfa0bde17f8d6fa78b84", "sha256": "80aa470459bff1f828efd6af2e7af2dad68f74571eee5a6a55c09d8bfba370c2" }, "downloads": -1, "filename": "multienum-0.2.3.tar.gz", "has_sig": false, "md5_digest": "5c34404933d4cfa0bde17f8d6fa78b84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9945, "upload_time": "2015-06-09T15:50:02", "url": "https://files.pythonhosted.org/packages/a5/1e/8a10beb163fbf6f1d3318c0b1b7fea18b164ebdb31a0218402005cb92e7b/multienum-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "90069d444ef24150c8159f9300ff2d97", "sha256": "ee1561812842ef9a950fa877875cf17620d5d03cf20bd4de49df74266b615456" }, "downloads": -1, "filename": "multienum-0.2.4.tar.gz", "has_sig": false, "md5_digest": "90069d444ef24150c8159f9300ff2d97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9990, "upload_time": "2015-08-19T21:32:39", "url": "https://files.pythonhosted.org/packages/9d/89/95b37cffa32113a49506ba38821aa6ca53829861c92e01d89d7a5c14ee53/multienum-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "46a0c45f1d1c5520e221a90d7dd50dd3", "sha256": "57e1ecff4d0004dc05b36cdd1ec4a103a652a9aee6038b8bd0cc2cd456244d78" }, "downloads": -1, "filename": "multienum-0.2.5.tar.gz", "has_sig": false, "md5_digest": "46a0c45f1d1c5520e221a90d7dd50dd3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10584, "upload_time": "2017-06-19T12:24:20", "url": "https://files.pythonhosted.org/packages/8d/34/f655a5a3fb97d8bafab39f3e469335ad9eabfa2bbbc4a73fc4bfd98828d6/multienum-0.2.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "46a0c45f1d1c5520e221a90d7dd50dd3", "sha256": "57e1ecff4d0004dc05b36cdd1ec4a103a652a9aee6038b8bd0cc2cd456244d78" }, "downloads": -1, "filename": "multienum-0.2.5.tar.gz", "has_sig": false, "md5_digest": "46a0c45f1d1c5520e221a90d7dd50dd3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10584, "upload_time": "2017-06-19T12:24:20", "url": "https://files.pythonhosted.org/packages/8d/34/f655a5a3fb97d8bafab39f3e469335ad9eabfa2bbbc4a73fc4bfd98828d6/multienum-0.2.5.tar.gz" } ] }