ninjecto.plugins.loader

Module to load plugins.

Classes

class ninjecto.plugins.loader.FunctionLoader(package, component, api_version='1.0')

Function loader utility class.

This class allows to load functions using Python entry points.

Parameters
  • component (str) – Name of the component.
  • api_version (str) – Version of the API.

Inheritance

Inheritance diagram of FunctionLoader

load_functions(cache=True)

Load all available functions.

This function load all available functions by discovering installed functions registered in the entry point. This can be costly or error prone if the package that declared the entrypoint misbehave. Because of this a cache is stored after the first call.

Parameters
cache (bool) – If True return the cached result. If False force reload of all functions registered for the entry point.
Returns
An ordered dictionary associating the name for which the function was registered and and the function itself.
Return type
OrderedDict
classmethod register(key)

Register a function locally.

This method is expected to be used as a decorator. It allows to register a function locally without having to create a full Python package to use entrypoints.

classmethod reset()

Reset locally registered functions.

classmethod unregister(key)

Unregister a previously registered function.