plugin – Plugin loader¶
The plugin module implements a sophisticated, featureful plugin loader with interface-based discovery.
- bravo.plugin.expand_names(plugins, names)[source]¶
Given a list of names, expand wildcards and discard disabled names.
Used to implement * and - options in plugin lists.
Parameters: Returns: a list of filtered plugin names
- bravo.plugin.get_plugins(interface, package)[source]¶
Lazily find objects in a package which implement a given interface.
This is a rewrite of Twisted’s twisted.plugin.getPlugins which searches for implementations of interfaces rather than providers.
Parameters: - interface (interface) – the interface to match against
- package (str) – the name of the package to search
- bravo.plugin.retrieve_named_plugins(interface, names, **kwargs)[source]¶
Look up a list of plugins by name.
Plugins are returned in the same order as their names.
Parameters: Returns: a list of plugins
Raises PluginException: no plugins could be found for the given interface
- bravo.plugin.retrieve_plugins(interface, **kwargs)[source]¶
Look up all plugins for a certain interface.
If the plugin cache is enabled, this function will not attempt to reload plugins from disk or discover new plugins.
Parameters: - interface (interface) – the interface to use
- parameters (dict) – parameters to pass into the plugins
Returns: a dict of plugins, keyed by name
Raises PluginException: no plugins could be found for the given interface
- bravo.plugin.retrieve_sorted_plugins(interface, names, **kwargs)[source]¶
Look up a list of plugins, sorted by interdependencies.
Parameters: parameters (dict) – parameters to pass into the plugins
- bravo.plugin.sort_plugins(plugins)[source]¶
Make a sorted list of plugins by dependency.
If the list cannot be arranged into a DAG, an error will be raised. This usually means that a cyclic dependency was found.
Raises PluginException: cyclic dependency detected
- bravo.plugin.verify_plugin(interface, plugin)[source]¶
Plugin interface verification.
This function will call verifyObject() and validateInvariants() on the plugins passed to it.
The primary purpose of this wrapper is to do logging, but it also permits code to be slightly cleaner, easier to test, and callable from other modules.