ucsschool.lib.pyhooks package
Contents
ucsschool.lib.pyhooks package¶
Python based hooks.
Submodules¶
ucsschool.lib.pyhooks.pyhook module¶
Base class for all Python based hooks.
ucsschool.lib.pyhooks.pyhooks_loader module¶
Loader for Python based hooks.
- class ucsschool.lib.pyhooks.pyhooks_loader.PyHooksLoader(base_dir, base_class, logger=None, filter_func=None)[source]¶
Bases:
object
Loader for PyHooks.
Use get_hook_objects() to get initialized and sorted objects. Use get_hook_classes() if you want to initialize them yourself.
Hint: if you wish to pass a logging instance to a hook, add it to the arguments list of
get_hook_objects()
and receive it in the hooks__init__()
method.If filter_func is a callable, it will be passed each class that is considered for loading and it can decide if it should be loaded or not. Thus its signature is (type) -> bool.
- Parameters
base_dir (str) – path to a directory containing Python files
base_class (str or type) – only subclasses of this class will be imported. This can be either a class object or the fully dotted Python path to a class (the latter helps to prevent import loops).
logger (logging.Logger) – Python logging instance to use for loader logging (deprecated, ignored)
filter_func (Callable) – function that takes a class and returns a bool
- drop_cache()[source]¶
Drop the cache of loaded hook classes and force a rerun of the filesystem search, next time get_hook_classes() or get_pyhook_objects() is called.
- Returns
None
- get_hook_classes()[source]¶
Search hook files in filesystem and load classes. No objects are initialized, no sorting is done.