21 from ..context
import LOG
22 from ..pluginapi
import Plugin
23 from .pluginconnector
import PluginFactory
28 def __init__(self, application, load_dirs, standard_classes):
48 return issubclass(cls, Plugin)
and cls
is not Plugin
49 except Exception
as err:
50 msg =
"Finding classes from module '%s' failed: %s"
55 for path
in load_dirs:
56 if not os.path.exists(path):
58 for filename
in os.listdir(path):
59 full_path = os.path.join(path, filename)
60 if filename[0].isalpha()
and \
61 os.path.splitext(filename)[1].
lower() ==
".py":
62 files.append(full_path)
63 elif os.path.isdir(full_path):
68 dirpath, filename = os.path.split(path)
69 modulename = os.path.splitext(filename)[0]
70 spec = importlib.util.spec_from_file_location(modulename, path)
74 m_module = importlib.util.module_from_spec(spec)
75 spec.loader.exec_module(m_module)
76 except Exception
as err:
77 self.
_load_errors_load_errors.append(
"Importing plugin module '%s' failed:\n%s"
80 return [cls
for _, cls
in
81 inspect.getmembers(m_module, predicate=inspect.isclass)]
def _is_plugin_class(self, path, cls)
def _find_python_files(self, load_dirs)
def _import_classes(self, path)
def __init__(self, application, load_dirs, standard_classes)
def _find_classes(self, load_dirs)
def PluginFactory(application, plugin_class)