From 72f0236e58b0e07fd1e1761f3304e10ea7177087 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 1 Oct 2022 19:08:05 -0500 Subject: [PATCH] Added submodule search logic --- .../SolarFM/solarfm/plugins/plugins_controller.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/plugins_controller.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/plugins_controller.py index 11f9dda..63cccfe 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/plugins_controller.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/plugins_controller.py @@ -72,13 +72,23 @@ class PluginsController: def load_plugin_module(self, path, folder, target): os.chdir(path) - spec = importlib.util.spec_from_file_location(folder, target, submodule_search_locations=path) + + locations = [] + self.collect_search_locations(path, locations) + + spec = importlib.util.spec_from_file_location(folder, target, submodule_search_locations = locations) module = importlib.util.module_from_spec(spec) sys.modules[folder] = module spec.loader.exec_module(module) return module + def collect_search_locations(self, path, locations): + locations.append(path) + for file in os.listdir(path): + _path = os.path.join(path, file) + if os.path.isdir(_path): + self.collect_search_locations(_path, locations) def execute_plugin(self, module: type, plugin: PluginInfo, loading_data: []): plugin.reference = module.Plugin()