diff --git a/shepherd/plugin.py b/shepherd/plugin.py index 26e98c1..ecdd125 100644 --- a/shepherd/plugin.py +++ b/shepherd/plugin.py @@ -35,6 +35,9 @@ class InterfaceFunction(): def __call__(self, *args, **kwargs): return self.func(*args, **kwargs) +# TODO: Create tests to try and make a plugin subclass, and check exceptions to see if they +# suggest the correct abstractmethods + class Plugin(ABC): @staticmethod @@ -105,6 +108,7 @@ def init_plugins(plugin_classes, plugin_configs, core_config): for plugininterface in plugin_interfaces.values(): plugininterface.functions = plugin_functions + def _add_job(job_desc): global _deferred_jobs global _defer @@ -114,6 +118,7 @@ def _add_job(job_desc): else: _deferred_jobs.append(job_desc) + def _attach_hook(attachment): global plugin_hooks global _deferred_attachments @@ -216,13 +221,13 @@ def find_plugins(plugin_names, plugin_dir=None): """ Looks for the list of plugin names supplied and returns their classes. Will first try for plugin modules and packages locally located in ``shepherd.plugins``, - then for modules and packages prefixed ``shepherd_`` located in the supplied ``plugin_dir`` + then for modules and packages prefixed ``shepherd_`` located in the supplied ``plugin_dir`` and lastly in the global import path. - + Args: plugin_names: List of plugin names to try and load plugin_dir: optional search path - + Returns: Dict of plugin classes, with their names as keys """ @@ -231,9 +236,10 @@ def find_plugins(plugin_names, plugin_dir=None): # First look for core plugins, then the plugin_dir, then in the general import path # for custom ones prefixed with "shepherd_" try: - #mod = importlib.import_module("shepherd.plugins." + plugin_name) + # mod = importlib.import_module("shepherd.plugins." + plugin_name) mod = importlib.import_module('.'+plugin_name, "shepherd.plugins") - #TODO - ModuleNotFoundError is also triggered here if the plugin has a dependancy that can't be found + # TODO - ModuleNotFoundError is also triggered here if the plugin has a dependancy + # that can't be found except ModuleNotFoundError: try: if (plugin_dir is not None) and (plugin_dir != ""):