plover.registry
– Plugin registry#
The Plover registry collects plugins from the local Python environment via
the entry_points
mechanism. This module exposes an interface to access the
list of available plugins, as well as possibly adding new ones.
- plover.registry.registry#
A global instance of the Plover registry, initialized by Plover at startup.
- class plover.registry.Registry([suppress_errors=True])#
- PLUGIN_TYPES: Tuple[str]#
A tuple of valid plugin types, such as
machine
for machine plugins andgui.qt.tool
for GUI tools.
- list_plugins(plugin_type: str) List[Plugin] #
Returns a list of available plugins of the specified type.
plugin_type
should be inPLUGIN_TYPES
, otherwise this raises aKeyError
.
- get_plugin(plugin_type: str, plugin_name: str) Plugin #
Returns a
Plugin
object containing information about the plugin with the specified name, of the specified type.plugin_type
is case-sensitive, butplugin_name
is not. Raises aKeyError
if such a plugin could not be found.
- update()#
Re-scans the Python environment to look for plugins, and registers any that were previously not loaded.
This method does not get called automatically upon instantiating a Registry object, so make sure to call it before using any plugins.
- register_plugin_from_entrypoint(plugin_type: str, entrypoint: pkg_resources.EntryPoint)#
Adds a plugin of the specified type discovered through the entry point mechanism to the registry.
- register_plugin(plugin_type: str, name: str, obj: any)#
Adds a plugin named
name
of the specified type to the registry.obj
is the Python object that provides the functionality of the plugin, and could be a function, class, or module – the exact type depends on the type of plugin (see Plugin Development Guide for more information).If
plugin_type
is not a valid plugin type (i.e. not inPLUGIN_TYPES
), this raises aKeyError
.
- list_distributions() List[PluginDistribution] #
Returns the list of distributions that Plover has found to contain Plover plugins. If
update()
has not been called, this will return an empty list.
- class plover.registry.Plugin(plugin_type, name, obj)#
- plugin_type: str#
The type of the plugin. This will be one of
PLUGIN_TYPES
.
- name: str#
The name of the plugin. This will be the same as the entrypoint name provided when creating a plugin.
- obj#
The Python object providing the plugin’s functionality, could be a function, class, or module.
- class plover.registry.PluginDistribution(dist, plugins)#
- dist: pkg_resources.Distribution#
A
Distribution
providing information on a single package either bundled with Plover, or installed from the plugins manager, for example, the main Plover packageplover 4.0.0-dev12
. Each distribution may contain multiple plugins.