This commit is contained in:
2025-11-13 01:02:07 +01:00
parent 67e5ed3807
commit 8ce890cae5
18 changed files with 767 additions and 442 deletions

31
src/services/discovery.py Normal file
View File

@@ -0,0 +1,31 @@
from __future__ import annotations
import os
from pathlib import Path
from typing import List, Tuple
def discover_playbooks(root: Path, data_subdir: str = "data") -> List[Tuple[str, Path, int]]:
"""
Liefert Liste aus (Display-Text, voller Pfad, Level).
Ignoriert das data-Verzeichnis auf oberster Ebene.
"""
playbooks: List[Tuple[str, Path, int]] = []
if not root.exists():
return playbooks
for dirpath, dirnames, filenames in os.walk(root):
path = Path(dirpath)
# ignore top-level data dir
if path.parent == root and path.name == data_subdir:
dirnames[:] = []
continue
rel = path.relative_to(root)
level = 0 if rel == Path(".") else len(rel.parts)
for fn in filenames:
if fn.endswith(".yml") or fn.endswith(".yaml"):
full = path / fn
indent = " " * level
display = f"{indent}{fn}"
playbooks.append((display, full, level))
return playbooks