coder_plugin.base_plugin_manager

Base plugin manager for the coder_plugin system.

Provides plugin discovery, dynamic loading, and context management for organized hierarchical plugin systems.

Classes

BasePluginManager(*args[, auto_load_children])

Manages discovery and loading of sub-plugins for a specific plugin group.

class coder_plugin.base_plugin_manager.BasePluginManager(*args, auto_load_children=False, **kwargs)[source]

Bases: BasePluginUnit

Manages discovery and loading of sub-plugins for a specific plugin group.

This base class provides dynamic plugin discovery using Python entry points, hierarchical plugin management, and context management support.

__init__(*args, auto_load_children=False, **kwargs)[source]

Initialize the PluginManager.

Parameters:

auto_load_children (bool) – If True, automatically load children upon initialization.

load_children()[source]

Discover and load child plugins dynamically via this plugin’s plugin_group.

Return type:

None

Defensive coding:
  • If no plugin group is defined, loading is skipped.

  • In the future, consider raising an exception if no plugin_group is set.

run(*args, **kwargs)[source]

Run the plugin manager’s main logic.

Parameters:
  • *args (Any) – Positional arguments forwarded to each child plugin.

  • **kwargs (Any) – Keyword arguments forwarded to each child plugin.

Returns:

The result of the plugin manager’s execution, as defined by the subclass.

Return type:

Any

set_up(*args, **kwargs)[source]

Perform setup task(s) for all loaded child plugins.

Returns:

Enables fluent chaining after set up.

Return type:

Self

classmethod load_from_parent_group(parent_group, parent_name, *args, **kwargs)[source]

Discover and load a plugin from a parent group by its registered name.

Parameters:
  • parent_group (str) – The entry point group where the parent plugin is registered.

  • parent_name (str) – The registered name of the plugin to load.

  • *args (Any) – Positional arguments to pass to the plugin constructor.

  • **kwargs (Any) – Keyword arguments to pass to the plugin constructor.

Returns:

An instantiated plugin object.

Return type:

Self

Raises:

LookupError – If no plugin with the specified name is found.

Notes

  • If no additional arguments are needed, the plugin class will be instantiated with no arguments.

  • If arguments are needed, they will be passed through *args and **kwargs.