{ "info": { "author": "guoquan", "author_email": "guoquanscu@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# `@cls` - Class Made Aware to Decorator\n\n[![PyPI - License](https://img.shields.io/pypi/l/acls.svg)](https://pypi.org/project/acls/)\n[![PyPI](https://img.shields.io/pypi/v/acls.svg)](https://pypi.org/project/acls/)\n[![PyPI - Status](https://img.shields.io/pypi/status/acls.svg)](https://pypi.org/project/acls/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/acls.svg)](https://pypi.org/project/acls/)\n\n[![GitHub](https://img.shields.io/github/license/guoquan/acls.svg)](LICENSE)\n[![CircleCI](https://circleci.com/gh/guoquan/acls/tree/master.svg?style=svg)](https://circleci.com/gh/guoquan/acls/tree/master)\n[![Build Status](https://travis-ci.org/guoquan/acls.svg?branch=master)](https://travis-ci.org/guoquan/acls)\n[![codecov](https://codecov.io/gh/guoquan/acls/branch/master/graph/badge.svg)](https://codecov.io/gh/guoquan/acls)\n\n\nThe purpose of this library is to provide possibility to create decorators, especially in super classes, with current class `cls` as argument.\nEverything are centered with our new `cls` module, keyword, magic, or what every you think it would be.\n\n## Getting Started\n\n### Installation\n\nInstall by `pip` from PyPI:\n```bash\npip install acls\n```\n\n### Example\n\nA typical snippet looks like:\n\n```python\nfrom functools import wraps\nimport cls\n\n\nclass Base(metaclass=cls.ClsMeta):\n @cls\n def decor(cls, decor_arg):\n def wrap(func):\n @wraps(func)\n def wrapper(self):\n # do something with `func`\n retval = func(self)\n # do something with `retval`\n return retval\n return wrapper\n return wrap\n\nclass Extended(Base):\n @cls.decor('some arg')\n def func(self):\n # do something\n pass\n```\n\nThe magic is that you can use `@cls.decor` in `Extended` class, which is inheritance from `Base`.\nWhat is more, with in the decorator `Base.decor`, argument `cls` will be assigned with the correct current class.\nIn this example, it would simply be a reference to `Extended`.\nThis would be helpful if you want to make use of some class property here in the decorator.\n\n## Magic\n\nWell, there is no magic. I created a delegator in class namespace to enable both class possible to use `@cls`.\nSo, it is not the module `cls` as we imported on the top.\nI use this to make it more consistent looking, and fool some interpreters like `pylint`.\nNo offense, just want to make them less noisy.\n\n## Limitations\n\nUnfortunately, This work is based on [customizing python class creation](https://docs.python.org/3/reference/datamodel.html#customizing-class-creation).\nI have to make use of [`__prepare__`](https://www.python.org/dev/peps/pep-3115/#id11), which is [introduced](https://www.python.org/dev/peps/pep-3115/) only to [python 3](https://docs.python.org/3/reference/datamodel.html#customizing-class-creation).\nThat means there is no known possible backward compatibility with [python 2](https://docs.python.org/2/reference/datamodel.html#customizing-class-creation) now.\nThe code is tested against python 3.5+.\n\nPlease let me know if you come up with an idea how to manipulate class creation in python 2.\n\nThere are a couple of issues, with which I am talking. Contributions are welcome.\n\n### Known issue\n\n- [ ] relying on length of arguments and `callable()` to support optional arguments in decorator\n- [ ] not compatible with `@classmethod`, or many other decorators\n- [ ] make `pylint` really noisy\n- [ ] no documents :see_no_evil:!\n\n## License\n\n[MIT License, Copyright (c) 2019 guoquan](LICENSE)", "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/guoquan/acls", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "acls", "package_url": "https://pypi.org/project/acls/", "platform": "", "project_url": "https://pypi.org/project/acls/", "project_urls": { "Homepage": "https://github.com/guoquan/acls" }, "release_url": "https://pypi.org/project/acls/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "`@cls` - Class Made Aware to Decorator", "version": "1.0.2" }, "last_serial": 5466205, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "2734148e376c316348b9a28fba390cf3", "sha256": "0094a4752eab2366ab4f6b96177f33c1904fa6038fcf31de93c6f2f8a94e7eba" }, "downloads": -1, "filename": "acls-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2734148e376c316348b9a28fba390cf3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5481, "upload_time": "2019-06-29T07:42:15", "url": "https://files.pythonhosted.org/packages/66/f8/a5d2de58cc3296192eb7382ab64e2d156d3a03839913e57cf50dba8d13de/acls-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a4a151cadcf3ff6c367c0e8dde0b452e", "sha256": "93cf0689e6ebaf33541d3442b1c3adb76cb7fd78c7aa8c0127027a347f7d2ea8" }, "downloads": -1, "filename": "acls-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a4a151cadcf3ff6c367c0e8dde0b452e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4123, "upload_time": "2019-06-29T07:42:18", "url": "https://files.pythonhosted.org/packages/14/40/a92eaeea775ab20deb139a565138470eec6f8b1b50acd678afe4ce3bd673/acls-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "e3beae5d25df0293cb9fac981132586f", "sha256": "07c4776550dc91c9f31822545268d82bd20f4b774532541672933ecc1d204a08" }, "downloads": -1, "filename": "acls-1.0.1.tar.gz", "has_sig": false, "md5_digest": "e3beae5d25df0293cb9fac981132586f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4086, "upload_time": "2019-06-29T09:32:08", "url": "https://files.pythonhosted.org/packages/cb/8e/b6e93fea6e65c1d9e2457ee155a5f2a35ba6d82218bf37cd9b723bd781f6/acls-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "90bdd0d5327a2e314154e04aba4f8ddb", "sha256": "3d448164b6275e7424407af647b283570871e68808fbe61a1cc8baeee3ac3951" }, "downloads": -1, "filename": "acls-1.0.2.tar.gz", "has_sig": false, "md5_digest": "90bdd0d5327a2e314154e04aba4f8ddb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4265, "upload_time": "2019-06-29T19:42:03", "url": "https://files.pythonhosted.org/packages/0b/03/1ab1f5cdffac551b7351444cccdac01d0b0f3ddf85b84a6a7d4aa858aa65/acls-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "90bdd0d5327a2e314154e04aba4f8ddb", "sha256": "3d448164b6275e7424407af647b283570871e68808fbe61a1cc8baeee3ac3951" }, "downloads": -1, "filename": "acls-1.0.2.tar.gz", "has_sig": false, "md5_digest": "90bdd0d5327a2e314154e04aba4f8ddb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4265, "upload_time": "2019-06-29T19:42:03", "url": "https://files.pythonhosted.org/packages/0b/03/1ab1f5cdffac551b7351444cccdac01d0b0f3ddf85b84a6a7d4aa858aa65/acls-1.0.2.tar.gz" } ] }