refactor: add pipe module
This commit is contained in:
@@ -1,30 +1,34 @@
|
||||
from cmath import pi
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from ..entry import Entry, EntryDetector
|
||||
from ..pipe.core import PipeParser, PipeRunner
|
||||
from .util import PresetUtil
|
||||
from .value import ValueResolver
|
||||
|
||||
__all__ = ("PresetEntryDetector",)
|
||||
|
||||
|
||||
class PresetEntryDetector(EntryDetector):
|
||||
_PIPE_PARSER = PipeParser()
|
||||
|
||||
def __init__(self, filename: Path):
|
||||
self._preset = PresetUtil.resolve_preset(filename)
|
||||
self._pipeparser = PipeParser()
|
||||
|
||||
def detect_entry(self, basepath: Path) -> Optional["Entry"]:
|
||||
piperunner = PipeRunner(basepath)
|
||||
tasks = defaultdict(list)
|
||||
for preset_name, preset in self._preset.presets.items():
|
||||
filename = basepath / preset.filename
|
||||
if filename.exists():
|
||||
value_resolver = ValueResolver(basepath)
|
||||
for task_name, task_pack in preset.tasks.items():
|
||||
for task_item_name, task in task_pack.items():
|
||||
if value_resolver.check_conditions(task.conditions):
|
||||
if piperunner.check_conditions(task.conditions):
|
||||
variables = (
|
||||
{
|
||||
k: value_resolver.resolve_value(v)
|
||||
k: piperunner.resolve_value(v)
|
||||
for k, v in task.variables.items()
|
||||
}
|
||||
if task.variables
|
||||
|
||||
Reference in New Issue
Block a user