{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://travis-ci.org/siddheshsathe/handy-decorators.svg?branch=master)](https://travis-ci.org/siddheshsathe/handy-decorators)\n---\n# Handy Decorators\n---\nThis is a set of `handy decorators` which one can use for their day-to-day life coding.\n\n## Installation Method\nInstall it via pip\n```bash\npip install handy-decorators\n```\n\n## Description\nThe set of decorators contain some daily needed decorators for being used in our day to day coding life. This has following set of decorators.\n\n### trycatch\nThis decorator surounds your function with a `try-except` block and if your code/function raises an exception, it's caught by this decorator and reported by logging.\n```python\n>>> from decorators import trycatch\n>>> @trycatch\n... def func():\n... print(0/0) # Division by 0 must raise exception\n...\n>>> func()\nException occurred: [integer division or modulo by zero]\n>>>\n```\n\n### timer\nThis decorator will calculate a time required in seconds by your function for execution.\n```python\n>>> from decorators import timer\n>>> @timer\n... def a():\n... import time\n... print('Hi')\n... time.sleep(1)\n...\n>>> a()\nHi\nTime taken by the function is [1.00103902817] sec\n>>>\n```\n\n### singleton\nThis decorator is for making your class [`singleton`](https://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html).\n
\nThe features given by this decorator are:\n* If instances of same class are created with **same** args and kwargs, decorator will return previously existing instance\n* If instances of same class are created with **different** args and kwargs, decorator will create a different one for you and store the newly created instance\n\n```python\n>>> from decorators import singleton\n>>>\n>>> @singleton\n... class A:\n... def __init__(self, *args, **kwargs):\n... pass\n...\n>>>\n>>> a = A(name='Siddhesh')\n>>> b = A(name='Siddhesh', lname='Sathe')\n>>> c = A(name='Siddhesh', lname='Sathe')\n>>> a is b # has to be different\nFalse\n>>> b is c # has to be same\nTrue\n>>>\n```\n---\nPlease create an issue if more decorators are needed.\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": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "handy-decorators", "package_url": "https://pypi.org/project/handy-decorators/", "platform": "", "project_url": "https://pypi.org/project/handy-decorators/", "project_urls": null, "release_url": "https://pypi.org/project/handy-decorators/0.0.7/", "requires_dist": [ "logging" ], "requires_python": "", "summary": "Handy decorators for day-to-day use!", "version": "0.0.7" }, "last_serial": 5621807, "releases": { "0.0.7": [ { "comment_text": "", "digests": { "md5": "759263d00ad2bf12803cf00f732f6b27", "sha256": "953deea0a2836d2944436b2b2e6d9e4d980d9b37fc1a75b0fc95cbc8a018aa27" }, "downloads": -1, "filename": "handy_decorators-0.0.7-py2-none-any.whl", "has_sig": false, "md5_digest": "759263d00ad2bf12803cf00f732f6b27", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15446, "upload_time": "2019-08-01T13:04:03", "url": "https://files.pythonhosted.org/packages/bc/f8/99c760e4f1c6226add1b358a740fe1b1d5bb5fe488dd601acb1446a3bda2/handy_decorators-0.0.7-py2-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "759263d00ad2bf12803cf00f732f6b27", "sha256": "953deea0a2836d2944436b2b2e6d9e4d980d9b37fc1a75b0fc95cbc8a018aa27" }, "downloads": -1, "filename": "handy_decorators-0.0.7-py2-none-any.whl", "has_sig": false, "md5_digest": "759263d00ad2bf12803cf00f732f6b27", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15446, "upload_time": "2019-08-01T13:04:03", "url": "https://files.pythonhosted.org/packages/bc/f8/99c760e4f1c6226add1b358a740fe1b1d5bb5fe488dd601acb1446a3bda2/handy_decorators-0.0.7-py2-none-any.whl" } ] }