Module to load plugins.


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.

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


Inheritance diagram of FunctionLoader


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.

cache (bool) – If True return the cached result. If False force reload of all functions registered for the entry point.
An ordered dictionary associating the name for which the function was registered and and the function itself.
Return type
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.