Files
linux-voice-assistant/script/lint_isort
2026-07-18 18:22:25 +02:00

30 lines
794 B
Python
Executable File

#!/usr/bin/env python3
import subprocess
import venv
from pathlib import Path
import sys
_DIR = Path(__file__).parent
_PROGRAM_DIR = _DIR.parent
_VENV_DIR = _PROGRAM_DIR / ".venv"
_MODULE_DIR = _PROGRAM_DIR / "linux_voice_assistant"
_TEST_DIRS = _PROGRAM_DIR / "tests"
_LINT_DIRS = [_MODULE_DIR, _TEST_DIRS]
if _VENV_DIR.exists():
context = venv.EnvBuilder().ensure_directories(_VENV_DIR)
python_exe = context.env_exe
else:
python_exe = "python3"
# Überprüfen, ob --auto angegeben wurde
auto_fix = "--auto" in sys.argv
if auto_fix:
# Automatisch formatieren
subprocess.check_call([python_exe, "-m", "isort"] + _LINT_DIRS)
else:
# Nur prüfen, ob Formatierung korrekt ist
subprocess.check_call([python_exe, "-m", "isort"] + _LINT_DIRS + ["--check", "--diff"])