{ "info": { "author": "Shir0kamii", "author_email": "shir0kamii@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "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", "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "#######\nPyHooks\n#######\n\n.. image:: https://img.shields.io/travis/Shir0kamii/pyhooks/master.svg\n :target: https://travis-ci.org/Shir0kamii/pyhooks\n.. image:: https://img.shields.io/coveralls/Shir0kamii/pyhooks/master.svg\n.. image:: https://img.shields.io/codeclimate/github/Shir0kamii/pyhooks.svg\n :alt:\n\nPyHooks is meant to expose method hook for classes\n\n======\nStatus\n======\n\nThis project is maintained, feel free to open issues or pull requests.\n\n=======\nPurpose\n=======\n\nHave you ever wanted to execute code before or after a method ? PyHooks solve\nthis exact problem taking inspiration from marshmallow's hook system.\n\n============\nInstallation\n============\n\nLike any other published python package, you can install it via `pip` : \n\n.. code-block:: bash\n\n pip install pyhooks\n\n\n============\nHow to use ?\n============\n\nTo use it, you first need to implement a hooked method. You do this by\ndecorating the method with `@Hook`.\n\nFor example, suppose you have a class that at some moment save your data (such\nas a database). If you want to be able to plug new behavior, your code\nwill look like this:\n\n.. code-block:: python \n\n from pyhooks import Hook\n\n\n class DatabaseEntry(object):\n @Hook\n def save(self):\n pass # save implementation here\n\nThanks to the `@Hook` line, you will now be able to add functions that execute\nbefore and after the `save` method using the decorators `@precall_register` \nand `@postcall_register`.\n\nFor instance, if you want to increment a version variable before \nsaving, you could do:\n\n.. code-block:: python\n\n from pyhooks import precall_register\n\n\n class VersionnedEntry(DatabaseEntry):\n @precall_register(\"save\")\n def increment_version(self):\n self.version += 1\n\n\nThe decorator directive indicates to your class that `increment_version` should\nbe run before the `save` method that is passed to the decorator as argument.\n\n\n========\nExamples\n========\n\nYou can find some more examples in the `examples/` directory of this\nrepository.\n\n==============\nAdvanced usage\n==============\n\nYou can specialize a register decorator by calling it outside of a decorator\ncontext. The last example would yield:\n\n.. code-block:: python\n\n from pyhooks import precall_register\n\n pre_save = precall_register(\"save\")\n\n\n class VersionnedEntry(DatabaseEntry):\n @pre_save\n def increment_version(self):\n self.version += 1\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/Shir0kamii/pyhooks/tags", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Shir0kamii/pyhooks", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyhooks", "package_url": "https://pypi.org/project/pyhooks/", "platform": "any", "project_url": "https://pypi.org/project/pyhooks/", "project_urls": { "Download": "https://github.com/Shir0kamii/pyhooks/tags", "Homepage": "https://github.com/Shir0kamii/pyhooks" }, "release_url": "https://pypi.org/project/pyhooks/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Python hooks for methods", "version": "1.0.3" }, "last_serial": 6004689, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "007a43cc280a2a7c81c20d412fdeee87", "sha256": "6cc8ec80db5c76bf60013e0f74b99f830734b21340631ef19f03dccc32fafbad" }, "downloads": -1, "filename": "pyhooks-1.0.0.tar.gz", "has_sig": false, "md5_digest": "007a43cc280a2a7c81c20d412fdeee87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4886, "upload_time": "2016-10-29T23:25:00", "url": "https://files.pythonhosted.org/packages/8a/aa/25f333f77e9945fffa3a6f5c31a826d9671ac3f6bee3488c709552680f16/pyhooks-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "64da14390f4732c652dbf412d67b9764", "sha256": "e31053aeab249a08a1ae16bc514185147ce3a94b28567812fddfeda2f1eb6b8b" }, "downloads": -1, "filename": "pyhooks-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "64da14390f4732c652dbf412d67b9764", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6358, "upload_time": "2019-10-16T19:49:57", "url": "https://files.pythonhosted.org/packages/0f/16/d161f0d4ad32a92adea5ed38493fdb338d4225cdd798d63e576a184ac8e4/pyhooks-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fecab594a62a486ad189fcefb34d7fb8", "sha256": "2db2fae9e5b3b17aee18632f94e69cee378db34163a4a9aa1e95c63362acca4d" }, "downloads": -1, "filename": "pyhooks-1.0.1.tar.gz", "has_sig": false, "md5_digest": "fecab594a62a486ad189fcefb34d7fb8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4880, "upload_time": "2017-11-12T17:23:01", "url": "https://files.pythonhosted.org/packages/b6/4d/e8f55d8c0ba4314dc26b4f02b2ac42042690eb704c1ddb0a39f45eedfbc9/pyhooks-1.0.1.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "eb1655605eb0aecf2e88b7b1cf74a825", "sha256": "6c9bdc14fbc87bc97f935aadef56bbca42697205ca0b5d1291259868296144a7" }, "downloads": -1, "filename": "pyhooks-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "eb1655605eb0aecf2e88b7b1cf74a825", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6429, "upload_time": "2019-10-16T19:55:13", "url": "https://files.pythonhosted.org/packages/db/ee/9b01ffe55d589fcc380e5c396dd16eefd106ef5a315095e14c203610f469/pyhooks-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "97d80d8e30e13e283301f624a614cd2a", "sha256": "7c3e62349488b53ffcf40241ac061d89a269bc4e5d59c3cd448a5b8fe49ce7e0" }, "downloads": -1, "filename": "pyhooks-1.0.3.tar.gz", "has_sig": false, "md5_digest": "97d80d8e30e13e283301f624a614cd2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5007, "upload_time": "2019-10-16T19:55:15", "url": "https://files.pythonhosted.org/packages/bb/a1/0ae6105cbcd0ca5c3b7435e2bb55dbbe9f14530cae84a582066d5f541910/pyhooks-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eb1655605eb0aecf2e88b7b1cf74a825", "sha256": "6c9bdc14fbc87bc97f935aadef56bbca42697205ca0b5d1291259868296144a7" }, "downloads": -1, "filename": "pyhooks-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "eb1655605eb0aecf2e88b7b1cf74a825", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6429, "upload_time": "2019-10-16T19:55:13", "url": "https://files.pythonhosted.org/packages/db/ee/9b01ffe55d589fcc380e5c396dd16eefd106ef5a315095e14c203610f469/pyhooks-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "97d80d8e30e13e283301f624a614cd2a", "sha256": "7c3e62349488b53ffcf40241ac061d89a269bc4e5d59c3cd448a5b8fe49ce7e0" }, "downloads": -1, "filename": "pyhooks-1.0.3.tar.gz", "has_sig": false, "md5_digest": "97d80d8e30e13e283301f624a614cd2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5007, "upload_time": "2019-10-16T19:55:15", "url": "https://files.pythonhosted.org/packages/bb/a1/0ae6105cbcd0ca5c3b7435e2bb55dbbe9f14530cae84a582066d5f541910/pyhooks-1.0.3.tar.gz" } ] }