aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/hydrorollcore/core.py
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2023-12-11 00:19:17 +0800
committer苏向夜 <fu050409@163.com>2023-12-11 00:19:17 +0800
commit0dd371d4f6ef45379e2934fd7106eff3f38eef5e (patch)
treee5520c30482e5a5af7094cb040266c6a91914466 /src/hydrorollcore/core.py
parent074579ccec5b31b6e6546bb16b2ffe9b1069f790 (diff)
downloadinfini-0dd371d4f6ef45379e2934fd7106eff3f38eef5e.tar.gz
infini-0dd371d4f6ef45379e2934fd7106eff3f38eef5e.zip
:fire: 清除core.py方案使用子类及规则包注册
Diffstat (limited to 'src/hydrorollcore/core.py')
-rw-r--r--src/hydrorollcore/core.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/hydrorollcore/core.py b/src/hydrorollcore/core.py
deleted file mode 100644
index 6f6bbcc1..00000000
--- a/src/hydrorollcore/core.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import importlib
-from typing import List
-from .exceptions import RuleLoadError
-from .rule import Rule
-from .config import Config
-
-
-class Core:
- def __init__(self, config: Config):
- self.rule_dir = config.rule_dir
- self.rules = config.rules
-
- def load_rules(self) -> List[Rule]:
- loaded_rules = []
- for rule in self.rules:
- try:
- module = importlib.import_module(rule)
- except ImportError as e:
- raise RuleLoadError(f"Failed to load rule {rule}: {e}") from e
- try:
- rule_cls = getattr(module, rule.split(".")[-1])
- if not issubclass(rule_cls, Rule):
- raise RuleLoadError(
- f"Class '{rule_cls.__name__}' is not a subclass of 'Rule'"
- )
- except AttributeError as e:
- raise RuleLoadError(
- f"Failed to get rule class from module '{rule}': {e}"
- ) from e
- loaded_rules.append(rule_cls())
- return loaded_rules