Роутер работает нормально в process v2
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Shared helpers for pipeline_setup_v4."""
|
||||
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from app.core.shared.config import load_workspace_env
|
||||
|
||||
|
||||
def load_pipeline_setup_env(start_dir: str | Path | None = None) -> list[Path]:
|
||||
base = Path(start_dir or Path.cwd()).resolve()
|
||||
loaded = load_workspace_env(start_dir=base)
|
||||
env_path = _find_v4_root(base) / ".env"
|
||||
if env_path.is_file():
|
||||
_apply_env_file(env_path)
|
||||
loaded.append(env_path)
|
||||
return loaded
|
||||
|
||||
|
||||
def _find_v4_root(base: Path) -> Path:
|
||||
for directory in (base, *base.parents):
|
||||
if directory.name == "pipeline_setup_v4" and (directory / "__init__.py").is_file():
|
||||
return directory
|
||||
raise RuntimeError(f"Unable to locate tests/pipeline_setup_v4 root from: {base}")
|
||||
|
||||
|
||||
def _apply_env_file(path: Path) -> None:
|
||||
for raw_line in path.read_text(encoding="utf-8").splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
key, raw_value = line.split("=", 1)
|
||||
name = key.removeprefix("export ").strip()
|
||||
if name:
|
||||
os.environ[name] = _normalize_value(raw_value.strip())
|
||||
|
||||
|
||||
def _normalize_value(value: str) -> str:
|
||||
if len(value) >= 2 and value[0] == value[-1] and value[0] in {"'", '"'}:
|
||||
return value[1:-1]
|
||||
return value
|
||||
Reference in New Issue
Block a user