lib.ProcFilter: Add run()
Add a run() function. It constructs a pipeline from various possible types, and runs its data parameter through it.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
1c11503dfb
commit
fe1eb0014a
1 changed files with 8 additions and 0 deletions
|
|
@ -42,3 +42,11 @@ class ProcPipeline:
|
|||
for f in self.__filters:
|
||||
ret = await f.run(ret.stdout)
|
||||
return ret
|
||||
|
||||
async def run(data: bytes|Result, chain: ProcFilter|list[ProcFilter]|ProcPipeline|None = None) -> Result:
|
||||
if chain is None:
|
||||
if isinstance(data, Result):
|
||||
return data
|
||||
return Result(data, None, 0)
|
||||
pl = chain if isinstance(chain, ProcPipeline) else ProcPipeline(chain)
|
||||
return await pl.run(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue