{ "info": { "author": "Konrad Kocik", "author_email": "konrad.kocik@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "==========\nexceptbool\n==========\n\n.. image:: https://img.shields.io/pypi/v/exceptbool.svg\n :target: https://pypi.python.org/pypi/exceptbool\n\n.. image:: https://pepy.tech/badge/exceptbool\n :target: https://pepy.tech/badge/exceptbool\n\n.. image:: https://travis-ci.org/konrad-kocik/exceptbool.svg?branch=master\n :target: https://travis-ci.org/konrad-kocik/exceptbool.svg?branch=master\n\n.. image:: https://readthedocs.org/projects/exceptbool/badge/?version=latest\n :target: https://exceptbool.readthedocs.io/en/latest/?badge=latest\n\nConverts caught exception into bool value.\n\n* Free software: `MIT license`_\n* Documentation: https://exceptbool.readthedocs.io.\n* Issue reporting: https://github.com/konrad-kocik/exceptbool/issues/new\n\n.. _MIT license: https://opensource.org/licenses/MIT\n\nFeatures\n--------\n\nHow many of those have you written in your life?\n\n.. code-block:: python\n\n def is_something_possible():\n try:\n do_something()\n return True\n except DoingSomethingError:\n return False\n\nUgh! A perfect example of six-line boilerplate code. With exceptbool you can shorten that into only three lines!\n\n.. code-block:: python\n\n @except_to_bool(exc=DoingSomethingError)\n def is_something_possible():\n do_something()\n\nExceptbool makes decorated function return bool instead of raising an exception by converting given exception(s) into given bool value. If no exception will be raised, then negation of given bool will be returned. If exception different than given one will be raised, then it will not be caught.\n\nDon't want to decorate whole function? Fine, you can convert exception raised from chosen block of code by using context manager:\n\n.. code-block:: python\n\n with except_converter(exc=DoingSomethingError) as converted_exception:\n do_something()\n\n============\nInstallation\n============\n\nStable release\n--------------\n\nTo install exceptbool, run this command in your terminal:\n\n.. code-block:: console\n\n $ pip install exceptbool\n\nThis is the preferred method to install exceptbool, as it will always install the most recent stable release.\n\nIf you don't have `pip`_ installed, this `Python installation guide`_ can guide\nyou through the process.\n\n.. _pip: https://pip.pypa.io\n.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/\n\nFrom sources\n------------\n\nThe sources for exceptbool can be downloaded from the `Github repo`_.\n\nYou can either clone the public repository:\n\n.. code-block:: console\n\n $ git clone https://github.com/konrad-kocik/exceptbool.git\n\nOr download the `tarball`_:\n\n.. code-block:: console\n\n $ curl -OL https://github.com/konrad-kocik/exceptbool/tarball/master\n\nOnce you have a copy of the source, you can install it with:\n\n.. code-block:: console\n\n $ python setup.py install\n\n\n.. _Github repo: https://github.com/konrad-kocik/exceptbool\n.. _tarball: https://github.com/konrad-kocik/exceptbool/tarball/master\n\n=====\nUsage\n=====\n\nAs decorator\n------------\n\nFirst, import ``except_to_bool`` decorator into current namespace:\n\n.. code-block:: python\n\n from exceptbool import except_to_bool\n\nTo catch any exception and convert it into False:\n\n.. code-block:: python\n\n @except_to_bool\n def decorated_function():\n error_raising_function()\n\nNow ``decorated_function`` will return False if ``error_raising_function`` raises Exception, True otherwise.\n\nTo catch given exception and convert it into given bool value:\n\n.. code-block:: python\n\n @except_to_bool(exc=ValueError, to=True)\n def decorated_function():\n error_raising_function()\n\nNow ``decorated_function`` will return True if ``error_raising_function`` raises ValueError, False otherwise.\n\nTo catch any of multiple exceptions:\n\n.. code-block:: python\n\n @except_to_bool(exc=(TypeError, TimeoutError))\n def decorated_function():\n error_raising_function()\n\nNow ``decorated_function`` will return False if ``error_raising_function`` raises TypeError or TimeoutError, True otherwise.\n\nFunction decorated with ``except_to_bool`` is perfectly capable of accepting positional and keyword arguments:\n\n.. code-block:: python\n\n @except_to_bool\n def decorated_function(*args, **kwargs):\n error_raising_function(*args, **kwargs)\n\n decorated_function(\"foo\", bar=\"baz\") # no error\n\nAs context manager\n------------------\n\nFirst, import ``except_converter`` context manager into current namespace:\n\n.. code-block:: python\n\n from exceptbool import except_converter\n\nTo catch any exception and convert it into False:\n\n.. code-block:: python\n\n with except_converter() as converted_exception:\n error_raising_function()\n\nNow ``converted_exception.value`` will return False if ``error_raising_function`` raises Exception, True otherwise.\n\nTo catch given exception and convert it into given bool value:\n\n.. code-block:: python\n\n with except_converter(exc=ValueError, to=True) as converted_exception:\n error_raising_function()\n\nNow ``converted_exception.value`` will return True if ``error_raising_function`` raises ValueError, False otherwise.\n\nTo catch any of multiple exceptions:\n\n.. code-block:: python\n\n with except_converter(exc=(OSError, KeyError)) as converted_exception:\n error_raising_function()\n\nNow ``converted_exception.value`` will return False if ``error_raising_function`` raises OSError or KeyError, True otherwise.\n\n=======\nHistory\n=======\n\n1.2.1 (2019-01-19)\n------------------\n\n* Improved documentation.\n\n1.2.0 (2019-01-12)\n------------------\n\n* Added possibility to convert exceptions by using context manager.\n\n1.1.0 (2018-12-18)\n------------------\n\n* Added support for Python 3.5.\n\n1.0.1 (2018-12-12)\n------------------\n\n* Updated and improved documentation.\n\n1.0.0 (2018-12-10)\n------------------\n\n* First release on PyPI with basic functionality.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/konrad-kocik/exceptbool", "keywords": "except exception catching bool boolean decorator context manager", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "exceptbool", "package_url": "https://pypi.org/project/exceptbool/", "platform": "", "project_url": "https://pypi.org/project/exceptbool/", "project_urls": { "Homepage": "https://github.com/konrad-kocik/exceptbool" }, "release_url": "https://pypi.org/project/exceptbool/1.2.1/", "requires_dist": null, "requires_python": "", "summary": "Converts caught exception into bool value.", "version": "1.2.1" }, "last_serial": 4716161, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "7a2263d0c5d5256c312b0d8f31cd93d4", "sha256": "e047f6e81a5c2aece906fbb6f9cbda6767e38b814ff806fd45dd8e4446b51fd7" }, "downloads": -1, "filename": "exceptbool-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7a2263d0c5d5256c312b0d8f31cd93d4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4217, "upload_time": "2018-12-11T20:31:00", "url": "https://files.pythonhosted.org/packages/a2/74/6587c99dcd425c5f0469f0deaef6f980cb15a594224b4c08d68fb69baeb2/exceptbool-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "713006d3987781e4f08e0fbde2814846", "sha256": "ec940c1ba1f9c5db05f3f4e0509fce98f1769a4bcabf6e3951ef355e6fed55c9" }, "downloads": -1, "filename": "exceptbool-1.0.0.tar.gz", "has_sig": false, "md5_digest": "713006d3987781e4f08e0fbde2814846", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9175, "upload_time": "2018-12-11T20:31:02", "url": "https://files.pythonhosted.org/packages/1e/0f/5f58834e838e82f346fd847e4eb40621a27c651f2cf6500ea22cc35b3f89/exceptbool-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "e08d1e7a9c6843c3dcd1a7ffea507e2b", "sha256": "f8962ade4bdeca188af61cd4ec6dd2ba140dc7d3ae98d6c0e83079a1c2243549" }, "downloads": -1, "filename": "exceptbool-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e08d1e7a9c6843c3dcd1a7ffea507e2b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4521, "upload_time": "2018-12-12T20:49:50", "url": "https://files.pythonhosted.org/packages/76/d3/0808bd1744a5ee0c28761a3e1235a1e9e5b1053c95e0af56984ec3bc8b04/exceptbool-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0d21a898e3287d432b7651397fb36a52", "sha256": "8133248083f66d2d3399da9d0529a16f349f69a99eebfd8c9c76daa71e9d3d69" }, "downloads": -1, "filename": "exceptbool-1.0.1.tar.gz", "has_sig": false, "md5_digest": "0d21a898e3287d432b7651397fb36a52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9134, "upload_time": "2018-12-12T20:49:51", "url": "https://files.pythonhosted.org/packages/2b/68/7bbec7b562144d270c0b8974a56e739d6a3f84fb0a9b0ea2c02e6ca9b734/exceptbool-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "40e77d0ff510dc0f2bdba880cd95ab47", "sha256": "e759705848d2c22dcf0e449e40f55211821ba5eefd13eeebb5c7f396ee67c6df" }, "downloads": -1, "filename": "exceptbool-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "40e77d0ff510dc0f2bdba880cd95ab47", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4575, "upload_time": "2018-12-18T19:10:05", "url": "https://files.pythonhosted.org/packages/22/66/a9a0080e1f5a1ec6bfed27e815f856e3f1464e6d6533cc317a9367adf506/exceptbool-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5a9f2528011aa3b25d94460b5bf70394", "sha256": "7c175843f2b8858d6a5480d9e3fc944d46f1cafdc8c706b8e8d6e4e3b42fdcbc" }, "downloads": -1, "filename": "exceptbool-1.1.0.tar.gz", "has_sig": false, "md5_digest": "5a9f2528011aa3b25d94460b5bf70394", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9363, "upload_time": "2018-12-18T19:10:07", "url": "https://files.pythonhosted.org/packages/2f/b5/c842cc580af1998a4002d3653e27bc838f5bcdf64f5a5f43cce10acc130e/exceptbool-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "edc28da55df0c3b394d51508d7892a3f", "sha256": "ff13de167f04325dccf3b9af2d498b028a64ea7489dfa1313ebc97fef8b5700d" }, "downloads": -1, "filename": "exceptbool-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "edc28da55df0c3b394d51508d7892a3f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5865, "upload_time": "2019-01-12T22:03:35", "url": "https://files.pythonhosted.org/packages/84/75/acdd846d9350dcf62db3b6ebeddb1547e97c2ca2092fcac5f5cfcb9a3eb7/exceptbool-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0068df4897543960713c754668d12cfe", "sha256": "c2cf175b252f42c9c98c1fb7ff63bc08f30c5bd0cf69fc923612ae41f6e5bdd8" }, "downloads": -1, "filename": "exceptbool-1.2.0.tar.gz", "has_sig": false, "md5_digest": "0068df4897543960713c754668d12cfe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12060, "upload_time": "2019-01-12T22:03:37", "url": "https://files.pythonhosted.org/packages/0c/f4/f1d07d33aaed79e65270c141d7ce0069a05ebfb5746dc082544d548d506b/exceptbool-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "aebf324158b5ac1f40c9279560581064", "sha256": "16906ff3b72c924f1825d231121488efe94cfd02c159fd122d9bc83b44d65058" }, "downloads": -1, "filename": "exceptbool-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "aebf324158b5ac1f40c9279560581064", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5925, "upload_time": "2019-01-19T17:25:10", "url": "https://files.pythonhosted.org/packages/2b/d5/19100c6bf6967c9fe191968d46c712624bc7382e1163d7bb166dc8ac60eb/exceptbool-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5aaeab1692b28076fc711bd126d2746f", "sha256": "5a431cb0c533555be5a51f81bf45fb2881da3876090a188e8247d1c04c4f81a3" }, "downloads": -1, "filename": "exceptbool-1.2.1.tar.gz", "has_sig": false, "md5_digest": "5aaeab1692b28076fc711bd126d2746f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12323, "upload_time": "2019-01-19T17:25:12", "url": "https://files.pythonhosted.org/packages/19/04/098ec5975a2b911279238f9ccb7f7279b417d2623bd1e3e1493a35b06fa6/exceptbool-1.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "aebf324158b5ac1f40c9279560581064", "sha256": "16906ff3b72c924f1825d231121488efe94cfd02c159fd122d9bc83b44d65058" }, "downloads": -1, "filename": "exceptbool-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "aebf324158b5ac1f40c9279560581064", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5925, "upload_time": "2019-01-19T17:25:10", "url": "https://files.pythonhosted.org/packages/2b/d5/19100c6bf6967c9fe191968d46c712624bc7382e1163d7bb166dc8ac60eb/exceptbool-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5aaeab1692b28076fc711bd126d2746f", "sha256": "5a431cb0c533555be5a51f81bf45fb2881da3876090a188e8247d1c04c4f81a3" }, "downloads": -1, "filename": "exceptbool-1.2.1.tar.gz", "has_sig": false, "md5_digest": "5aaeab1692b28076fc711bd126d2746f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12323, "upload_time": "2019-01-19T17:25:12", "url": "https://files.pythonhosted.org/packages/19/04/098ec5975a2b911279238f9ccb7f7279b417d2623bd1e3e1493a35b06fa6/exceptbool-1.2.1.tar.gz" } ] }