{ "info": { "author": "Kiss Gy\u00f6rgy", "author_email": "kissgyorgy@me.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4" ], "description": "enum34-custom\n=============\n\n|travis| |coveralls| |release| |downloads| |pythons| |license|\n\nWhat\n----\n\nCustom Enum classes for the Python 3.4 enum module.\n\n\nInstall\n-------\n\n.. code-block:: bash\n\n $ pip install enum34-custom\n\n\nUsage\n-----\n\nMultiValueEnum\n^^^^^^^^^^^^^^\n\nEnum subclass where a member can be any iterable (even a generator, except str).\nYou can reference a member by any of its element in the associated iterable.\nIt might be usable for e.g. Equivalence Class Partitioning (ECP/EC testing).\n\n\n.. code-block:: python\n\n from enum_custom import MultiValueEnum\n\n class Suit(MultiValueEnum):\n CLUBS = '\u2663', 'c', 'C'\n DIAMONDS = '\u2666', 'd', 'D'\n HEARTS = '\u2665', 'h', 'H'\n SPADES = '\u2660', 's', 'S'\n\n >>> print(Suit.CLUBS)\n Suit.CLUBS\n\n >>> Suit.CLUBS\n \n\n >>> Suit('c')\n \n\n >>> Suit('c') is Suit('C') is Suit('\u2663') is Suit.CLUBS\n True\n\n >>> import pickle\n >>> pickle.loads(pickle.dumps(Suit('c'))) is Suit('\u2663')\n True\n\n >>> Suit('L')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"/Users/walkman/Projects/enum34-custom/enum_custom.py\", line 19, in __call__\n return super().__call__(suit)\n File \"/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/enum.py\", line 222, in __call__\n return cls.__new__(cls, value)\n File \"/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/enum.py\", line 457, in __new__\n raise ValueError(\"%s is not a valid %s\" % (value, cls.__name__))\n ValueError: L is not a valid Suit\n\n >>> list(Suit)\n [,\n ,\n ,\n ]\n\n\n.. warning::\n\n You need to keep a couple of things in mind when using MultiValueEnum:\n\n\n* Generators will immediately be exhausted at class creation time!\n* To conform to the standard library behavior, overlapping iterables are\n considered aliases, and works the same way as in stdlib\n (lookup will match the first declared element):\n\n .. code-block:: python\n\n >>> class MyOverLappingMVE(MultiValueEnum):\n ... A = (0, 1, 2, 3, 4)\n ... B = (4, 5, 6, 7, 8)\n >>> MyOverLappingMVE(4)\n \n\n If you want to make sure, no overlapping elements are present between members,\n you can use the no_overlap decorator:\n\n .. code-block:: python\n\n >>> from enum_custom import MultiValueEnum, no_overlap\n\n >>> @no_overlap\n ... class NoOverLappingEnum(MultiValueEnum):\n ... A = (1, 2, 3)\n ... B = (3, 4, 5)\n ...\n /Users/walkman/Projects/enum34-custom/enum_custom.py in no_overlap(multienum)\n 55 (alias, name, intersection) in duplicates])\n 56 raise ValueError('common element found in {!r}: {}'\n ---> 57 .format(multienum, alias_details))\n 58 return multienum\n 59\n\n ValueError: common element found in : B & A -> {3}\n\n* Beware with storing lots of data, every value will stored twice\n (MultiValueEnum stores values internally in a set for faster lookups)\n* If you declare a dict as a value, keys will be looked up (as expected)\n\n\nCaseInsensitiveMultiValueEnum\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThis works the same way as MultiValueEnum except if a member's value contains\na str, those will be compared in a case-insensitive member.\n\nConsider the following example:\n\n.. code-block:: python\n\n class SimpleMultiValueEnum(MultiValueEnum):\n one = 1, 'one'\n two = 2, 'two'\n\n >>> SimpleMultiValueEnum('One')\n /usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/enum.py in __new__(cls, value)\n 455 if member.value == value:\n 456 return member\n --> 457 raise ValueError(\"%s is not a valid %s\" % (value, cls.__name__))\n 458\n 459 def __repr__(self):\n\n ValueError: One is not a valid SimpleMultiValueEnum\n\nWhile:\n\n.. code-block:: python\n\n class CaseInsensitiveMVE(CaseInsensitiveMultiValueEnum):\n one = 1, 'one'\n two = 2, 'two'\n\n >>> CaseInsensitiveMVE('One')\n \n\n\nStrEnum\n^^^^^^^\n\nMembers of this enum are also instances of str and directly comparable to strings.\nstr type is forced at declaration. Works the same way as described in Python\nEnum documentation, except for checking type.\n\n.. warning::\n\n It's not possible to use StrEnum with OrderableMixin, because the members of\n StrEnum are also instances of str and ordering members will happen beased on\n str ordering (e.g. '1' < '2', 'A' < 'B', etc.)\n If you want ordering by declaration, use OrderableMixin without typed\n subclass.\n\n\nCaseInsensitiveStrEnum\n^^^^^^^^^^^^^^^^^^^^^^\n\nSame as StrEnum, but members stored as uppercase, and comparing to them is\ncase insensitive also:\n\n.. code-block:: python\n\n from enum_custom import CaseInsensitiveStrEnum\n class MyCaseInsensitiveStrEnum(CaseInsensitiveStrEnum):\n one = 'a'\n two = 'b'\n\n >>> MyCaseInsensitiveStrEnum('a') == 'A'\n True\n >>> MyCaseInsensitiveStrEnum.one == 'a'\n True\n\n\nTesting\n-------\n\n.. code-block:: bash\n\n $ python setup.py test\n\n\nOr install package in development mode and test with py.test::\n\n $ pip install -e .\n $ py.test\n\n\nDifferences between Python 2 and 3\n----------------------------------\n\nThere are differences in how Python 2 and 3 creates classes, there are a couple of\nthings that doesn't work very well on 2, which you should be aware:\n\n- xrange(5) != xrange(5)\n This is the opposit in Python 3, because range(5) == range(5), however you can use\n range(5) == range(5) in Python 2 in this case.\n- Python 2 have no definition order of members. This means you *have to* manually define\n __order__ attribute to be able to compare members by definition order (e.g. with\n OrderableMixin). See the details in `enum34 package dokumentation`_:\n- str vs unicode: This library doesn't mix and match str types either in Python2\n it uses unicode in Python2 and str in Python3 and also enforces the type in\n StrEnum, CaseInsensitiveStrEnum and ckeck for text type only in\n CaseInsensitiveMultiValueEnum. (So if you pass str in Python2, it will not be case\n insensitive!)\n- Python 2 leaks variables from list comprehensions, so if you define your class\n like this:\n- On pypy you always have to set __order__ because if you use different types, because\n it would sort the member values, but can't compare set to other type.\n\n .. code-block:: python\n\n class MyList(MultiValueEnum):\n A = [n for n in range(5)]\n\n MyList will have 'MyList.n' also!!!\n\n\nChanges\n-------\n\nv0.7.0\n^^^^^^\n\n- Python 2.7 support\n- Renamed module to enum_custom for consistency (enum34 package is called enum also).\n\n\n\n.. _enum34 package dokumentation: https://pypi.python.org/pypi/enum34\n\n.. |travis| image:: https://travis-ci.org/kissgyorgy/enum34-custom.svg?branch=master\n :target: https://travis-ci.org/kissgyorgy/enum34-custom\n\n.. |coveralls| image:: https://coveralls.io/repos/github/kissgyorgy/enum34-custom/badge.svg?branch=master\n :target: https://coveralls.io/github/kissgyorgy/enum34-custom?branch=master\n\n.. |pythons| image:: https://img.shields.io/pypi/pyversions/enum34-custom.svg\n :target: https://pypi.python.org/pypi/enum34-custom/\n :alt: Supported Python versions\n\n.. |release| image:: https://img.shields.io/pypi/v/enum34-custom.svg\n :target: https://pypi.python.org/pypi/enum34-custom/\n :alt: Latest Version\n\n.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg\n :target: https://github.com/kissgyorgy/enum34-custom/blob/master/LICENSE\n :alt: MIT License\n\n.. |downloads| image:: https://img.shields.io/pypi/dm/enum34-custom.svg\n :target: https://pypi.python.org/pypi/enum34-custom/\n :alt: Downloads", "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/kissgyorgy/enum34-custom", "keywords": "enum", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "enum34-custom", "package_url": "https://pypi.org/project/enum34-custom/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/enum34-custom/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/kissgyorgy/enum34-custom" }, "release_url": "https://pypi.org/project/enum34-custom/0.7.2/", "requires_dist": null, "requires_python": null, "summary": "Custom Enum classes for enum in Python 3.4 or for enum34 for Python2.7", "version": "0.7.2" }, "last_serial": 3808069, "releases": { "0.6.5": [ { "comment_text": "", "digests": { "md5": "196a0cc3c57a6777d54e3c225d21f692", "sha256": "93ff632f5213914549591dabf14fbec884fc639049dd9049fab5866ec76b4ca4" }, "downloads": -1, "filename": "enum34_custom-0.6.5-py3-none-any.whl", "has_sig": false, "md5_digest": "196a0cc3c57a6777d54e3c225d21f692", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 8616, "upload_time": "2014-09-08T19:48:20", "url": "https://files.pythonhosted.org/packages/a4/9f/222637397c638dd00fc29bd73a1f6adc2c8dd5037518fa0cb3f7afa0746d/enum34_custom-0.6.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f0b8887ad6c93667587596b8b9379d36", "sha256": "6ecb401bb19ef74431b7319b4e9e76327ab23837af1f843530fefd6051686e04" }, "downloads": -1, "filename": "enum34-custom-0.6.5.tar.gz", "has_sig": false, "md5_digest": "f0b8887ad6c93667587596b8b9379d36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5549, "upload_time": "2014-09-08T19:48:18", "url": "https://files.pythonhosted.org/packages/31/b0/5dfe0395d3624cdd9492c168a3ab42a4eddea3da17cb7fc59eb1ea8fb251/enum34-custom-0.6.5.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "18b2b3e155b563ca40f9f4dfd81b85c4", "sha256": "897541f61fe37bf55a4e5b59389c9ff0801fc6326293df1f9fae72bc5c914670" }, "downloads": -1, "filename": "enum34_custom-0.7.1-py2-none-any.whl", "has_sig": false, "md5_digest": "18b2b3e155b563ca40f9f4dfd81b85c4", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9829, "upload_time": "2014-09-26T19:30:43", "url": "https://files.pythonhosted.org/packages/dc/86/2bda1569aa9c8f2bf4206c4d6aeef9c549cc4fa45ce02ad0572326657576/enum34_custom-0.7.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e81ca8efacd2eb786524599c4872953e", "sha256": "7bd8f34f12fbd9521cbf37b6cec6b28c6645f6ddc822f5cfc5c0aad2aac20c30" }, "downloads": -1, "filename": "enum34_custom-0.7.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e81ca8efacd2eb786524599c4872953e", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 9821, "upload_time": "2014-09-26T19:31:04", "url": "https://files.pythonhosted.org/packages/bc/be/7c7d77bb8cf5a056547f69d98d32fe112a39709e7fe97f8046f4895200e3/enum34_custom-0.7.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e218bb86e541f441018665d0ac9cdf04", "sha256": "d2ae06f88442ce16b29f28bd9223ea7efb7ebe9497885796c307ef412c1bee9d" }, "downloads": -1, "filename": "enum34-custom-0.7.1.tar.gz", "has_sig": false, "md5_digest": "e218bb86e541f441018665d0ac9cdf04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6309, "upload_time": "2014-09-26T19:30:40", "url": "https://files.pythonhosted.org/packages/83/ad/bb2b8a323caae1eb69ddfb679155181aa4d1863efd0da4bc836518ff7e43/enum34-custom-0.7.1.tar.gz" } ], "0.7.2": [ { "comment_text": "", "digests": { "md5": "2815c80d6023f447c63bc08790fef48e", "sha256": "da38e15132fa87a588493b85310d2b8802fd7ffe1990851048628d5ccd3cfd05" }, "downloads": -1, "filename": "enum34_custom-0.7.2-py2-none-any.whl", "has_sig": false, "md5_digest": "2815c80d6023f447c63bc08790fef48e", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9798, "upload_time": "2016-09-18T15:24:06", "url": "https://files.pythonhosted.org/packages/4c/4c/9baa3b3c905cde93ab802e2f1a569860bfb8406b6285e511e9d0e1a8a7e9/enum34_custom-0.7.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f211a3f84dbdf34ba4fd93d5a3523c1b", "sha256": "6cecbf087e9ff6507b742329793c4f81dbdb8ae771a5945f36a51c12c329757e" }, "downloads": -1, "filename": "enum34-custom-0.7.2.tar.gz", "has_sig": false, "md5_digest": "f211a3f84dbdf34ba4fd93d5a3523c1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6265, "upload_time": "2016-09-18T15:24:03", "url": "https://files.pythonhosted.org/packages/08/af/da9bb347826b870dc5484e86037dc6f92f53ed248049efcc44033052982d/enum34-custom-0.7.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2815c80d6023f447c63bc08790fef48e", "sha256": "da38e15132fa87a588493b85310d2b8802fd7ffe1990851048628d5ccd3cfd05" }, "downloads": -1, "filename": "enum34_custom-0.7.2-py2-none-any.whl", "has_sig": false, "md5_digest": "2815c80d6023f447c63bc08790fef48e", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9798, "upload_time": "2016-09-18T15:24:06", "url": "https://files.pythonhosted.org/packages/4c/4c/9baa3b3c905cde93ab802e2f1a569860bfb8406b6285e511e9d0e1a8a7e9/enum34_custom-0.7.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f211a3f84dbdf34ba4fd93d5a3523c1b", "sha256": "6cecbf087e9ff6507b742329793c4f81dbdb8ae771a5945f36a51c12c329757e" }, "downloads": -1, "filename": "enum34-custom-0.7.2.tar.gz", "has_sig": false, "md5_digest": "f211a3f84dbdf34ba4fd93d5a3523c1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6265, "upload_time": "2016-09-18T15:24:03", "url": "https://files.pythonhosted.org/packages/08/af/da9bb347826b870dc5484e86037dc6f92f53ed248049efcc44033052982d/enum34-custom-0.7.2.tar.gz" } ] }