wolfhece._companion_plugin_manager

Companion plugin manager.

Manages discovery, loading, enabling and disabling of external companion plugins, and integrates them into the viewer menu bar.

Quick usage

from wolfhece._companion_plugin_manager import PluginManagerCompanion

mgr = PluginManagerCompanion(viewer)
mgr.menu_build()   # adds "Plugins" top-level menu
mgr.discover()     # scans default directory and activates enabled plugins

# Programmatic enable/disable:
mgr.plugin_manager.disable('dot_picker')
mgr.plugin_manager.enable('dot_picker')

Persistence

Enabled/disabled state is stored in the viewer’s WolfConfiguration under the PLUGINS_DISABLED key (list of disabled plugin names).

The plugins directory is stored under PLUGINS_DIRECTORY (empty string → built-in wolfhece/data/plugins).

Module Contents

wolfhece._companion_plugin_manager._logger[source]
class wolfhece._companion_plugin_manager.PluginManager(viewer: wolfhece.PyDraw.WolfMapViewer)[source]

Manages the runtime lifecycle of companion plugins for one viewer.

plugins[source]

All discovered plugins (loaded or failed).

Type:

list[PluginInfo]

active[source]

Mapping of plugin name → currently active companion instance.

Type:

dict[str, AbstractCompanion]

_viewer[source]
plugins: list[wolfhece._plugin_loader.PluginInfo] = [][source]
active: dict[str, wolfhece._menu_companion_abc.AbstractCompanion][source]
discover(directory: pathlib.Path | str | None = None) list[wolfhece._plugin_loader.PluginInfo][source]

Scan directory, load plugins, and apply the stored enable/disable state.

Parameters:

directory – Override the plugins directory. None reads the value from the viewer configuration (falling back to the built-in wolfhece/data/plugins).

Returns:

The refreshed plugins list.

enable(name: str) bool[source]

Enable the plugin name and activate it if not already running.

Returns:

True on success, False if the plugin was not found or could not be loaded.

disable(name: str) bool[source]

Disable the plugin name and destroy its active companion.

Returns:

True on success, False if the plugin was not found.

is_enabled(name: str) bool[source]

Return whether the plugin name is currently enabled.

_activate(info: wolfhece._plugin_loader.PluginInfo) None[source]

Instantiate, wire up menu, and store the companion.

_find(name: str) wolfhece._plugin_loader.PluginInfo | None[source]
_get_config()[source]

Return the viewer’s WolfConfiguration, or None if unavailable.

_configured_directory() pathlib.Path | None[source]

Read the plugins directory from the viewer config.

_disabled_names() list[str][source]
_save_state() None[source]
class wolfhece._companion_plugin_manager.PluginManagerCompanion(viewer: wolfhece.PyDraw.WolfMapViewer)[source]

Bases: wolfhece._menu_companion_abc.AbstractCompanion

Inheritance diagram of wolfhece._companion_plugin_manager.PluginManagerCompanion

Companion that manages external companion plugins.

Adds a Plugins top-level menu to the viewer with items to discover, reload, and toggle individual plugins.

Typical integration in a viewer subclass or startup script:

from wolfhece._companion_plugin_manager import PluginManagerCompanion

mgr = PluginManagerCompanion(viewer)
mgr.menu_build()   # installs the "Plugins" menu
mgr.discover()     # scans directory and activates enabled plugins
plugin_manager[source]
start() None[source]

No-op — the manager operates through the menu, not interactively.

menu_build() None[source]

Build (or rebuild) the top-level Plugins menu.

discover(directory: pathlib.Path | str | None = None) list[wolfhece._plugin_loader.PluginInfo][source]

Scan directory, activate plugins, then refresh the menu.

Parameters:

directory – Override the plugins directory. None reads from the viewer configuration.

Returns:

The refreshed list of PluginInfo.

_menu_items() list[source]
_make_toggle(name: str)[source]

Return a menu-event handler that toggles plugin name.

_on_discover(event) None[source]
_on_choose_dir(event) None[source]
_persist_directory(path: pathlib.Path) None[source]
_rebuild_menu() None[source]