add 插件API
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
from types import FunctionType
|
||||
from typing import Generator, Optional
|
||||
|
||||
from app.core.config import settings
|
||||
from app.helper.module import ModuleHelper
|
||||
from app.log import logger
|
||||
from app.utils.object import ObjectUtils
|
||||
from app.utils.singleton import Singleton
|
||||
|
||||
|
||||
@ -68,16 +68,9 @@ class ModuleManager(metaclass=Singleton):
|
||||
"""
|
||||
获取模块列表
|
||||
"""
|
||||
|
||||
def check_method(func: FunctionType) -> bool:
|
||||
"""
|
||||
检查函数是否已实现
|
||||
"""
|
||||
return func.__code__.co_code != b'd\x01S\x00'
|
||||
|
||||
if not self._running_modules:
|
||||
return []
|
||||
for _, module in self._running_modules.items():
|
||||
if hasattr(module, method) \
|
||||
and check_method(getattr(module, method)):
|
||||
and ObjectUtils.check_method(getattr(module, method)):
|
||||
yield module
|
||||
|
Reference in New Issue
Block a user