{ "info": { "author": "bennr01", "author_email": "benjamin99.vogt@web.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Quality Assurance", "Topic :: Software Development :: Testing", "Topic :: Utilities" ], "description": "# benterfaces - Interface utilities and plugin system\n[![Travis](https://img.shields.io/travis/bennr01/benterfaces.svg)]()\n[![Coveralls github](https://img.shields.io/coveralls/github/bennr01/benterfaces.svg)]()\n[![GitHub issues](https://img.shields.io/github/issues/bennr01/benterfaces.svg)](https://github.com/bennr01/benterfaces/issues)\n[![GitHub license](https://img.shields.io/github/license/bennr01/benterfaces.svg)](https://github.com/bennr01/benterfaces/blob/master/LICENSE)\n\n\n`benterfaces` contains miscellaneous interface utilities and a plugin system.\n\n# Interface utilities\n**@verify_implementation**\nA simple decorator for verifying interface implementations when a class is created.\nFor example, the following code would raise a BrokenImplementationError if FooBar would not implement IFoo or IBar correctly.\n\n```python\nfrom zope.interfaces import implementer\nfrom benterfaces import verify_implementation\n\nfrom imyproject import IFoo, IBar\n\n\n@verify_implementation\n@implementer(IFoo, IBar)\nclass FooBar(object):\n ...\n\n\n```\n\nThis is useful if your interfaces may change during the developement process.\nAlso, its a single line (+import), so its not much work to add.\n\n\n# Plugin system\nThe plugin system provides an easy way to make your scripts extendandable.\nHere is a list of some features of the plugin system:\n- plugin priority support (you can use this feature to allow plugins to overwrite each other)\n- plugin requirement support (enable/disable plugins depending on conditions and installed modules)\n- load plugins from multiple paths\n- load plugins from python source files of any file extension\n- load plugins from `.pyc`-files\n\n\n**PluginDiscoverer(paths, extensions=[\".py\"])**\n\nThis class handles the plugin discovery and loading.\nArguments:\n- `paths`: list of strings specifying directories to search for plugins.\n- `extensions`: list of file extensions in which plugins will be searched for.\n\nImportant methods and attributes:\n- `load_plugins(max_depth=9999)`: load plugins from self.paths. Descend at most `max_depth` directories.\n- `loaded`: number of loaded plugins\n- `enabled`: number of enabled plugins\n- `clear_plugin_list()`: clears the internal plugin cache.\n- `reload_plugins()`: clears the internal plugin cache and the load the plugins again.\n- `get_implementation(self, iface, exclude=[])`: returns the plugin implementing `iface` with the highest priority which is not in `exclude`. This raises a `NotImplementedError` if no plugin if found.\n- `get_plugin(...)`: same as `get_implementation()`.\n- `get_all_plugins(self, iface, exclude=[], sorted_by_priority=True)`: returns a list of all plugins implementing iface excluding `exclude`.\n- `is_implemented(iface, exclude=[])`: returns True if iface is implemented by any plugin excluding `exclude`, otherwise False.\n\n\n**@requires(condition=True, modules=[])**\n\nThis decorator function marks the requirements of a plugin.\nArguments:\n- `condition`: a boolean which must be `True` in order for the plugin to be enabled.\n- `modules`: a list of module names which are required for the plugin to be enabled.\nPlugins without a `@requires(...)` decorator are always enabled.\n\n\n**@priority(n=0)**\n\nThis decorator function sets the priority of a plugin.\nHigher values for `n` mean a higher priority.\nPlugins without a `@priority(...)` decorator are considered to have a priority of `0`.\n\n\n# Using plugins\n**Creating a plugin**\nCreating a plugin is simple:\n1. create a file containing a `zope.interface.Interface`-definition which can be imported from your project and the plugin directory.\n2. create one or more plugin directories\n3. create a `.py` file inside the plugin directory containing an implementation of the plugin (remember to implement the Interface)\n4. Done.\n\n**loading plugins**\nTo load your plugins, just do the following:\n1. import `benterfaces.PluginDiscoverer()`\n2. create an instance of `benterfaces.PluginDiscoverer(paths)`, passing the plugin directories as `paths`.\n3. call the `.load_plugins()` method of the instance.\n4. Depending on your use case, use `get_plugin(iface)` or `get_all_plugins(iface)` to access the plugins.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bennr01/benterfaces/", "keywords": "interface interfaces utilities plugin plugins", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "benterfaces", "package_url": "https://pypi.org/project/benterfaces/", "platform": "", "project_url": "https://pypi.org/project/benterfaces/", "project_urls": { "Homepage": "https://github.com/bennr01/benterfaces/" }, "release_url": "https://pypi.org/project/benterfaces/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "interface utilities", "version": "0.1.1" }, "last_serial": 3958760, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "fc66c3332f5905716d2569c210474ca6", "sha256": "49104457b7126a3b77d2fed34c85ee72586e1885ccd172542dd12954abce654b" }, "downloads": -1, "filename": "benterfaces-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "fc66c3332f5905716d2569c210474ca6", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8464, "upload_time": "2018-02-11T22:21:01", "url": "https://files.pythonhosted.org/packages/95/ce/c07a8d74b03b294caae3e494147b65db55d1eaaa0202fb9942bf8481093d/benterfaces-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b6ea059eee65f44baca82abc5bcd9f1a", "sha256": "25e8fc8914f14489905332388d73553c6e57d0bba958caa4e5960c3f52e19bf0" }, "downloads": -1, "filename": "benterfaces-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b6ea059eee65f44baca82abc5bcd9f1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5128, "upload_time": "2018-02-11T22:20:59", "url": "https://files.pythonhosted.org/packages/dc/37/1cb3bb5ec66817c0096a94b688e43a642dbefb62a83a0c06b8d3440ed647/benterfaces-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "445efeefd5fc6e093387b4e6029af058", "sha256": "c3f17ab0cdea610215bab668eb05f040a0893d27ef8b852de0fcc560d6d1bca4" }, "downloads": -1, "filename": "benterfaces-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "445efeefd5fc6e093387b4e6029af058", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8959, "upload_time": "2018-02-19T18:45:23", "url": "https://files.pythonhosted.org/packages/d0/3c/0797eec57ec910e00be845cc0224e84712721bd296a1be645a8b41061d96/benterfaces-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "000a89cf4ba4d686d16306acd3e9c763", "sha256": "f46c91fa3fdae7d9dcc3603d1abe03c9c68d61d9c7279218e1a0d328805b2c4f" }, "downloads": -1, "filename": "benterfaces-0.1.0.tar.gz", "has_sig": false, "md5_digest": "000a89cf4ba4d686d16306acd3e9c763", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5621, "upload_time": "2018-02-19T18:44:34", "url": "https://files.pythonhosted.org/packages/25/de/16d874fdc79fa0ea8466050905e6a76aba29c0331d1c676803e89b541e84/benterfaces-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ed2bfae11d8032729564da47e7d8d4af", "sha256": "2ffaabf82e7eb1ac146af68be922e96e3a2c0b195ff0ed80a699889d0560a032" }, "downloads": -1, "filename": "benterfaces-0.1.1-py2-none-any.whl", "has_sig": false, "md5_digest": "ed2bfae11d8032729564da47e7d8d4af", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9276, "upload_time": "2018-06-13T18:50:02", "url": "https://files.pythonhosted.org/packages/a0/99/37f2311efb7f1fdb0bd6e1e133b8ec416df5258da3e5c3ea5979ff0b7a81/benterfaces-0.1.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9aed81e76fcfb88a19eb0f906c47254", "sha256": "52cab61229dc9632c0fc74a32161cfcbff0d6f0489f6dd7e9a62e540217e4962" }, "downloads": -1, "filename": "benterfaces-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e9aed81e76fcfb88a19eb0f906c47254", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5918, "upload_time": "2018-06-13T18:50:01", "url": "https://files.pythonhosted.org/packages/53/cc/17a29a7d9114b1b138dd735abc64bb4d5047027cd22b5182074f24a90e49/benterfaces-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ed2bfae11d8032729564da47e7d8d4af", "sha256": "2ffaabf82e7eb1ac146af68be922e96e3a2c0b195ff0ed80a699889d0560a032" }, "downloads": -1, "filename": "benterfaces-0.1.1-py2-none-any.whl", "has_sig": false, "md5_digest": "ed2bfae11d8032729564da47e7d8d4af", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9276, "upload_time": "2018-06-13T18:50:02", "url": "https://files.pythonhosted.org/packages/a0/99/37f2311efb7f1fdb0bd6e1e133b8ec416df5258da3e5c3ea5979ff0b7a81/benterfaces-0.1.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9aed81e76fcfb88a19eb0f906c47254", "sha256": "52cab61229dc9632c0fc74a32161cfcbff0d6f0489f6dd7e9a62e540217e4962" }, "downloads": -1, "filename": "benterfaces-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e9aed81e76fcfb88a19eb0f906c47254", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5918, "upload_time": "2018-06-13T18:50:01", "url": "https://files.pythonhosted.org/packages/53/cc/17a29a7d9114b1b138dd735abc64bb4d5047027cd22b5182074f24a90e49/benterfaces-0.1.1.tar.gz" } ] }