diff options
| author | 2023-12-11 01:12:41 +0800 | |
|---|---|---|
| committer | 2023-12-11 01:12:41 +0800 | |
| commit | 60df69ff0e36ffa3f966d663ad6de3028141e064 (patch) | |
| tree | 569115937c58d0ba955932446f598500c9650939 /src/hydrorollcore/core.py | |
| parent | 5781a072250a147d5e636b269fd0a8b7a0b045da (diff) | |
| parent | 0a688b5105daf563baffedcfb21e16332fe4494e (diff) | |
| download | infini-60df69ff0e36ffa3f966d663ad6de3028141e064.tar.gz infini-60df69ff0e36ffa3f966d663ad6de3028141e064.zip | |
Merge pull request #37 from HydroRoll-Team/sourcery/pull-36
✨ 实现消息事件文本生成 实现子类注册器 (Sourcery refactored)
Diffstat (limited to 'src/hydrorollcore/core.py')
| -rw-r--r-- | src/hydrorollcore/core.py | 31 |
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 |
