{ "info": { "author": "Isaac Muse", "author_email": "Isaac.Muse@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "[![Unix Build Status][travis-image]][travis-link]\n[![Windows Build Status][appveyor-image]][appveyor-link]\n[![Coverage][codecov-image]][codecov-link]\n[![PyPI Version][pypi-image]][pypi-link]\n![License][license-image-mit]\n\n# PEP 562\n\n## Overview\n\nA backport of PEP 562. Allows controlling a module's `__dir__` and `__getattr__`. Useful for deprecating attributes. Works for Python 2.7+. And while it works on Python 3.7, it is recommended to use the official Python 3.7 implementation where applicable.\n\nThis module can be installed and used as a dependency, or if desired, it is easy to vendor as the license is quite permissible, and the code is contained in a single file.\n\n## Install\n\nInstallation is done with `pip`:\n\n```\npip install pep562\n```\n\n## Vendoring\n\nSimply copy the file `pep562/__init__.py` to your project and rename to `pep562`. Import and use as needed.\n\n## Usage\n\nHere is a simple example where we deprecate the attribute `version` for the more standardized `__version__`.\n\n```py\nfrom pep562 import Pep562\nimport sys\nimport warnings\n\n__version__ = (1, 0, 0)\n__all__ = (\"__version__\",)\n__deprecated__ = {\n \"version\": (\"__version__\", __version__)\n}\n\nPY37 = sys.version_info >= (3, 7)\n\n\ndef __getattr__(name):\n \"\"\"Get attribute.\"\"\"\n\n deprecated = __deprecated__.get(name)\n if deprecated:\n stacklevel = 3 if PY37 else 4\n warnings.warn(\n \"'{}' is deprecated. Use '{}' instead.\".format(name, deprecated[0]),\n category=DeprecationWarning,\n stacklevel=stacklevel\n )\n return deprecated[1]\n raise AttributeError(\"module '{}' has no attribute '{}'\".format(__name__, name))\n\n\ndef __dir__():\n \"\"\"Module directory.\"\"\"\n\n return sorted(list(__all__) + list(__deprecated__.keys()))\n\n\nif not PY37:\n Pep562(__name__)\n```\n\n## License\n\nMIT License\n\nCopyright (c) 2018 Isaac Muse \n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n[travis-image]: https://img.shields.io/travis/facelessuser/pep562/master.svg?label=Unix%20Build\n[travis-link]: https://travis-ci.org/facelessuser/pep562\n[appveyor-image]: https://img.shields.io/appveyor/ci/facelessuser/pep562/master.svg?label=Windows%20Build\n[appveyor-link]: https://ci.appveyor.com/project/facelessuser/pep562\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg\n[codecov-image]: https://img.shields.io/codecov/c/github/facelessuser/pep562/master.svg\n[codecov-link]: http://codecov.io/github/facelessuser/pep562?branch=master\n[pypi-image]: https://img.shields.io/pypi/v/pep562.svg\n[pypi-link]: https://pypi.python.org/pypi/pep562\n[license-image-mit]: https://img.shields.io/badge/license-MIT-blue.svg\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/facelessuser/pep562", "keywords": "pep 562 backport", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "pep562", "package_url": "https://pypi.org/project/pep562/", "platform": "", "project_url": "https://pypi.org/project/pep562/", "project_urls": { "Homepage": "https://github.com/facelessuser/pep562" }, "release_url": "https://pypi.org/project/pep562/1.0/", "requires_dist": null, "requires_python": "", "summary": "Backport of PEP 562.", "version": "1.0" }, "last_serial": 4510268, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "ff63533a5c9dfe5fcee9ad637fde5d84", "sha256": "d2a48b178ebf5f8dd31709cc26a19808ef794561fa2fe50ea01ea2bad4d667ef" }, "downloads": -1, "filename": "pep562-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ff63533a5c9dfe5fcee9ad637fde5d84", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7020, "upload_time": "2018-11-21T01:07:21", "url": "https://files.pythonhosted.org/packages/f5/31/2c8475b148c8a0c8cae39300f4346068e21909d44e0659f104ce76c3a7ef/pep562-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1505ec5af1f56c5c3f3ecd64b3a049f2", "sha256": "58cb1cc9ee63d93e62b4905a50357618d526d289919814bea1f0da8f53b79395" }, "downloads": -1, "filename": "pep562-1.0.tar.gz", "has_sig": false, "md5_digest": "1505ec5af1f56c5c3f3ecd64b3a049f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8409, "upload_time": "2018-11-21T01:07:23", "url": "https://files.pythonhosted.org/packages/98/46/048232af31a939b3c0e363418faa12f4cc0e144d00cebce6ec9ff5d0f06b/pep562-1.0.tar.gz" } ], "1.0b1": [ { "comment_text": "", "digests": { "md5": "ad57bdad9b09d5ef546afacbc74e5c7a", "sha256": "1cd6bdd88cefb6a2979245da15a40c23d2c0a86a5cde8fb64819ae7d40a57863" }, "downloads": -1, "filename": "pep562-1.0b1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ad57bdad9b09d5ef546afacbc74e5c7a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5865, "upload_time": "2018-10-26T06:53:41", "url": "https://files.pythonhosted.org/packages/12/94/71a323a231b0930ebb1cff8076e6e12d29698f71ca1807e171907d4e5f66/pep562-1.0b1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "76fe5ae5bd194d0e15a24bd49fa25b4d", "sha256": "9ab7124d6a97b78bc23276feaf96521b87a1873901cee7896272ea76ed6ec834" }, "downloads": -1, "filename": "pep562-1.0b1.tar.gz", "has_sig": false, "md5_digest": "76fe5ae5bd194d0e15a24bd49fa25b4d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5868, "upload_time": "2018-10-26T06:53:43", "url": "https://files.pythonhosted.org/packages/96/4d/c6c9602891a213d10230a4ae7b4794e011ad143270772e63518c578b8a8b/pep562-1.0b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ff63533a5c9dfe5fcee9ad637fde5d84", "sha256": "d2a48b178ebf5f8dd31709cc26a19808ef794561fa2fe50ea01ea2bad4d667ef" }, "downloads": -1, "filename": "pep562-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ff63533a5c9dfe5fcee9ad637fde5d84", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7020, "upload_time": "2018-11-21T01:07:21", "url": "https://files.pythonhosted.org/packages/f5/31/2c8475b148c8a0c8cae39300f4346068e21909d44e0659f104ce76c3a7ef/pep562-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1505ec5af1f56c5c3f3ecd64b3a049f2", "sha256": "58cb1cc9ee63d93e62b4905a50357618d526d289919814bea1f0da8f53b79395" }, "downloads": -1, "filename": "pep562-1.0.tar.gz", "has_sig": false, "md5_digest": "1505ec5af1f56c5c3f3ecd64b3a049f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8409, "upload_time": "2018-11-21T01:07:23", "url": "https://files.pythonhosted.org/packages/98/46/048232af31a939b3c0e363418faa12f4cc0e144d00cebce6ec9ff5d0f06b/pep562-1.0.tar.gz" } ] }