{ "info": { "author": "Mirko Maelicke", "author_email": "mirko.maelicke@kit.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "DType-Decorate\n==============\n\nThe DType-Decorate module defines two different decorators at the current state. These decorators can be used to\nconstrain the attributes of the decorated function to specific data types. This can help to keep functions clean\nespecially when they are written for a specific context. This is usually the case for scientific applications,\nwhere functionality is often more important than clean code.\n\nThe basic structure of this module was heavily inspired / extended on the basis of:\nhttps://stackoverflow.com/questions/15299878/how-to-use-python-decorators-to-check-function-arguments\n\n\nInstallation\n~~~~~~~~~~~~\n\nYou can either use `pip` to install the version from PyPI or git to install the probably more recent version from\ngithub.\n\n.. code-block:: bash\n\n git clone http://github.com/mmaelicke/dtype-decorate.git\n cd dtype-decorate\n pip install -r requirements.txt\n python setup.py install\n\n\n.. code-block:: bash\n\n pip install dtype-decorate\n\n\nUsage\n~~~~~\n\nThere are two decorators so far: `accept` and `enforce`. `accept` will restrict the attribute data types to the\nthe defined ones, while `enforce` will try to convert the given attribute to a desired data type.\nBoth can also be used together, where `accept` does only make sense to be used after `enforce`.\n\nDefine a function that does only accept an `int` and a `float`.\n\n.. code-block:: python\n\n import ddec\n @ddec.accept(a=int, b=float)\n def f(a, b):\n pass\n\nYou can also specify more than one data type allowed. Any attribute not given in the decorator will just be\nignored.\n\n.. code-block:: python\n\n @ddec.accept(a=(int, float))\n def f(a, be_any_type)\n pass\n\n f(5, 'mystr') # will run fine\n f('mystr', 5) # will raise a TypeError\n\nThe `accept` decorator can also handle None type and callables like functions or lambda. These have to be specified\nas a string.\n\n.. code-block:: python\n\n @ddec.accept(a='None', b=('None', 'callable'))\n def f(a, b):\n pass\n\n f(None, None) # will run fine\n f(None, lambda x: x) # will run fine\n f(5, None) # will raise a TypeError", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dtype-decorate", "package_url": "https://pypi.org/project/dtype-decorate/", "platform": "", "project_url": "https://pypi.org/project/dtype-decorate/", "project_urls": null, "release_url": "https://pypi.org/project/dtype-decorate/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "data type check and conversion decorators", "version": "0.1.2" }, "last_serial": 3049532, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "45017b81e4cf4b40e2ace140a4c1cc7b", "sha256": "8038e32164641e4d1589ed2185768a294c32dab8e9e7c93f6e256c93d4ed6434" }, "downloads": -1, "filename": "dtype-decorate-0.1.1.tar.gz", "has_sig": false, "md5_digest": "45017b81e4cf4b40e2ace140a4c1cc7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5393, "upload_time": "2017-07-25T12:37:43", "url": "https://files.pythonhosted.org/packages/98/dc/7edfd522792e590d595827fb3dc79e1df9fa80043f23d400a21d2bacc02d/dtype-decorate-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "16325cdc9839d33b116333a45d138741", "sha256": "aa93f9213ab2548ea138482b3c48fcda10cd91dd70f1f485d3cdfd2c38907057" }, "downloads": -1, "filename": "dtype-decorate-0.1.2.tar.gz", "has_sig": false, "md5_digest": "16325cdc9839d33b116333a45d138741", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5686, "upload_time": "2017-07-26T08:54:07", "url": "https://files.pythonhosted.org/packages/f7/af/a851e97d825299c114039306899b391d5179de70f33c58eed0a2036d126e/dtype-decorate-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "16325cdc9839d33b116333a45d138741", "sha256": "aa93f9213ab2548ea138482b3c48fcda10cd91dd70f1f485d3cdfd2c38907057" }, "downloads": -1, "filename": "dtype-decorate-0.1.2.tar.gz", "has_sig": false, "md5_digest": "16325cdc9839d33b116333a45d138741", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5686, "upload_time": "2017-07-26T08:54:07", "url": "https://files.pythonhosted.org/packages/f7/af/a851e97d825299c114039306899b391d5179de70f33c58eed0a2036d126e/dtype-decorate-0.1.2.tar.gz" } ] }