Api Reference

HookimplMarker

class HookimplMarker(project_name, flags=None)[source]

Bases: object

Decorator helper class for marking functions as hook implementations.

You can instantiate with a project_name to get a decorator. Calling PluginManager.register later will discover all marked functions if the PluginManager uses the same project_name.

HookspecMarker

class HookspecMarker(project_name, flags=None)[source]

Bases: object

Decorator helper class for marking functions as hook specifications.

You can instantiate it with a project_name to get a decorator. Calling PluginManager.register_specs later will discover all marked functions if the PluginManager uses the same project_name.

HookCallError

class HookCallError[source]

Bases: Exception

Hook was called wrongly.

HookValidationError

class HookValidationError[source]

Bases: Exception

Plugin failed validation.

PluginManager

class PluginManager(project_name)[source]

Bases: object

Core Pluginmanager class which manages registration of plugin objects and 1:N hook calling.

You can register new hooks by calling add_hookspec(module_or_class). You can register plugin objects (which contain hooks) by calling register(plugin). The Pluginmanager is initialized with a prefix that is searched for in the names of the dict of registered plugin objects.

For debugging purposes you can call enable_tracing() which will subsequently send debug information to the trace helper.

missing()[source]

Dictionary of specified required hooks without implementation.

redundant()[source]

Dictionary of first_only hooks with multiple implementations.

register(namespace)[source]

Register a plugin and return its canonical name.

Raises:ValueError – if the plugin is already registered.
register_specs(namespace)[source]

add new hook specifications defined in the given module_or_class. Functions are recognized if they have been decorated accordingly.

unhandled_exceptions = None

type: list(tuple(aiopluggy.hooks.HookImpl, Exception))

unimplemented()[source]

Dictionary of specified hooks without implementation.

unscheduled_coros = None

type: list(tuple(aiopluggy.hooks.HookImpl, Coroutine))

unspecified()[source]

Dictionary of implemented hooks without specification.

Result

class Result(value=None, exc_info=None)[source]

Bases: object

exc_info

Exception info.

Return type:a tuple. See sys.exc_info() for details.
exception

Exception info.

Return type:a tuple. See sys.exc_info() for details.
value

Get the result(s) for this hook call.

If the hook was marked as a first_notnone or first_only only a single value will be returned otherwise a list of results.