merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi
About | Files | Commits | Refs | License
refactor:simplify plugin loading
Author: pixel
Date: 2026-07-22 09:33
commit: 43df41e3
Stat
| M | src/build.py | 11 | +4 | -7 |
Diff
diff --git a/src/build.py b/src/build.py
index 004a822..88ee6ee 100644
--- a/src/build.py
+++ b/src/build.py
@@ -14,7 +14,7 @@ from os import chdir, getcwd, makedirs, path, walk, readlink
from .config import find_project_from_path, load_config
from .errors import fatal, html_fatal
from .fileops import is_dotfile, read_file, write_file
-from .log import GRAY, BLUE, die, info, warn, progress
+from .log import GRAY, info, warn, progress
from . import log
api.log = log
@@ -36,7 +36,8 @@ def load_plugins(config):
try:
main_path = path.join(module_dir, "main.py")
if not path.isfile(main_path):
- die("can not find `main.py` on plugins directory")
+ warn("can not find `main.py` on plugins directory")
+ return {}
...
Show all
Show less
diff --git a/src/build.py b/src/build.py
index 004a822..88ee6ee 100644
--- a/src/build.py
+++ b/src/build.py
@@ -14,7 +14,7 @@ from os import chdir, getcwd, makedirs, path, walk, readlink
from .config import find_project_from_path, load_config
from .errors import fatal, html_fatal
from .fileops import is_dotfile, read_file, write_file
-from .log import GRAY, BLUE, die, info, warn, progress
+from .log import GRAY, info, warn, progress
from . import log
api.log = log
@@ -36,7 +36,8 @@ def load_plugins(config):
try:
main_path = path.join(module_dir, "main.py")
if not path.isfile(main_path):
- die("can not find `main.py` on plugins directory")
+ warn("can not find `main.py` on plugins directory")
+ return {}
...
diff --git a/src/build.py b/src/build.py
index 004a822..88ee6ee 100644
--- a/src/build.py
+++ b/src/build.py
@@ -14,7 +14,7 @@ from os import chdir, getcwd, makedirs, path, walk, readlink
from .config import find_project_from_path, load_config
from .errors import fatal, html_fatal
from .fileops import is_dotfile, read_file, write_file
-from .log import GRAY, BLUE, die, info, warn, progress
+from .log import GRAY, info, warn, progress
from . import log
api.log = log
@@ -36,7 +36,8 @@ def load_plugins(config):
try:
main_path = path.join(module_dir, "main.py")
if not path.isfile(main_path):
- die("can not find `main.py` on plugins directory")
+ warn("can not find `main.py` on plugins directory")
+ return {}
for name in list(sys.modules):
mod_file = getattr(sys.modules[name], "__file__", "") or ""
if mod_file.startswith(module_dir):
@@ -51,11 +52,7 @@ def load_plugins(config):
spec.loader.exec_module(module)
hook_call("on_plugins_before_export", config)
- exports = {
- name: value
- for name, value in vars(module).items()
- if not name.startswith("_")
- }
+ exports = {n: v for n, v in vars(module).items() if not n.startswith("_")}
hook_call("on_plugins_loaded", exports)
return exports