Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

refactor:simplify plugin loading

author: pixel
date: 2026-07-22 09:33
hash: 43df41e37f29eeb9284348cb12fb81d65248c5b9

Diffstat:

M

src/build.py
11 +++++++++++-------------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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