Compare commits

...

2 commits

Author SHA1 Message Date
Jordan ⌨️ 56f252f588 feat: Plugins system allows __init__.py for relative imports 2023-11-25 12:28:37 +01:00
Jordan ⌨️ a9ef90c04e cleanup: remove unused assignation and if stmt
the function doesn't return anything (see function signature)
2023-11-25 12:17:58 +01:00

View file

@ -1,5 +1,6 @@
import os
import logging
import os
import sys
from . import shell, model, const
@ -17,6 +18,7 @@ def load(path: str):
return None
module = importlib.module_from_spec(spec)
sys.modules["plugin"] = module
spec.loader.exec_module(module)
@ -33,11 +35,11 @@ def loadAll():
for dirname in paths:
pluginDir = os.path.join(project.dirname(), dirname, const.META_DIR, "plugins")
initFile = os.path.join(pluginDir, "__init__.py")
for files in shell.readdir(pluginDir):
if files.endswith(".py"):
plugin = load(os.path.join(pluginDir, files))
if plugin:
_logger.info(f"Loaded plugin {plugin.name}")
plugin.init()
if os.path.isfile(initFile):
load(initFile)
else:
for files in shell.readdir(pluginDir):
if files.endswith(".py"):
load(os.path.join(pluginDir, files))