diplomat.utils.pluginloader.load_plugin_classes

diplomat.utils.pluginloader.load_plugin_classes(plugin_dir: module, plugin_metaclass: Type[T], do_reload: bool = False, display_error: bool = True, recursive: bool = True) Set[Type[T]][source]

Loads all plugins, or classes, within the specified module folder and submodules that extend the provided metaclass type.

Parameters:
  • plugin_dir – A module object representing the path containing plugins… Can get a module object using import…

  • plugin_metaclass – The metaclass that all plugins extend. Please note this is the class type, not the instance of the class, so if the base class is Foo just type Foo as this argument.

  • do_reload – Boolean, Determines if plugins should be reloaded if they already exist. Defaults to True.

  • display_error

    Boolean, determines if import errors are sent using python’s warning system when they occur. Defaults to True. Note these warnings won’t be visible unless you set up a filter for them, such as below:

    import warnings warnings.simplefilter(“always”, ImportWarning)

  • recursive – Boolean, if true recursively search subpackages for the class. Otherwise, only the first level is searched.

Returns:

A list of class types that directly extend the provided base class and where found in the specified module folder.