{ "info": { "author": "MrMrRobat", "author_email": "appkiller16@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "\nAnyStrEnum\n==========\n\n\n.. image:: https://img.shields.io/badge/Python%203.7-blue.svg\n :target: https://python.org\n :alt: Python 3.7\n\n\n.. image:: https://img.shields.io/pypi/v/AnyStrEnum.svg\n :target: https://pypi.python.org/pypi/AnyStrEnum\n :alt: PyPi Package Version\n\n\nElegant implementation of Enum which inherits from str or bytes\n\nAs simple as this\n-----------------\n\n.. code-block:: python\n\n from anystrenum import StrEnum\n\n class Season(StrEnum):\n spring: str\n summer: str\n autumn: str\n winter: str\n\n print(Season.summer)\n print(isinstance(Season.summer, str))\n # summer\n # True\n\nFeatures\n========\n\n\n* Easy members assignment with type hinting (No need to use ``auto()`` or other stubs)\n* Automatic value generation with support of custom converters or separators\n* Method to filter members (\\ ``contains``\\ , ``contained_in``\\ , ``startswith``\\ , ``endswith``\\ , etc.)\n* Custom ``str`` and ``bytes`` types support\n\nInstallation\n============\n\n.. code-block:: bash\n\n $ pip install AnyStrEnum\n\nExamples\n========\n\nUsing custom words separator\n----------------------------\n\nTo automatically replace all underscores (\\ ``_``\\ ) in names to something more suitable, use ``sep`` parameter:\n\n.. code-block:: python\n\n from anystrenum import StrEnum\n\n class Region(StrEnum, sep='-'):\n us_east_1: str\n us_west_1: str\n ca_central_1: str\n cn_northwest_1: str\n eu_central_1: str\n eu_west_1: str\n eu_north_2: str\n sa_east_1: str\n\n print(Region.us_east_1)\n # us-east-1\n\nUsing str converter and custom words separator\n----------------------------------------------\n\nIf you need to apply to your names more changes, you can use ``converter`` parameter. Pass a function in here which will be called on every member\n\n.. code-block:: python\n\n from anystrenum import StrEnum\n\n class ContentType(StrEnum, converter=lambda s: s.replace('_', '/', 1), sep='-'):\n application_json: str\n application_octet_stream: str\n application_x_json_stream: str\n audio_mpeg: str\n audio_pcm: str\n audio_ogg: str\n\n print(ContentType.application_octet_stream)\n # application/octet-stream\n\nAs you can see from an example, firstly, names will be converted with our lambda function and then, \nremaining underscores will be replaced with given separator\n\nFiltering enum members\n----------------------\n\nUsing enums from previous examples\n##################################\n\n.. code-block:: python\n\n print(ContentType.filter(contains='-', startswith='a', endswith='m'))\n # {, \n # }\n\n print(ContentType.filter(contained_in='Usually content type for MP3 is audio/mpeg'))\n # {}\n\n print(Region.filter(startswith='eu', endswith='1'))\n # {, }\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "enum str strenum bytesenum bytestrenum typing auto autoenum", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "AnyStrEnum", "package_url": "https://pypi.org/project/AnyStrEnum/", "platform": "", "project_url": "https://pypi.org/project/AnyStrEnum/", "project_urls": null, "release_url": "https://pypi.org/project/AnyStrEnum/0.2.0/", "requires_dist": [ "pytest ; extra == 'dev'", "inflection ; extra == 'inflection'", "pytest ; extra == 'tests'" ], "requires_python": ">=3.6", "summary": "Elegant implementation of Enum which inherits from str or bytes", "version": "0.2.0" }, "last_serial": 5458536, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7b85e18e503ed216cd9914e8d4c0a0a2", "sha256": "9ad70584824a5f88f9ca6a3b05f66528ed77dbcb439623b0dcb426f147e00ea8" }, "downloads": -1, "filename": "AnyStrEnum-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7b85e18e503ed216cd9914e8d4c0a0a2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 5333, "upload_time": "2019-06-26T15:49:00", "url": "https://files.pythonhosted.org/packages/8f/8b/d8670cba0dce6d08712e1520875ba881df6ffb36c5e351986a444177bdc7/AnyStrEnum-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4f3e5f47046e48a3ff5ed61f0cbd3a29", "sha256": "75c34cab7a2d5bb41b20233359c81563a162e36494a0221ae2de0ee34acada6d" }, "downloads": -1, "filename": "AnyStrEnum-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4f3e5f47046e48a3ff5ed61f0cbd3a29", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4462, "upload_time": "2019-06-26T15:49:03", "url": "https://files.pythonhosted.org/packages/dc/4f/57e41e115887567b636db27aaa9c920e1fd1e4cb558b02c813cdee91b168/AnyStrEnum-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "57f0e4acb1d895ead684791838f44ca6", "sha256": "2eea8854c0202cb04e5122558db8f1d0c801269922b89a20109206d94877fd31" }, "downloads": -1, "filename": "AnyStrEnum-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "57f0e4acb1d895ead684791838f44ca6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 6290, "upload_time": "2019-06-27T19:31:33", "url": "https://files.pythonhosted.org/packages/70/e2/2f009daccfb8af8896c712ba9ad4e053e4132b76c9a8557bb9642de79ba3/AnyStrEnum-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f575fdb2f0f6310e0bbb36dbe3ca64fc", "sha256": "675a804941d370d98b618f6a11f7ebffb9a633a32c63057ee37b1d6b3b6e4be7" }, "downloads": -1, "filename": "AnyStrEnum-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f575fdb2f0f6310e0bbb36dbe3ca64fc", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5201, "upload_time": "2019-06-27T19:31:35", "url": "https://files.pythonhosted.org/packages/21/63/391b3edcd6129e32a57fce21b1c41cfd27b48330cfa9b974d6b309ba6fee/AnyStrEnum-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "57f0e4acb1d895ead684791838f44ca6", "sha256": "2eea8854c0202cb04e5122558db8f1d0c801269922b89a20109206d94877fd31" }, "downloads": -1, "filename": "AnyStrEnum-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "57f0e4acb1d895ead684791838f44ca6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 6290, "upload_time": "2019-06-27T19:31:33", "url": "https://files.pythonhosted.org/packages/70/e2/2f009daccfb8af8896c712ba9ad4e053e4132b76c9a8557bb9642de79ba3/AnyStrEnum-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f575fdb2f0f6310e0bbb36dbe3ca64fc", "sha256": "675a804941d370d98b618f6a11f7ebffb9a633a32c63057ee37b1d6b3b6e4be7" }, "downloads": -1, "filename": "AnyStrEnum-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f575fdb2f0f6310e0bbb36dbe3ca64fc", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5201, "upload_time": "2019-06-27T19:31:35", "url": "https://files.pythonhosted.org/packages/21/63/391b3edcd6129e32a57fce21b1c41cfd27b48330cfa9b974d6b309ba6fee/AnyStrEnum-0.2.0.tar.gz" } ] }