fix(satellite): .env-Parser schneidet Inline-Kommentare ab
Nativer Start crashte an `SCAN_INTERVAL_SEC=300 # Hintergrund-Rescan-Intervall`
(int('300 # ...') → ValueError), weil der .env-Parser den Wert ungekuerzt
nahm. Jetzt: ungequotete Werte werden am ersten " #" (Whitespace+#) abgeschnitten,
gequotete Werte bleiben unangetastet (auch mit # im Inhalt). Getestet.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -66,8 +66,17 @@ def _load_dotenv() -> None:
|
||||
if key.startswith("export "):
|
||||
key = key[len("export "):].strip()
|
||||
val = val.strip()
|
||||
if len(val) >= 2 and val[0] == val[-1] and val[0] in ("'", '"'):
|
||||
val = val[1:-1]
|
||||
if val[:1] in ("'", '"'):
|
||||
# Gequotet: Inhalt bis zum schliessenden Quote, Rest (Kommentar) egal.
|
||||
q = val[0]
|
||||
end = val.find(q, 1)
|
||||
val = val[1:end] if end != -1 else val[1:]
|
||||
else:
|
||||
# Ungequotet: Inline-Kommentar (Whitespace + #) abschneiden.
|
||||
m = re.search(r"\s+#", val)
|
||||
if m:
|
||||
val = val[:m.start()]
|
||||
val = val.strip()
|
||||
if key and key not in os.environ:
|
||||
os.environ[key] = val
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user