{ "info": { "author": "Ian McCracken", "author_email": "ian.mccracken@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "===============================\nPython eXtraordinary Decorators\n===============================\n\nDecorators in Python are limited to action when the function they wrap is\nactually called. This package adds the ability to define decorators to be\ncalled at any of the three points of the function's existence: when the\nfunction is defined, when an instance of the class containing the function is\ncreated, and when the function is itself called.\n\nThis enables the use of decorators to, e.g., tag deprecated methods and pull\nup a report; register instance methods as listeners to events; manipulate\nmethods at class creation without metaclasses; and so on.\n\npyxdeco includes decorator base classes::\n\n >>> from pyxdeco import ClassLevelDecorator\n >>> from pyxdeco import InstanceLevelDecorator\n >>> from pyxdeco import MethodLevelDecorator\n\nand factory decorators for easy creation of decorators from functions::\n\n >>> from pyxdeco import class_level_decorator\n >>> from pyxdeco import instance_level_decorator\n >>> from pyxdeco import method_level_decorator\n\nCreate a decorator by subclassing any of the base classes and overriding the\n``decorate`` method. Alternatively, decorate a function with the factory\ndecorator and the function will be used as the ``decorate`` method for the\ndecorator.\n\n\nClass-Level Decorators\n======================\nClass-level decorators are invoked when the class is created. They are called\nwith the decorated method and the class as arguments::\n\n >>> deprecated_methods = []\n >>>\n >>> @class_level_decorator\n ... def deprecated(func, cls):\n ... deprecated_methods.append(func.__name__)\n ...\n >>> class A(object):\n ...\n ... def not_deprecated(self):\n ... pass\n ...\n ... @deprecated\n ... def deprecated_method(self):\n ... pass\n ... \n ... @deprecated\n ... def also_deprecated_method(self):\n ... pass\n ...\n >>> deprecated_methods\n ['deprecated_method', 'also_deprecated_method']\n\n\nInstance-Level Decorators\n=========================\nInstance-level decorators are invoked when an instance of the class containing\nthe decorated method is created (that is, after ``__init__``). The are called with the decorated instance method, the instance, and the class as arguments::\n\n >>> click_listeners = []\n >>>\n >>> @instance_level_decorator\n ... def onclick(func, inst, cls):\n ... click_listeners.append('%s.%s' % (inst.id, func.__name__))\n ...\n >>> class A(object):\n ... def __init__(self, id):\n ... self.id = id\n ...\n ... @onclick\n ... def click_listener(self):\n ... pass\n ... \n >>> len(click_listeners) == 0\n True\n >>>\n >>> ob1 = A('ob1')\n >>> click_listeners\n ['ob1.click_listener']\n >>>\n >>> ob2 = A('ob2')\n >>> click_listeners\n ['ob1.click_listener', 'ob2.click_listener']\n\n\nMethod-Level Decorators\n=======================\nMethod-level decorators are no different from ordinary decorators but are\nprovided for the sake of completeness and flexibility. They are passed the\ndecorated function (or instance method) and any arguments::\n\n >>> called = []\n >>>\n >>> @method_level_decorator\n ... def noticeme(func, *args, **kwargs):\n ... called.append(func.__name__)\n ...\n >>> class A(object):\n ... @noticeme\n ... def amethod(self):\n ... pass\n ...\n >>> a = A()\n >>> len(called) == 0\n True\n >>>\n >>> a.amethod()\n >>> called\n ['amethod']\n >>>\n >>> a.amethod()\n >>> called\n ['amethod', 'amethod']", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/iancmcc/pyxdeco", "keywords": "", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "pyxdeco", "package_url": "https://pypi.org/project/pyxdeco/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyxdeco/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/iancmcc/pyxdeco" }, "release_url": "https://pypi.org/project/pyxdeco/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "Python eXtraordinary Decorators", "version": "0.1.2" }, "last_serial": 816356, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ae92c716bc785c8cc953d46d95113e90", "sha256": "2f2123669006ad666c2ac4bb959bb210a8620dbf1e25dc05b3bbc4613d35e0ec" }, "downloads": -1, "filename": "pyxdeco-0.1-py2.6.egg", "has_sig": false, "md5_digest": "ae92c716bc785c8cc953d46d95113e90", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 13909, "upload_time": "2011-01-30T16:55:47", "url": "https://files.pythonhosted.org/packages/1e/74/f13cb4cbfe411fda0d56825b732d6f4a63fec0511f25dd4ff501e88d5c1c/pyxdeco-0.1-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "e7e35301361972673ef0b3dd7437a412", "sha256": "7d933b6e5b0d77f6c6fe756e45777017fc23207d02be2ef9e1f08e8fc7b7c6ff" }, "downloads": -1, "filename": "pyxdeco-0.1-py2.7.egg", "has_sig": false, "md5_digest": "e7e35301361972673ef0b3dd7437a412", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 13883, "upload_time": "2011-01-30T17:04:11", "url": "https://files.pythonhosted.org/packages/79/11/95b4b1b165c5530a588497bf75a86f9fc55783ee4e2e87358964ccdcb1a6/pyxdeco-0.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "3e0da113823535175ca56239faca54d8", "sha256": "5a8ec9c6741d183319b328e2a0bed09f9e7566a9eebc9cf0a2244e0e9bbef55b" }, "downloads": -1, "filename": "pyxdeco-0.1.tar.gz", "has_sig": false, "md5_digest": "3e0da113823535175ca56239faca54d8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6306, "upload_time": "2011-01-30T16:55:46", "url": "https://files.pythonhosted.org/packages/dc/8a/c9776a8617604ca855c71a8d49667480575bf993b883660b47de8a3212ca/pyxdeco-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ffabc151d5384a1c21352bbfa9fd5715", "sha256": "9b26637836f332f18741b83520c36be72c5247b74fc4b06d785fe2cf8409a675" }, "downloads": -1, "filename": "pyxdeco-0.1.1-py2.6.egg", "has_sig": false, "md5_digest": "ffabc151d5384a1c21352bbfa9fd5715", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 14096, "upload_time": "2011-01-31T15:45:36", "url": "https://files.pythonhosted.org/packages/8f/f3/aa76ffb209f59108350a5268570c2f5e1b30281f8aa9dc4796226a3b68dc/pyxdeco-0.1.1-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "4f303a395b64758002a59c2c53eb30dc", "sha256": "5b409942e60f8863fa40781312a0cc9909fd5dbb89e1014ec52411667c01ac25" }, "downloads": -1, "filename": "pyxdeco-0.1.1-py2.7.egg", "has_sig": false, "md5_digest": "4f303a395b64758002a59c2c53eb30dc", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 14073, "upload_time": "2011-01-31T15:46:24", "url": "https://files.pythonhosted.org/packages/ad/e0/a399dddc8005149cdd2f6a38ca259ef79145bd61d8541f68e7d2b2cad04c/pyxdeco-0.1.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "a66a7a60dab9d9a64f5dc435063eb326", "sha256": "feb72a12d71bd6ce5b5a5a997d45c72b5dfc630ac0cf596988fc93c8bad00abb" }, "downloads": -1, "filename": "pyxdeco-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a66a7a60dab9d9a64f5dc435063eb326", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6358, "upload_time": "2011-01-31T15:45:35", "url": "https://files.pythonhosted.org/packages/fc/09/84dec755cf609fe3f8b667b133bf326f793fbb382e8daeb66c1ae02bb53e/pyxdeco-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "32589d4315fcaade317fa250111910ea", "sha256": "4b9e36891511c450dd71f48f3dd2da043b91ade9614b946a2edff32e1399a4c4" }, "downloads": -1, "filename": "pyxdeco-0.1.2.tar.gz", "has_sig": false, "md5_digest": "32589d4315fcaade317fa250111910ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6695, "upload_time": "2013-07-16T03:07:36", "url": "https://files.pythonhosted.org/packages/52/d4/4417b0ec847bf2cc8b6d1a7cf59f2ab1b00952ad604e52a8fbd147e54a1b/pyxdeco-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "32589d4315fcaade317fa250111910ea", "sha256": "4b9e36891511c450dd71f48f3dd2da043b91ade9614b946a2edff32e1399a4c4" }, "downloads": -1, "filename": "pyxdeco-0.1.2.tar.gz", "has_sig": false, "md5_digest": "32589d4315fcaade317fa250111910ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6695, "upload_time": "2013-07-16T03:07:36", "url": "https://files.pythonhosted.org/packages/52/d4/4417b0ec847bf2cc8b6d1a7cf59f2ab1b00952ad604e52a8fbd147e54a1b/pyxdeco-0.1.2.tar.gz" } ] }