aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/infini/core.py35
-rw-r--r--src/infini/exceptions.py2
-rw-r--r--src/infini/input.py3
-rw-r--r--src/infini/loader.py5
-rw-r--r--src/infini/output.py5
5 files changed, 32 insertions, 18 deletions
diff --git a/src/infini/core.py b/src/infini/core.py
index 7c84a15f..0de6034c 100644
--- a/src/infini/core.py
+++ b/src/infini/core.py
@@ -15,9 +15,7 @@ class Core:
interceptor: Interceptor
injector: Injector
- def input(
- self, input: Input
- ) -> GeneratorT[Union[str, Output], Any, None]:
+ def input(self, input: Input) -> GeneratorT[Union[str, Output], Any, None]:
for pre_intercepted_stream in self.pre_intercept(input):
if isinstance(pre_intercepted_stream, Output):
if not isinstance(pre_intercepted_stream, Output):
@@ -26,7 +24,15 @@ class Core:
)
if pre_intercepted_stream.is_empty():
return
- yield self.generate(pre_intercepted_stream)
+ if pre_intercepted_stream.type == "workflow":
+ yield pre_intercepted_stream
+ if pre_intercepted_stream.block:
+ while pre_intercepted_stream.status != 0:
+ pass
+ continue
+ else:
+ yield self.generate(pre_intercepted_stream) # TODO 拦截拦截器文本
+
if pre_intercepted_stream.block:
return
else:
@@ -39,14 +45,27 @@ class Core:
)
if handled_stream.is_empty():
return
- outcome = self.generate(handled_stream)
+ if handled_stream.type == "workflow":
+ yield handled_stream
+ if handled_stream.block:
+ while handled_stream.status != 0:
+ pass
+ continue
+ else:
+ outcome = self.generate(handled_stream)
for stream in self.intercept(handled_stream, outcome):
if isinstance(stream, Output):
if stream.is_empty():
return
- yield self.generate(stream)
- if stream.block:
- return
+ if stream.type == "workflow":
+ yield stream
+ if stream.block:
+ while stream.status != 0:
+ pass
+ else:
+ yield self.generate(stream)
+ if stream.block:
+ return
continue
outcome = stream
yield outcome
diff --git a/src/infini/exceptions.py b/src/infini/exceptions.py
index 2e2b0197..ac9c3d22 100644
--- a/src/infini/exceptions.py
+++ b/src/infini/exceptions.py
@@ -11,7 +11,7 @@ class UnknownEvent(InfiniException):
class UnknownEventType(InfiniException, TypeError):
- """文本事件不存在"""
+ """事件类型不存在"""
class ValueError(InfiniException, ValueError):
diff --git a/src/infini/input.py b/src/infini/input.py
index 30683a4b..0bbb3f2f 100644
--- a/src/infini/input.py
+++ b/src/infini/input.py
@@ -32,10 +32,9 @@ class Input(Generic[T]):
type: Literal["text", "workflow"],
name: str,
*,
- status: int = 0,
block: bool = False,
variables: Dict[str, Any] = {},
):
vars = self.variables.copy()
vars.update(variables)
- return Output(type, name, status=status, block=block, variables=vars)
+ return Output(type, name, block=block, variables=vars)
diff --git a/src/infini/loader.py b/src/infini/loader.py
index 07ebe0a8..f02dd910 100644
--- a/src/infini/loader.py
+++ b/src/infini/loader.py
@@ -82,10 +82,7 @@ class InfiniLoader(importlib.abc.Loader):
def _install():
- if not sys.meta_path:
- raise OSError("Var 'sys.meta_path' is empty, since Python is stop.")
- if not isinstance(sys.meta_path[0], InfiniMetaFinder):
- sys.meta_path.insert(0, InfiniMetaFinder())
+ sys.meta_path.insert(0, InfiniMetaFinder())
def _uninstall():
diff --git a/src/infini/output.py b/src/infini/output.py
index 13f26d47..6520d9b4 100644
--- a/src/infini/output.py
+++ b/src/infini/output.py
@@ -14,19 +14,18 @@ class Output:
type: Union[Literal["null", "text", "workflow"], str],
name: str,
*,
- status: int = 0,
block: bool = False,
variables: Dict[str, Any] = {},
) -> None:
self.type = type
self.name = name
- self.status = status
+ self.status = 1
self.block = block
self.variables = variables
@classmethod
def empty(cls) -> "Output":
- return cls("null", "null", status=0, block=True)
+ return cls("null", "null", block=True)
def is_empty(self) -> bool:
return self.type == "null"