plugins.manager module¶
Provides plugin loading/unloading functionality.
- class plugins.manager.PluginManager(base_import='')[source]¶
Bases:
OrderedDict
Stores plugins and their instances.
- get_plugin_directory(plugin_name)[source]¶
Return the directory of the given plugin.
- Return type:
path.Path
- get_plugin_file_path(plugin_name)[source]¶
Return the path to the plugin’s main file.
- Parameters:
plugin_name (str) – Name of the plugin.
- Return type:
path.Path
- get_plugin_info(plugin_name)[source]¶
Return information about the given plugin.
- Parameters:
plugin_name (str) – The plugin to check. You can pass
__name__
from one of your plugin files to retrieve its own plugin instance.- Return type:
- load(plugin_name)[source]¶
Load a plugin by name.
- Parameters:
plugin_name (str) – Name of the plugin to load.
- Raises:
InvalidPluginName – Raised if the given plugin name is invalid.
PluginAlreadyLoaded – Raised if the plugin was already loaded.
PluginFileNotFoundError – Raised if the plugin’s main file wasn’t found.
PluginHasBuiltInName – Raised if the plugin has the name of a built-in module.
Exception – Any other exceptions raised by the plugin during the load process.
- Return type:
- reload(plugin_name)[source]¶
Reload a plugin by name.
- Parameters:
plugin_name (str) – Name of the plugin to reload.
- Raises:
PluginNotLoaded – Raised if the plugin is not loaded.
InvalidPluginName – Raised if the given plugin name is invalid.
PluginFileNotFoundError – Raised if the plugin’s main file wasn’t found.
PluginHasBuiltInName – Raised if the plugin has the name of a built-in module.
Exception – Any other exceptions raised by the plugin during the load process.
- Return type:
- unload(plugin_name)[source]¶
Unload a plugin by name.
- Parameters:
plugin_name (str) – Name of the plugin to unload.
- Raises:
PluginNotLoaded – Raised if the plugin is not loaded.
- RE_VALID_PLUGIN = re.compile('^([A-Za-z][A-Za-z0-9_]*[A-Za-z0-9])$')¶
- property loaded_plugins¶
Return a tuple containing all loaded plugins.
- Returns:
The tuple contains
plugins.instance.Plugin
instances.- Return type:
- property plugins¶
Return a generator to iterate over all existing plugins.
- Returns:
The generator yields the plugin names.
- Return type:
generator
- property plugins_directory¶
Return the directory where the plugins are stored.
- Return type:
path.Path