Files
claude-werkzeuge/.claude/skills/plane-abgleich/scripts/plane/konfiguration.py
T
Pascal MichelandClaude Opus 5.5 fa1c26b407 Erste Fassung: Claude-Werkzeuge aus dem Vault
.vault-tools (ohne trading-plattform-pruefung und watermarks-remover),
.claude/agents, .claude/skills, .claude/workflows, .claude/settings.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 11:27:59 +02:00

52 lines
1.6 KiB
Python

"""Liest die Plane-Zugangsdaten aus Umgebungsvariablen."""
from __future__ import annotations
import os
from collections.abc import Mapping
from dataclasses import dataclass, field
from pathlib import Path
STANDARD_QUELLE = Path(r"D:\Claude\Code Projekte")
PFLICHTVARIABLEN = ("PLANE_URL", "PLANE_API_KEY", "PLANE_WORKSPACE")
class KonfigurationsFehler(Exception):
"""Zugangsdaten fehlen oder sind unbrauchbar."""
@dataclass(frozen=True)
class Konfiguration:
basis_url: str
api_key: str = field(repr=False)
workspace: str = ""
quelle: Path = STANDARD_QUELLE
def lade_konfiguration(umgebung: Mapping[str, str] | None = None) -> Konfiguration:
"""Baut die Konfiguration aus der Umgebung; meldet alle Lücken auf einmal."""
werte = os.environ if umgebung is None else umgebung
fehlend = [name for name in PFLICHTVARIABLEN if not werte.get(name, "").strip()]
if fehlend:
raise KonfigurationsFehler(
"Diese Umgebungsvariablen fehlen oder sind leer: "
+ ", ".join(fehlend)
+ ". Siehe README.md, Abschnitt \u201eEinrichtung\u201c."
)
basis_url = werte["PLANE_URL"].strip().rstrip("/")
if not basis_url.startswith(("http://", "https://")):
raise KonfigurationsFehler(
f"PLANE_URL muss mit http:// oder https:// beginnen, "
f"ist aber \u201e{basis_url}\u201c."
)
quelle = werte.get("PLANE_QUELLE", "").strip()
return Konfiguration(
basis_url=basis_url,
api_key=werte["PLANE_API_KEY"].strip(),
workspace=werte["PLANE_WORKSPACE"].strip(),
quelle=Path(quelle) if quelle else STANDARD_QUELLE,
)