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 and gui.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 in PLUGIN_TYPES, otherwise this raises a KeyError.

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, but plugin_name is not. Raises a KeyError 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 in PLUGIN_TYPES), this raises a KeyError.

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 package plover 4.0.0-dev12. Each distribution may contain multiple plugins.

plugins: List[Plugin]#

The list of plugins contained in this distribution.