syntax fix
Sonarqube Scanner / Prepare environment (push) Successful in 5s
Sonarqube Scanner / Build and test (push) Successful in 19s
Sonarqube Scanner / SonarQube analysis (push) Failing after 55s
Sonarqube Scanner / Deploy to Server (push) Successful in 4s

This commit is contained in:
Florian Zumpe
2026-10-03 12:53:42 +02:00
parent 171ea88d55
commit cf4170f590
2 changed files with 30 additions and 14 deletions
+15 -14
View File
@@ -5,10 +5,10 @@ import argparse
from datetime import datetime, timezone
import os
from pathlib import Path
import re
import shlex
import sqlite3
import sys
import re
PROJECT_ROOT = Path(__file__).resolve().parents[2]
@@ -18,19 +18,20 @@ def database_path(project_root):
settings = {}
env_file = project_root / ".env"
try:
for number, line in enumerate(env_file.read_text(encoding="utf-8-sig").splitlines(), 1):
line = re.sub(r'^\s*export\s+', '', line).strip()
if not line or line.startswith("#"):
continue
if line.startswith("export "):
line = line[7:].lstrip()
key, separator, value = line.partition("=")
if not separator:
raise ValueError(f"Ungültige .env-Angabe in Zeile {number}.")
try:
settings[key.strip()] = " ".join(shlex.split(value, comments=True))
except ValueError as error:
raise ValueError(f"Ungültige .env-Anführungszeichen in Zeile {number}.") from error
contents = env_file.read_text(encoding="utf-8-sig")
except FileNotFoundError:
contents = ""
for number, line in enumerate(contents.splitlines(), 1):
line = re.sub(r'^\s*export\s+', '', line).strip()
if not line or line.startswith("#"):
continue
key, separator, value = line.partition("=")
if not separator:
raise ValueError(f"Ungültige .env-Angabe in Zeile {number}.")
try:
settings[key.strip()] = " ".join(shlex.split(value, comments=True))
except ValueError as error:
raise ValueError(f"Ungültige .env-Anführungszeichen in Zeile {number}.") from error
data_dir = os.environ.get("DATA_DIR", settings.get("DATA_DIR", "")) or "data"
return (project_root / data_dir / "wegwichtel.sqlite").resolve()