feat: 使算法能被自动注册
This commit is contained in:
@@ -1,21 +1,14 @@
|
||||
import importlib
|
||||
import pkgutil
|
||||
from pathlib import Path
|
||||
|
||||
from .base import BaseAlgorithm
|
||||
from .sm2 import SM2Algorithm
|
||||
from .sm15m import SM15MAlgorithm
|
||||
from .nsp0 import NSP0Algorithm
|
||||
from .fsrs import FSRSAlgorithm
|
||||
|
||||
__all__ = [
|
||||
"SM2Algorithm",
|
||||
"BaseAlgorithm",
|
||||
"SM15MAlgorithm",
|
||||
"NSP0Algorithm",
|
||||
"FSRSAlgorithm",
|
||||
]
|
||||
__path__ = [str(Path(__file__).parent)]
|
||||
|
||||
algorithms = {
|
||||
"SM-2": SM2Algorithm,
|
||||
"NSP-0": NSP0Algorithm,
|
||||
"SM-15M": SM15MAlgorithm,
|
||||
"FSRS": FSRSAlgorithm,
|
||||
"Base": BaseAlgorithm,
|
||||
}
|
||||
for _finder, _name, _ispkg in pkgutil.iter_modules(__path__):
|
||||
if _name == "base":
|
||||
continue
|
||||
importlib.import_module(f".{_name}", __package__)
|
||||
|
||||
algorithms = BaseAlgorithm.get_registry()
|
||||
Reference in New Issue
Block a user