{ "info": { "author": "Chad Lucas", "author_email": "cjlucas85@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5" ], "description": "Python terse Library\n====================\n\nThis module provides a collection of function decorators to handle\ncommon procedures done on the entry and exit points.\n\nInstallation\n------------\n\nThis library can be installed using pip with the following command.\n\n.. code:: bash\n\n pip install terse\n\nDirectory\n---------\n\nIn Directory\n~~~~~~~~~~~~\n\nBefore the function is executed, the current working directory is saved\nand the directory is changed to the provided **path**. After the\nfunction has completed, the directory is changed to the saved working\ndirectory. *Caution: This is intended for single threaded usage. Threads\nshould use absolute paths.*\n\n.. code:: python\n\n from terse import in_dir\n from glob import glob\n import os\n\n # Returns all files and directories at file system's root.\n @in_dir('/')\n def root_files():\n return glob('*')\n\n # Prints current working directory.\n print(os.getcwd())\n # Prints fils gathered from root.\n print(root_files())\n # Demonstrates current working directory is preserved.\n print(os.getcwd())\n\nInvoke\n------\n\nMain\n~~~~\n\nSets the function up to be the file's main function. If the file is\n**main**, then the function is executed. The return value will attempt\nto be converted to a value that can be passed to sys.exit; however if no\nvalue can be converted, it's assumed the function exited successfully.\n\nTraditionally in Python you do the following to create the main entry\npoint in the file.\n\n.. code:: python\n\n def main():\n print(\"Hello World!\")\n\n\n if __name__ == '__main__':\n main()\n\nThis can be replaced by the following.\n\n.. code:: python\n\n from terse import main\n\n @main\n def main_impl():\n print(\"Hello World!\")\n\nOn Exit\n-------\n\nNo Raise\n~~~~~~~~\n\nDecorator will catch all exceptions leaked or produced by callee. If\nprovided with **callback** function, then the callback will only be\ninvoked when an exception occurs. If provided with **instead\\_return**,\nthen the value will be returned when an exception occurs.\n\n.. code:: python\n\n from terse import no_except\n\n def log(function, exception):\n print('LOG: %s' % exception)\n\n # If exception is given, raise given exception.\n # Otherwise, return True\n @no_raise(instead_return=False, callback=log)\n def example(exception=None):\n if exception:\n raise exception\n return True\n\n # Example with no parameters raises no exceptions,\n # makes no calls to log, returns True.\n assert example() == True\n\n # Example with parameter raises given exception,\n # makes a call to log, surpresses exception and\n # returns False.\n assert example(False) == False\n\nOn Returned\n~~~~~~~~~~~\n\nDecorator will invoke **callback** whenever a value in **args** is\nreturned by function.\n\n.. code:: python\n\n from terse import on_returned\n from enum import Enum\n\n class Status(Enum):\n SUCCESS = 0\n FAILED = 1\n CONNECTION_FAILED = 2\n DISK_FAILED = 3\n\n def log(function, returned):\n print(\"LOG: %s\" % returned)\n\n # The following are examples for two uses of on_returned.\n # First is for any return value and the second is for a \n # set of return values.\n\n\n\n # ANY RETURN VALUE\n\n # Function example_any returns any value passed in.\n # on_returned will invoke log for any return value.\n @on_returned(log)\n def example_any(val):\n return val\n\n # Log invoked: prints \"LOG: Status.SUCCESS\"\n assert example_any(Status.SUCCESS) == Status.SUCCESS\n\n # Log invoked: prints \"LOG: Status.FAILED\"\n assert example_any(Status.FAILED) == Status.FAILED\n\n # Log invoked: prints \"LOG: None\"\n assert example_any(None) == None\n\n # Log invoked: prints \"LOG:1\"\n assert example_any(1) == 1\n\n\n\n # SET OF RETURN VALUES\n\n # Function example_set returns any value passed in.\n # on_returned will invoke log whenever values FAILED, \n # CONNECTION_FAILED or DISK_FAILED from enum Status are\n # returned by example.\n @on_returned(log, Status.FAILED, Status.CONNECTION_FAILED, Status.DISK_FAILED)\n def example_set(val):\n return val\n\n # log is not invoked.\n assert example_set(Status.SUCCESS) == Status.SUCCESS\n\n # Log invoked: prints \"LOG: Status.FAILED\"\n assert example_set(Status.FAILED) == Status.FAILED\n\n # Log invoked: prints \"LOG: Status.CONNECTION_FAILURE\"\n assert example_set(Status.CONNECTION_FAILED) == Status.CONNECTION_FAILED\n\n # Log invoked: prints \"LOG: Status.DISK_FAILURE\"\n assert example_set(Status.DISK_FAILED) == Status.DISK_FAILED\n\nOn Raised\n~~~~~~~~~\n\nDecorator will invoke **callback** whenever exception of type in\n**args** is raised by function.\n\n.. code:: python\n\n from terse import on_exception\n\n def log(function, exception):\n print(returned)\n\n # The following are examples for two uses of on_raised.\n # First is for any exception and the second is a set of\n # exceptions.\n\n\n\n # ANY EXCEPTION EXAMPLE\n\n # If exception is given, raise given exception.\n # Otherwise, return True\n # on_raised will invoke log for all exceptions\n # raised by example_any.\n @on_raised(log)\n def example_any(exception=None)\n if exception:\n raise exception\n return True\n\n # example_any is given no exceptions to throw.\n # Therefore, it will raise nothing and return True.\n assert example_any() == True\n\n # example_any is given ZeroDivisionError exception.\n # It will raise ZeroDivisionError instance.\n # on_raised detects exception raised and invokes log.\n try:\n example_any(ZeroDivisionError())\n assert False\n except ZeroDivisionError:\n pass\n\n # example_any is given ValueError exception.\n # It will raise ValueError instance.\n # on_raised detects exception raised and invokes log.\n try:\n example_any(ValueError())\n assert False\n except ValueError:\n pass\n\n # example_any is given KeyError exception.\n # It will raise KeyError instance.\n # on_raised detects exception raised and invokes log.\n try:\n example_any(KeyError())\n assert False\n except ValueError:\n pass\n\n\n\n # SET OF EXCEPTIONS EXAMPLE\n\n # If exception is given, raise given exception.\n # Otherwise, return True.\n # on_raised will only invoke log for ZeroDivisionError\n # and ValueError. All other exceptions are ignored by\n # on_raised.\n @on_raised(log, ZeroDivisionError, ValueError)\n def example_set(exception=None)\n if exception:\n raise exception\n return True\n\n # example_set is given no exceptions to throw.\n # Therefore, it will raise nothing and return True.\n assert example_set() == True\n\n # example_set is given ZeroDivisionError exception.\n # It will raise ZeroDivisionError instance.\n # on_raised detects exception raised and invokes log.\n try:\n example_set(ZeroDivisionError())\n assert False\n except ZeroDivisionError:\n pass\n\n # example_set is given ValueError exception.\n # It will raise ValueError instance.\n # on_raised detects exception raised and invokes log.\n try:\n example_set(ValueError())\n assert False\n except ValueError:\n pass\n\n # example_set is given KeyError exception.\n # It will raise KeyError instance.\n # example_set detects exception, but it will not\n # invoke log because KeyError is not in the set of\n # exceptions to be tracked.\n try:\n example_set(KeyError())\n assert False\n except ValueError:\n pass\n\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/cjlucas85/terse", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "terse", "package_url": "https://pypi.org/project/terse/", "platform": "", "project_url": "https://pypi.org/project/terse/", "project_urls": { "Homepage": "https://github.com/cjlucas85/terse" }, "release_url": "https://pypi.org/project/terse/0.0.9/", "requires_dist": null, "requires_python": "", "summary": "a collection of function decorators to handle common procedures done on the entry and exit points.", "version": "0.0.9" }, "last_serial": 4833752, "releases": { "0.0.1": [], "0.0.2": [ { "comment_text": "", "digests": { "md5": "7d9f7f95984fc51971861cc98ab5dd81", "sha256": "3ac4bcfad2cffa17d239a9a8699ee1c93d2c8a63ea173c713f45c53822ed394d" }, "downloads": -1, "filename": "terse-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7d9f7f95984fc51971861cc98ab5dd81", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6678, "upload_time": "2018-07-23T01:37:16", "url": "https://files.pythonhosted.org/packages/1c/98/93c53b53007a003b2ac3b0c7bbebe073842146384a6cb3328c1f4a16d967/terse-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0eb254f761ebba2be88d226ce3259258", "sha256": "22b912902bfbb27ff3eed0b1a6ebf14b24fc0ece48763b3abbcb7d1a1e039a91" }, "downloads": -1, "filename": "terse-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0eb254f761ebba2be88d226ce3259258", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3788, "upload_time": "2018-07-23T01:37:17", "url": "https://files.pythonhosted.org/packages/fa/d5/ffd0d0af370795b42f5162f3e5739769ddb6e6d2b7a583d7d73717c16b7a/terse-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "b20c133350cdc4344548d36339a6f87f", "sha256": "ebfa537556d660cbc2605ff5d6266f80000fe7b2a743d157b56cc9c660a79568" }, "downloads": -1, "filename": "terse-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b20c133350cdc4344548d36339a6f87f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6677, "upload_time": "2018-07-23T01:57:40", "url": "https://files.pythonhosted.org/packages/aa/41/8199cc5f88708cb7cc0c45ff17f789df2139f8bdad69ba10ee397722b171/terse-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1366a16f42f73afd060849ff1b897045", "sha256": "851d95cd48f79631c35a535dba2d167ba50f950dee2bf625282b2427e443caea" }, "downloads": -1, "filename": "terse-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1366a16f42f73afd060849ff1b897045", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3751, "upload_time": "2018-07-23T01:57:41", "url": "https://files.pythonhosted.org/packages/2e/59/cffc47a5041674a9c63f4c42d455dbef1395e75124c8ba389f67a2c9b71a/terse-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "86109d41377a31206139a784b3ef57a6", "sha256": "0f5c70d96d1b7f92d14d317032d8e9ab4ca2a412bafbf2dd82b1f1e7661804ef" }, "downloads": -1, "filename": "terse-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "86109d41377a31206139a784b3ef57a6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6963, "upload_time": "2018-07-23T02:12:34", "url": "https://files.pythonhosted.org/packages/3b/a3/d9c1fe74f6f508d355313c2759217e6ccfe0d9019e3eaa509d69377039c0/terse-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4088a00b62c2496e41ee3fee87df7fb4", "sha256": "052bedbf6d73eebf2d31c3aad6fb79d46277497746e982374104bb4f0bef72be" }, "downloads": -1, "filename": "terse-0.0.4.tar.gz", "has_sig": false, "md5_digest": "4088a00b62c2496e41ee3fee87df7fb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3941, "upload_time": "2018-07-23T02:12:35", "url": "https://files.pythonhosted.org/packages/bf/89/1ec8f59b145e3acd5f8a1ec553335388156af0bf19efb978fe924ff09bf2/terse-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "641564de045b490536941863074c62b9", "sha256": "ff8bae56e377a225ea9d66ba039690a5d4d926e2443b7214d9e8045257396d45" }, "downloads": -1, "filename": "terse-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "641564de045b490536941863074c62b9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7357, "upload_time": "2018-07-23T05:44:32", "url": "https://files.pythonhosted.org/packages/5d/27/c25eaf36fa25b5f3dd9018081655906ca617f91e19162a7d7223ac39ba6e/terse-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "186846689e06f8f59b6c9cfcef604c38", "sha256": "cab56024b13f1fb36bbf07c131172efce870e051f73a52b6c050b872aa960402" }, "downloads": -1, "filename": "terse-0.0.5.tar.gz", "has_sig": false, "md5_digest": "186846689e06f8f59b6c9cfcef604c38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4260, "upload_time": "2018-07-23T05:44:33", "url": "https://files.pythonhosted.org/packages/43/37/7ab8848237f15dc259dab14929730a2ab885c996c84c46156646befa7504/terse-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "299e0e98c3266899fb3a2dca208cf572", "sha256": "2e3822195dc4fadba311b375b385d294fab9749981576a41cc179404694e5117" }, "downloads": -1, "filename": "terse-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "299e0e98c3266899fb3a2dca208cf572", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9157, "upload_time": "2018-07-30T03:10:24", "url": "https://files.pythonhosted.org/packages/30/52/79b65ef359ba59b31fd2ab7d208d598dc69b1cf8e644bf4f36836a0b3393/terse-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2f746a8e12b053a5d1fea3bf63297ca2", "sha256": "3eb93dedf50ff17f2b9320c2f2871c0ea9e67100d41e46b4bf8dd58290ec1a2c" }, "downloads": -1, "filename": "terse-0.0.6.tar.gz", "has_sig": false, "md5_digest": "2f746a8e12b053a5d1fea3bf63297ca2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5707, "upload_time": "2018-07-30T03:10:26", "url": "https://files.pythonhosted.org/packages/07/72/b0522dd4a5dec0e874e77a74064941cc6ce73d2e466dde01e432bd09113a/terse-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "053f4101e521c2fdcf7a0c30c2008660", "sha256": "fc8ccbab09f2166dd23597ac71be4b0e294a5f50e6d86448ff4caf5e930a0f41" }, "downloads": -1, "filename": "terse-0.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "053f4101e521c2fdcf7a0c30c2008660", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10558, "upload_time": "2018-08-05T07:18:07", "url": "https://files.pythonhosted.org/packages/81/bd/ce5cffe2ff70e1c7b12a443df0b5757d69dfc7bd86403059b14382b2b45b/terse-0.0.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fb4b79911963c175b9a397ff9ff54b34", "sha256": "fd126a167a0f75c22c0379dccf7f9a3b510ac61b10af04507c355b623a0c9233" }, "downloads": -1, "filename": "terse-0.0.7.tar.gz", "has_sig": false, "md5_digest": "fb4b79911963c175b9a397ff9ff54b34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8104, "upload_time": "2018-08-05T07:18:08", "url": "https://files.pythonhosted.org/packages/9c/8f/b271cf5b98c7c745c7ac845e6faad508c41b1405a0334bca663fa6196b32/terse-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "ebe11b4f43035e9c05b4fffdbf7b3628", "sha256": "0869d61668fe2b10780212f77d4ff85a84041460509e8dd65853aeefd24d0ce4" }, "downloads": -1, "filename": "terse-0.0.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ebe11b4f43035e9c05b4fffdbf7b3628", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10559, "upload_time": "2018-08-09T05:51:37", "url": "https://files.pythonhosted.org/packages/0a/ef/2fb78f3e6458b2351ef0dc14ee74a187786a0f3ff18fa99521d87d3e6025/terse-0.0.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9f4ad7ecfbb89cea94b28d72215d3813", "sha256": "94ee7e8f3e60981f78fe1824d64bcc0fd684d0a5c71b6c88f41c05110db09c21" }, "downloads": -1, "filename": "terse-0.0.8.tar.gz", "has_sig": false, "md5_digest": "9f4ad7ecfbb89cea94b28d72215d3813", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8115, "upload_time": "2018-08-09T05:51:39", "url": "https://files.pythonhosted.org/packages/9b/1a/6fff3cc369c8ffe4b2163dcd959b891148ce35192e7eec4dccb656cdbdd7/terse-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "cba6715e01f033916b7d152a291a14b5", "sha256": "3847721ffb794337d664910d382cdebe28d5924b668a5b16f5371d12c819d3d5" }, "downloads": -1, "filename": "terse-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cba6715e01f033916b7d152a291a14b5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10559, "upload_time": "2019-02-18T07:34:59", "url": "https://files.pythonhosted.org/packages/f8/18/00573b456cfc96623002036489c7179af8c8892fdafd1a4242c85b0591b1/terse-0.0.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21b5a73fe69d588afe3e70b3d4aea4de", "sha256": "bf5ff17717fd632126e5064ef8a96895be546538440581c72d60d606312bccdc" }, "downloads": -1, "filename": "terse-0.0.9.tar.gz", "has_sig": false, "md5_digest": "21b5a73fe69d588afe3e70b3d4aea4de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8039, "upload_time": "2019-02-18T07:35:01", "url": "https://files.pythonhosted.org/packages/e3/8c/f55e7aadf067c971234ab695ad5b2b45fbfcb7670a60693ae5923a2a88dc/terse-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cba6715e01f033916b7d152a291a14b5", "sha256": "3847721ffb794337d664910d382cdebe28d5924b668a5b16f5371d12c819d3d5" }, "downloads": -1, "filename": "terse-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cba6715e01f033916b7d152a291a14b5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10559, "upload_time": "2019-02-18T07:34:59", "url": "https://files.pythonhosted.org/packages/f8/18/00573b456cfc96623002036489c7179af8c8892fdafd1a4242c85b0591b1/terse-0.0.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21b5a73fe69d588afe3e70b3d4aea4de", "sha256": "bf5ff17717fd632126e5064ef8a96895be546538440581c72d60d606312bccdc" }, "downloads": -1, "filename": "terse-0.0.9.tar.gz", "has_sig": false, "md5_digest": "21b5a73fe69d588afe3e70b3d4aea4de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8039, "upload_time": "2019-02-18T07:35:01", "url": "https://files.pythonhosted.org/packages/e3/8c/f55e7aadf067c971234ab695ad5b2b45fbfcb7670a60693ae5923a2a88dc/terse-0.0.9.tar.gz" } ] }