Pylint and cleanup

master
Tom Wilson 6 years ago
parent a50ddfc763
commit 7a7d2128a4

@ -35,6 +35,9 @@ class InterfaceFunction():
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
return self.func(*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): class Plugin(ABC):
@staticmethod @staticmethod
@ -105,6 +108,7 @@ def init_plugins(plugin_classes, plugin_configs, core_config):
for plugininterface in plugin_interfaces.values(): for plugininterface in plugin_interfaces.values():
plugininterface.functions = plugin_functions plugininterface.functions = plugin_functions
def _add_job(job_desc): def _add_job(job_desc):
global _deferred_jobs global _deferred_jobs
global _defer global _defer
@ -114,6 +118,7 @@ def _add_job(job_desc):
else: else:
_deferred_jobs.append(job_desc) _deferred_jobs.append(job_desc)
def _attach_hook(attachment): def _attach_hook(attachment):
global plugin_hooks global plugin_hooks
global _deferred_attachments 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. 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``, 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. and lastly in the global import path.
Args: Args:
plugin_names: List of plugin names to try and load plugin_names: List of plugin names to try and load
plugin_dir: optional search path plugin_dir: optional search path
Returns: Returns:
Dict of plugin classes, with their names as keys 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 # First look for core plugins, then the plugin_dir, then in the general import path
# for custom ones prefixed with "shepherd_" # for custom ones prefixed with "shepherd_"
try: 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") 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: except ModuleNotFoundError:
try: try:
if (plugin_dir is not None) and (plugin_dir != ""): if (plugin_dir is not None) and (plugin_dir != ""):

Loading…
Cancel
Save