调试后整体可以使用的版本。
This commit is contained in:
@@ -587,7 +587,7 @@ class ProjectBuilder:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def register(toolkit_class: type, config: dict):
|
||||
def register(cls, toolkit_class: type, config: dict):
|
||||
"""
|
||||
注册工具类到工厂
|
||||
|
||||
@@ -597,10 +597,11 @@ class ProjectBuilder:
|
||||
if not issubclass(toolkit_class, ProjectToolkit):
|
||||
raise TypeError(f"{toolkit_class.__name__} 必须继承自 ProjectToolkit")
|
||||
|
||||
_config = config
|
||||
_registry = toolkit_class
|
||||
cls._config = config
|
||||
cls._registry = toolkit_class
|
||||
|
||||
def build(self) -> ProjectToolkit:
|
||||
@classmethod
|
||||
def build(cls) -> ProjectToolkit:
|
||||
"""
|
||||
创建工具实例
|
||||
|
||||
@@ -609,7 +610,7 @@ class ProjectBuilder:
|
||||
返回:
|
||||
实例化的工具对象
|
||||
"""
|
||||
if _registry is None:
|
||||
if cls._registry is None:
|
||||
raise KeyError(f"未注册的类,请先注册类")
|
||||
|
||||
return _registry(_config)
|
||||
return cls._registry(cls._config)
|
||||
|
||||
Reference in New Issue
Block a user