spyder.api.plugin_registration.registry#
Global registry for internal and external Spyder plugins.
Module Attributes
Type alias for the set of supported classes for Spyder plugin objects. |
|
List of all Spyder internal plugins. |
|
The global Spyder plugin registry instance. |
Classes
Class with constants for the plugin manager preferences page. |
|
Global Spyder plugin registry. |
- spyder.api.plugin_registration.registry.SpyderPluginClass#
Type alias for the set of supported classes for Spyder plugin objects.
alias of
SpyderPluginV2|SpyderDockablePlugin
- spyder.api.plugin_registration.registry.ALL_PLUGINS: list[str] = ['appearance', 'application', 'completions', 'internal_console', 'debugger', 'editor', 'explorer', 'external_terminal', 'find_in_files', 'help', 'historylog', 'ipython_console', 'layout', 'main_interpreter', 'mainmenu', 'onlinehelp', 'outline_explorer', 'plots', 'preferences', 'profiler', 'project_explorer', 'pylint', 'pythonpath_manager', 'remoteclient', 'run', 'shortcuts', 'statusbar', 'switcher', 'toolbar', 'tours', 'update_manager', 'variable_explorer', 'workingdir']#
List of all Spyder internal plugins.
- class spyder.api.plugin_registration.registry.PreferencesAdapter[source]#
Bases:
SpyderConfigurationAccessorClass with constants for the plugin manager preferences page.
- class spyder.api.plugin_registration.registry.SpyderPluginRegistry[source]#
Bases:
QObject,PreferencesAdapterGlobal Spyder plugin registry.
This class handles a plugin’s initialization/teardown lifetime, including notifications when a plugin is available or about to be torn down.
This registry alleviates the limitations of a topological sort-based plugin initialization by enabling plugins to have bidirectional dependencies instead of unidirectional ones.
Caution
A plugin should not depend on other plugin to perform its initialization, since this could cause deadlocks.
Note
This class should be instantiated as a singleton.
- sig_plugin_ready(QString, bool): Signal#
Signal used to let the main window know that a plugin is ready for use.
- __init__() None[source]#
Create a global registry for internal and external Spyder plugins.
- Return type:
None
- plugin_dependents: dict[str, dict[str, list[str]]]#
Mapping of plugin names to the names of plugins depending on them.
The second-level dictionary holds lists of dependencies for the plugin by category, under the keys
"requires"and"optional".
- plugin_dependencies: dict[str, dict[str, list[str]]]#
Mapping of plugin names to the names of plugins they depend on.
The second-level dictionary holds lists of dependencies for the plugin by category, under the keys
"requires"and"optional".
- all_internal_plugins: dict[str, tuple[str, type[SpyderPluginClass]]]#
Mapping of internal plugins to their name and plugin class.
Includes all internal plugins that are part of Spyder’s source tree, enabled or not.
- all_external_plugins: dict[str, tuple[str, type[SpyderPluginClass]]]#
Mapping of external plugins to their name and plugin class.
Includes all externals plugins installed separately from Spyder, enabled or not.
- register_plugin(main_window: spyder.app.mainwindow.MainWindow, PluginClass: type[SpyderPluginClass], *args: Any, external: bool = False, **kwargs: Any) SpyderPluginClass[source]#
Register a plugin into the Spyder plugin registry.
- Parameters:
main_window (spyder.app.mainwindow.MainWindow) – Reference to Spyder’s main window.
PluginClass (type[SpyderPluginClass]) – The plugin class to register and create. It must be one of
SpyderPluginClass.*args (Any, optional) –
Arbitrary positional arguments passed to the plugin instance’s initializer.
Deprecated since version 6.2: No longer needed following completion of the Spyder plugin API migration in Spyder 6.0. Passing
*argswill raise aDeprecationWarningin Spyder 6.2 and be removed in Spyder 7.0.external (bool, optional) – If
True, then the plugin is stored as an external plugin. Otherwise, it will be marked as an internal plugin (the default).**kwargs (Any, optional) –
Arbitrary positional arguments passed to the plugin instance’s initializer.
Deprecated since version 6.2: No longer needed following completion of the Spyder plugin API migration in Spyder 6.0. Passing
**kwargswill raise aDeprecationWarningin Spyder 6.2 and be removed in Spyder 7.0.
- Returns:
plugin – The initialized instance of the registered plugin.
- Return type:
SpyderPluginClass
- Raises:
TypeError – If the
PluginClassdoes not inherit from any ofspyder.app.registry.SpyderPluginClass.
- notify_plugin_availability(plugin_name: str, notify_main: bool = True, omit_conf: bool = False) None[source]#
Notify a plugin’s dependents that the plugin is ready for use.
- Parameters:
plugin_name (str) – Name of the plugin that has become ready for use.
notify_main (bool, optional) – If
True, then a signal is emitted to the main window to perform further registration steps (the default). Otherwise, no signal is emitted.omit_conf (bool, optional) – If
True, then the main window is instructed to not write the plugin configuration into the Spyder configuration file. Otherwise, configuration will be written as normal (the default).
- Return type:
None
- can_delete_plugin(plugin_name: str) bool[source]#
Check if a plugin with the given name can be deleted from the registry.
Calls
spyder.api.plugins.SpyderPluginV2.can_close()to perform the check.
- dock_undocked_plugin(plugin_name: str, save_undocked: bool = False) None[source]#
Dock plugin if undocked and save undocked state if requested.
- delete_plugin(plugin_name: str, teardown: bool = True, check_can_delete: bool = True) bool[source]#
Remove and delete the plugin with the given name from the registry.
- Parameters:
plugin_name (str) – Name of the plugin to delete.
teardown (bool, optional) –
Trueif the teardown notification to other plugins should be sent when deleting the plugin (the default),Falseotherwise.check_can_delete (bool, optional) –
Trueif the plugin should first check if it can be deleted (usingcan_delete_plugin()) before closing and removing itself from the registry (the default). If this check then fails, the plugin’s removal is aborted and this method returnsFalse. Otherwise, if this parameter isFalse, the plugin is deleted unconditionally without a check.
- Returns:
plugin_deleted –
Trueif the registry was able to teardown and remove the plugin;Falseotherwise. Will always returnTrueifcheck_can_deleteisFalse.- Return type:
- dock_all_undocked_plugins(save_undocked: bool = False) None[source]#
Dock undocked plugins and save the undocked state if requested.
- Parameters:
save_undocked (bool, optional) –
Trueif the undocked state should be saved. IfFalse, the default, don’t persist the undocked state.- Return type:
None
- can_delete_all_plugins(excluding: set[str] | None = None) bool[source]#
Determine if all plugins can be deleted (except any specified).
Calls
spyder.api.plugins.SpyderPluginV2.can_close()to perform the check.
- delete_all_plugins(excluding: set[str] | None = None, close_immediately: bool = False) bool[source]#
Remove all plugins from the registry.
The teardown mechanism will remove external plugins then internal ones.
- Parameters:
excluding (set[str] | None, optional) – A set that lists plugins (by name) that will not be deleted. If
None(the default) or an empty set, no plugins are excluded from being deleted.close_immediately (bool, optional) – If
True, then thecan_close()status will be ignored, and all plugins will be closed unconditionally. IfFalse(the default), Spyder will not close any plugins if they report they cannot be closed, i.e. ifcan_delete_all_plugins()returnsFalse.
- Returns:
all_deleted –
Trueif all the plugins were deleted.Falseotherwise.- Return type:
- get_plugin(plugin_name: str) spyder.api.plugin_registration.registry.SpyderPluginClass[source]#
Get a reference to a plugin instance by its name.
- Parameters:
plugin_name (str) – Name of the plugin to retrieve the plugin object of.
- Returns:
plugin – The instance of the requested plugin.
- Return type:
SpyderPluginClass
- Raises:
SpyderAPIError – If the plugin name was not found in the registry.
- set_plugin_enabled(plugin_name: str) None[source]#
Add a plugin by name to the set of enabled plugins.
- Parameters:
plugin_name (str) – Name of the plugin to add.
- Return type:
None
- is_plugin_enabled(plugin_name: str) bool[source]#
Determine if a given plugin is enabled and is going to be loaded.
- is_plugin_available(plugin_name: str) bool[source]#
Determine if a given plugin is loaded and ready for use.
- set_all_internal_plugins(all_plugins: dict[str, tuple[str, type[spyder.api.plugin_registration.registry.SpyderPluginClass]]]) None[source]#
Set the
all_internal_pluginsattribute to the given plugins.Deprecated since version 6.2: Will raise a
DeprecationWarningin Spyder 6.2 and be removed in Spyder 7.0. Set theall_internal_pluginsattribute directly instead.
- set_all_external_plugins(all_plugins: dict[str, tuple[str, type[spyder.api.plugin_registration.registry.SpyderPluginClass]]]) None[source]#
Set the
all_external_pluginsattribute to the given plugins.Deprecated since version 6.2: Will raise a
DeprecationWarningin Spyder 6.2 and be removed in Spyder 7.0. Set theall_external_pluginsattribute directly instead.
- set_main(main: spyder.app.mainwindow.MainWindow) None[source]#
Set the reference to the Spyder main window for the plugin registry.
Deprecated since version 6.2: Will raise a
DeprecationWarningin Spyder 6.2 and be removed in Spyder 7.0. Set themainattribute directly instead.- Parameters:
main (spyder.app.mainwindow.MainWindow) – The Spyder main window instance to set the reference to.
- Return type:
None
- spyder.api.plugin_registration.registry.PLUGIN_REGISTRY: SpyderPluginRegistry = <spyder.api.plugin_registration.registry.SpyderPluginRegistry object>#
The global Spyder plugin registry instance.