Skip to content

Plugins module

Boldi's Plugins module support extending any Python libraries with feature provided through Python package entry points.

Install

Boldi's Plugins module is distributed as the boldi-plugins Python package, thus to install it, run:

pip install boldi-plugins

...or add "boldi-plugins" as a dependency to your project.

Import

Import the module like so:

import boldi.plugins
# or:
from boldi.plugins import load

Usage

Use the boldi.plugins.load function to load all entry points (plugin classes) that match the specified group.

API

boldi.plugins

Plugin

Bases: NamedTuple

Source code in pkg/boldi-plugins/boldi/plugins.py
6
7
8
class Plugin(NamedTuple):
    name: str
    impl: Callable[..., None]
impl: Callable[..., None]
name: str

load(group: str) -> Iterable[Plugin]

Source code in pkg/boldi-plugins/boldi/plugins.py
def load(group: str) -> Iterable[Plugin]:
    entry_points = importlib.metadata.entry_points(group=group)
    for entry_point in entry_points:
        plugin = entry_point.load()
        yield Plugin(entry_point.name, plugin)