{ "info": { "author": "Eric V. Smith", "author_email": "eric@trueblade.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=======\ncalllib\n=======\n\nOverview\n========\n\n``calllib`` provides 3 functions, ``apply``, ``getargs``, and\n``inspect_params``. These functions are used to inspect and call\nPython functions whose parameters are not known in advance, but are\ndetermined at runtime from a mapping of available objects.\n\nThis is particularly useful in plug-in frameworks, where you don't\nwant every callback function to be required to have identical\nsignatures. Instead, each function can take a subset of available\nparameters.\n\nFor example::\n\n >>> from __future__ import print_function\n >>> import calllib\n\n >>> def callback1(time):\n ... print('callback1 called at:', time)\n\n >>> def callback2(time, reason):\n ... print('callback2 called at:', time, 'reason:', reason)\n\n # register the callbacks\n >>> callbacks = [callback1, callback2]\n\n # elsewhere: compute the total universe of possible\n # callback arguments\n >>> args = {'time': 'noon', 'reason': 'abort'}\n >>> for callback in callbacks:\n ... calllib.apply(callback, args) # execute each callback\n callback1 called at: noon\n callback2 called at: noon reason: abort\n\nThe last line shows that you can call any callback routine without\nknowing its exact arguments, as long as its arguments are a subset of\nthe available arguments.\n\napply()\n-------\n\n``apply(callable, args)``\n\n * `callable` - Any callable object that can be inspected with the\n `inspect` module.\n\n * `args` - A mapping object, typically a `dict`, that contains the\n available arguments that will be passed to `callable`.\n\n `callable` is inpsected with ``getargs`` and the its parameters are\n extracted by name. For each parameter the corresponding value is\n retrieved from `args` by name and passed to the callable.\n\n ``apply`` returns the result of executing `callable` with the\n computed arguments.\n\n\ngetargs()\n---------\n\n``getargs(callable, args)``\n\n * `callable` - Any callable object that can be inspected with the\n `inspect` module.\n\n * `args` - A mapping object, typically a `dict`, that contains the\n available arguments that could be passed to `callable`.\n\n `callable` is inspected to determine its parameters. For each\n parameter the corresponding value is retrieved from `args`. If a\n parameter is not found in args `callable` has a default value for\n that parameter, the default value is retrieved.\n\n ``getargs`` returns a list of actual argument values that would be\n passed to `callable`.\n\n\ninspect_params()\n----------------\n\n``inspect_params(callable)``\n\n * `callable` - Any callable object that can be inspected with the\n `inspect` module.\n\n `callable` is inspected to deterine its parameters and default\n values, if any. ``inspect_params`` returns a tuple containing a\n list of parameter names and a dict with default values, if any. For\n example::\n\n >>> def foo(x, y=0, z=6): pass\n ...\n >>> calllib.inspect_params(foo)\n (['x', 'y', 'z'], {'y': 0, 'z': 6})\n\n >>> class Baz(object):\n ... def __init__(self, x, y='hello'): pass\n ...\n >>> calllib.inspect_params(Baz)\n (['x', 'y'], {'y': 'hello'})\n\n\nTypes of callables supported\n============================\n\n``calllib`` supports any callable written in Python. This includes\nfunctions, bound and unbound methods, classes, and object instances\nwith `__call__` members.\n\nBecause they are not introspectable by the inspect module, built in\nPython functions such as ``len`` cannot be used with ``apply``.\n\nDefault arguments\n=================\n\nFunctions with default arguments are fully supported by\n``calllib``. If an argument is not specified in the `args` parameter\nto ``apply`` and it has a default, the default value will be used.\n\nTesting\n=======\n\nTo test, run 'python setup.py test'. On python >= 3.0, this also runs the doctests.\n\nChange log\n==========\n\n1.8 2016-10-27 Eric V. Smith\n----------------------------\n\n* Remove hack for changing RPM name (issue #7).\n\n* Always require setuptools (issue #6).\n\n* No code changes.\n\n1.7 2015-05-16 Eric V. Smith\n----------------------------\n\n* Removed 'test' package, so it won't get installed by bdist_*. It's still\n included in sdists.\n\n* No code changes.\n\n1.6 2015-05-15 Eric V. Smith\n----------------------------\n\n* Changed RPM name to python3-calllib if running with python 3.\n\n* No code changes.\n\n1.5 2014-12-07 Eric V. Smith\n----------------------------\n\n* Added inspect_params (issue #5).\n\n1.4 2014-07-24 Eric V. Smith\n----------------------------\n\n* Release version 1.4. No code changes.\n\n* Add a README.txt entry on running the test suite.\n\n* Fix missing test/__init__.py in the sdist.\n\n1.3 2014-03-14 Eric V. Smith\n----------------------------\n\n* Add MANIFEST.in to MANIFEST.in, so it will be included in sdists\n (issue #4).\n\n1.2 2014-02-12 Eric V. Smith\n----------------------------\n\n* New release just to update development status classifier.\n\n1.1 2014-02-12 Eric V. Smith\n----------------------------\n\n* Produce an RPM named python-calllib (issue #3).\n\n* Support python3 (issue #2).\n\n* Moved tests to a separate module (issue #1).\n\n1.0 2011-11-10 Eric V. Smith\n----------------------------\n\n* Finalized API.\n\n* Added tests for derived classes.\n\n0.2 2011-11-10 Eric V. Smith\n----------------------------\n\n* Allow for classes with no __init__ method.\n\n* Normalize test names.\n\n0.1 2011-11-09 Eric V. Smith\n----------------------------\n\n* Initial release.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/ericvsmith/calllib", "keywords": "", "license": "Apache License Version 2.0", "maintainer": "", "maintainer_email": "", "name": "calllib", "package_url": "https://pypi.org/project/calllib/", "platform": "", "project_url": "https://pypi.org/project/calllib/", "project_urls": { "Homepage": "https://bitbucket.org/ericvsmith/calllib" }, "release_url": "https://pypi.org/project/calllib/1.8/", "requires_dist": null, "requires_python": "", "summary": "A library to call Python functions with parameters determined at runtime by name.", "version": "1.8" }, "last_serial": 2426049, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "245dbb0681a1341ba12f5dba893777c3", "sha256": "51c5c9ba4f03e3b357b4c8b99eb8e17bb11a7aefebe73d720271974ed7557a5b" }, "downloads": -1, "filename": "calllib-1.0.tar.gz", "has_sig": false, "md5_digest": "245dbb0681a1341ba12f5dba893777c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8126, "upload_time": "2011-11-11T00:46:17", "url": "https://files.pythonhosted.org/packages/75/57/998a0031f635ed433203ea38aeeb91466f5763e2db9ec67e459f33f02919/calllib-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "1bd6c97ed622033dd9948bec8982233a", "sha256": "4115d5ac1b00888f7ec6304fe036fd4d059be09bc4d39cdc3a740e11dda119bf" }, "downloads": -1, "filename": "calllib-1.1.tar.gz", "has_sig": false, "md5_digest": "1bd6c97ed622033dd9948bec8982233a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9335, "upload_time": "2014-02-12T23:23:55", "url": "https://files.pythonhosted.org/packages/a7/d2/af5b04cbe03f9faf7187d63e430051dc9969ccf7e251aa2628ec0e3574d5/calllib-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "eda9d9e4968016985afac31fa53fc8d9", "sha256": "bda3f8e122688f6343104d10627d373e43963da660bb7a580befdd8cbe539fac" }, "downloads": -1, "filename": "calllib-1.2.tar.gz", "has_sig": false, "md5_digest": "eda9d9e4968016985afac31fa53fc8d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9386, "upload_time": "2014-02-13T01:09:03", "url": "https://files.pythonhosted.org/packages/4c/8e/ec683ca0b8258909d08c86762336ae6f2f6df321c97e03b93645e3d0207e/calllib-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "993eed5add11c8be07b03718a6909441", "sha256": "3494d0465ec875b92c2babd66fcd63780dcd5c4dad84f8e0fea0012cd12d50f7" }, "downloads": -1, "filename": "calllib-1.3.tar.gz", "has_sig": false, "md5_digest": "993eed5add11c8be07b03718a6909441", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9488, "upload_time": "2014-03-15T02:23:07", "url": "https://files.pythonhosted.org/packages/6c/a9/8aae2139f7e9b74b0c81299abd04c6a9ff53a6c74c492da8b35cc33d87cf/calllib-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "bbc751aaa4466eee72baa3d2f2f846e4", "sha256": "596a95a89f47f78de8247e442cae70ec2a4fe3ad88d077596436060f6f9558b3" }, "downloads": -1, "filename": "calllib-1.4.tar.gz", "has_sig": false, "md5_digest": "bbc751aaa4466eee72baa3d2f2f846e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9658, "upload_time": "2014-07-24T23:05:53", "url": "https://files.pythonhosted.org/packages/b7/70/6dd4eb6de6acc40e2a3b339f6011d0d01550ef40eeae004edc5685a80744/calllib-1.4.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "ba416216861c13f618844f8ebe44e006", "sha256": "fe52ed78da9e107de7bf46988c2a48b45bd47030fd299cb3544fe691aac168d5" }, "downloads": -1, "filename": "calllib-1.5.tar.gz", "has_sig": false, "md5_digest": "ba416216861c13f618844f8ebe44e006", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10270, "upload_time": "2014-12-08T00:39:34", "url": "https://files.pythonhosted.org/packages/f9/a1/03fac7ed636db303bb00a5d85e78635e35a307a3d782a56b516c1e72d481/calllib-1.5.tar.gz" } ], "1.6": [ { "comment_text": "", "digests": { "md5": "392f9552cce75bf81793bc23ae717a3f", "sha256": "65fb6e421b02bb898dbf788aa261ae71db0967d41062b382931af1c4be7a7aa6" }, "downloads": -1, "filename": "calllib-1.6.tar.gz", "has_sig": false, "md5_digest": "392f9552cce75bf81793bc23ae717a3f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10375, "upload_time": "2015-05-15T11:42:06", "url": "https://files.pythonhosted.org/packages/a6/8e/7b88eed173e697d72a062774ba559ee8377fe72492d5e3f5a938ce895d3a/calllib-1.6.tar.gz" } ], "1.7": [ { "comment_text": "", "digests": { "md5": "6ffc96802ddcfdd5de0902c47016e470", "sha256": "89f685047ede7956e108224b5bd5c302c26d5466fa88b42f061c188665ec5f43" }, "downloads": -1, "filename": "calllib-1.7.tar.gz", "has_sig": false, "md5_digest": "6ffc96802ddcfdd5de0902c47016e470", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10440, "upload_time": "2015-05-16T17:17:53", "url": "https://files.pythonhosted.org/packages/e1/d5/dd0a64ee85f086badf2fd183fd6fbeefbbeac9c6d08337e2c1abbc4b0ec5/calllib-1.7.tar.gz" } ], "1.8": [ { "comment_text": "", "digests": { "md5": "972356433fcb07ce70e636381a16873d", "sha256": "45e2b6ef7e2257b517b080eed5f8032f2201f25e29a43a51ed039233524159fd" }, "downloads": -1, "filename": "calllib-1.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "972356433fcb07ce70e636381a16873d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7714, "upload_time": "2016-10-27T12:28:39", "url": "https://files.pythonhosted.org/packages/f6/30/ced52c2f70ace43ab28f4d91103067e248783d598c26e13487cdf521951a/calllib-1.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d1f79335050c6d151868d045580558cf", "sha256": "7849715a5d0f10cbe32cc32ef7f2e2681552c49f7394215bcc187ce69d046377" }, "downloads": -1, "filename": "calllib-1.8.tar.gz", "has_sig": false, "md5_digest": "d1f79335050c6d151868d045580558cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12198, "upload_time": "2016-10-27T12:28:41", "url": "https://files.pythonhosted.org/packages/36/be/caa16bec5e8f405570dbe581745e011542cc6a62ff540baa276bb1fe8088/calllib-1.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "972356433fcb07ce70e636381a16873d", "sha256": "45e2b6ef7e2257b517b080eed5f8032f2201f25e29a43a51ed039233524159fd" }, "downloads": -1, "filename": "calllib-1.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "972356433fcb07ce70e636381a16873d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7714, "upload_time": "2016-10-27T12:28:39", "url": "https://files.pythonhosted.org/packages/f6/30/ced52c2f70ace43ab28f4d91103067e248783d598c26e13487cdf521951a/calllib-1.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d1f79335050c6d151868d045580558cf", "sha256": "7849715a5d0f10cbe32cc32ef7f2e2681552c49f7394215bcc187ce69d046377" }, "downloads": -1, "filename": "calllib-1.8.tar.gz", "has_sig": false, "md5_digest": "d1f79335050c6d151868d045580558cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12198, "upload_time": "2016-10-27T12:28:41", "url": "https://files.pythonhosted.org/packages/36/be/caa16bec5e8f405570dbe581745e011542cc6a62ff540baa276bb1fe8088/calllib-1.8.tar.gz" } ] }