diff --git a/main/utils.py b/main/utils.py new file mode 100644 index 00000000..ba63ac82 --- /dev/null +++ b/main/utils.py @@ -0,0 +1,14 @@ +import sys +import logging +import importlib +from pathlib import Path + +def load_plugins(plugin_name): + path = Path(f"main/plugins/{plugin_name}.py") + name = "main.plugins.{}".format(plugin_name) + spec = importlib.util.spec_from_file_location(name, path) + load = importlib.util.module_from_spec(spec) + load.logger = logging.getLogger(plugin_name) + spec.loader.exec_module(load) + sys.modules["main.plugins." + plugin_name] = load + print("main has Imported " + plugin_name)