Pi66

Home | Repos | About | Blog | Gaza

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

About | Files | Commits | Refs | License


fix: handle plugin loading failures

Author: pi66
Date: 2026-06-29 16:41
commit: 51699c04

Stat

M src/build.py 22 +13 -9

Diff

diff --git a/src/build.py b/src/build.py
index 16bffa4..158cd76 100644
--- a/src/build.py
+++ b/src/build.py
@@ -26,15 +26,19 @@ replace_filters = [
 ]

def load_plugins(path): - spec = importlib.util.spec_from_file_location("plugins", path) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - - return { - name: value - for name, value in vars(module).items() - if not name.startswith("_") - } + try: + spec = importlib.util.spec_from_file_location("plugins", path) + module = importlib.util.module_from_spec(spec) ...

Show all

diff --git a/src/build.py b/src/build.py
index 16bffa4..158cd76 100644
--- a/src/build.py
+++ b/src/build.py
@@ -26,15 +26,19 @@ replace_filters = [
 ]

def load_plugins(path): - spec = importlib.util.spec_from_file_location("plugins", path) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - - return { - name: value - for name, value in vars(module).items() - if not name.startswith("_") - } + try: + spec = importlib.util.spec_from_file_location("plugins", path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + return { + name: value + for name, value in vars(module).items() + if not name.startswith("_") + } + + except Exception as e: + raise RuntimeError(f"Failed loading plugin {path}: {e}") from e

def html_filter(html_content:str):

// Created by Pi66

// Copyright ©Pi66 2026