pycopancore.runners.hooks module

Register hooks for the run inside a runner.

exception HookRegistrationError[source]

Bases: BaseException

Dummy docstring

class Hooks(*args, **kwargs)[source]

Bases: object

Class managing the hooks that are called before, during and after a run.

class Types(*values)[source]

Bases: Enum

Defines the three hook types: pre, mid, post

mid = 2
post = 3
pre = 1
static __new__(cls, *args, **kwargs)[source]

raises an error because this class should not be instantiated

_mid_hooks = {}

dict of hooks that are executed every time the run is halted for a step or an event

keys: None or Entity class or Taxon class

values: list of functions

_post_hooks = {}

dict of hooks that are executed after the run

keys: None or Entity class or Taxon class

values: list of functions

_pre_hooks = {}

dict of hooks that are executed before the run

keys: None or Entity class or Taxon class

values: list of functions

classmethod execute_hooks(type, model, t)[source]

Dummy docstring

classmethod register_hook(type, hook, theclass=None)[source]

Register a hook. :param type: Specifies the type of the hook. :type type: HookTypes member :param hook: The function to be called.

arguments: instance of the corresponding enitity or taxon, time when called

tmp = []
classmethod unregister_hook(type, hook, theclass=None, error_if_not_registered=True)[source]

Register a hook. :param type: Specifies the type of the hook. :type type: HookTypes member :param hook: The function to be removed. :type hook: function :param Errors: :param ======: :param raises HookRegistrationError when hook is not listed as registered:

exception HooksError[source]

Bases: BaseException

Dummy docstring