{ "info": { "author": "David Shriver", "author_email": "davidshriver@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Testing" ], "description": "Intercepts\n==========\n\n[![Build Status](https://travis-ci.org/dlshriver/intercepts.svg?branch=master)](https://travis-ci.org/dlshriver/intercepts)\n[![PyPI](https://img.shields.io/pypi/v/intercepts.svg)](https://pypi.org/project/intercepts/)\n[![license](https://img.shields.io/github/license/dlshriver/intercepts.svg)](https://github.com/dlshriver/intercepts/blob/master/LICENSE)\n\nIntercepts allows you to intercept any function call in Python and handle it in any manner you choose. For example, you can pre-process the inputs to a function, or apply post-processing on its output. Intercepts also allows you to completely replace a function with a custom implementation.\n\n```python\n>>> increment(41)\n42\n>>> intercepts.register(increment, handler)\n>>> increment(41)\n40\n>>> intercepts.unregister(increment)\n>>> intercepts.register(increment, handler2)\n>>> increment(41)\n'The answer is: 42'\n>>> intercepts.unregister_all()\n```\n\nHandler functions receive the intercepted function as their first argument, as well as all of the arguments to the intercepted function.\n\n```python\n>>> def handler(func, num):\n... result = func(num)\n... return num - (result - num)\n>>> def handler2(func, *args, **kwargs):\n... return \"The answer is: %s\" % func(*args, **kwargs)\n```\n\nThe intercepts module also allows intercepting python built-in functions, such as `print` and `sorted`. For best results, the intercepts module should be the first module imported.\n\n```python\n>>> def print_handler(print_func, message):\n... return print_func(''.join(reversed(message)))\n>>> print(\"Hello world\")\nHello world\n>>> intercepts.register(print, print_handler)\n>>> print(\"Hello world\")\ndlrow olleH\n```\n\nRequirements\n------------\n\nIntercepts requires python 3.5+. There are currently no additional dependencies.\n\nInstallation\n------------\n\nIntercepts can be installed using `pip`.\n\n $ pip install intercepts\n\nOr, use `pip` to install the latest version from the github source.\n\n $ pip install -U git+https://github.com/dlshriver/intercepts.git@master\n\nDocumentation\n-------------\n\nSome documentation is available [here](https://intercepts.readthedocs.io/en/latest/).\n\n***This software is in early stages of development and may be unstable.***", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dlshriver/intercepts", "keywords": "intercepts testing development", "license": "", "maintainer": "", "maintainer_email": "", "name": "intercepts", "package_url": "https://pypi.org/project/intercepts/", "platform": "", "project_url": "https://pypi.org/project/intercepts/", "project_urls": { "Homepage": "https://github.com/dlshriver/intercepts", "Issues": "https://github.com/dlshriver/intercepts/issues", "Source": "https://github.com/dlshriver/intercepts/" }, "release_url": "https://pypi.org/project/intercepts/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "Intercept function and method calls", "version": "0.3.1" }, "last_serial": 5269451, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "a54e57bbe69e50db0903ab908fd7ae6e", "sha256": "ca1fad2eb4d444026d73d64ef7eff4acea55894f1000a80c146c24e2a32075cb" }, "downloads": -1, "filename": "intercepts-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a54e57bbe69e50db0903ab908fd7ae6e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4378, "upload_time": "2018-04-21T21:05:19", "url": "https://files.pythonhosted.org/packages/ef/77/43aff8a7382c72916da015a7cb60c5a1ef64c6f86558013dac47380cca40/intercepts-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9c8a24900f840a25a3d3e13395e3006c", "sha256": "a826b73bb5448ce43024d915dc3685864ebfa92a8d5361d44e780a90950eef15" }, "downloads": -1, "filename": "intercepts-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9c8a24900f840a25a3d3e13395e3006c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5541, "upload_time": "2018-04-21T21:05:21", "url": "https://files.pythonhosted.org/packages/ff/0d/3928eca852dfcd22fd790fe58d99263b7c2264c4d71254f8cf2e0ebe60ec/intercepts-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "9c8ed99d55d7d0a411cd893436df5e05", "sha256": "2f3f5cf53045b38315cf6280dd3d893556ac454f1799b578f6d72667767700cc" }, "downloads": -1, "filename": "intercepts-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9c8ed99d55d7d0a411cd893436df5e05", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4831, "upload_time": "2018-08-05T16:40:26", "url": "https://files.pythonhosted.org/packages/3c/df/08d6b4451d17ca4417911c5271e82c27af0d1ab167e0cd4b02dbc839253a/intercepts-0.2.0-py2.py3-none-any.whl" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "9dcf9f14320a89f7c5e3551efdf75151", "sha256": "20d5c61321fc4deec50a6d6e09e18dcbfff96b07cc3fa57e46dec52cb0b34b04" }, "downloads": -1, "filename": "intercepts-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9dcf9f14320a89f7c5e3551efdf75151", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6875, "upload_time": "2019-03-16T16:31:40", "url": "https://files.pythonhosted.org/packages/20/6f/1284ce8d9295038a60010f00a0b68a79c237c90de0e5c493ba1a7ada4818/intercepts-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b74b99cdf0f538b54defd138c9cee78f", "sha256": "4435d67912496ce3ff3157f5655e8fa267faa62474bffccfdeec6fe7ef54f316" }, "downloads": -1, "filename": "intercepts-0.3.0.tar.gz", "has_sig": false, "md5_digest": "b74b99cdf0f538b54defd138c9cee78f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8147, "upload_time": "2019-03-16T16:31:41", "url": "https://files.pythonhosted.org/packages/24/8c/ae3f22b059fd5147367cccc1368478a4ea36dc07034f963214916672d487/intercepts-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "42d33599dd94b04040c24f4fafb39e74", "sha256": "35d74c5ca0a4c2c47d34acada99819bbdf505e1d973f8db962e25f1ce906e215" }, "downloads": -1, "filename": "intercepts-0.3.1.tar.gz", "has_sig": false, "md5_digest": "42d33599dd94b04040c24f4fafb39e74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12623, "upload_time": "2019-05-14T21:25:17", "url": "https://files.pythonhosted.org/packages/a1/e9/88f5dbf67707ce994d4f2b92e27eac45595161e92b5e7a2031b498ee9a92/intercepts-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "42d33599dd94b04040c24f4fafb39e74", "sha256": "35d74c5ca0a4c2c47d34acada99819bbdf505e1d973f8db962e25f1ce906e215" }, "downloads": -1, "filename": "intercepts-0.3.1.tar.gz", "has_sig": false, "md5_digest": "42d33599dd94b04040c24f4fafb39e74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12623, "upload_time": "2019-05-14T21:25:17", "url": "https://files.pythonhosted.org/packages/a1/e9/88f5dbf67707ce994d4f2b92e27eac45595161e92b5e7a2031b498ee9a92/intercepts-0.3.1.tar.gz" } ] }