"""Analyse 01 : MA7D_DROP (tendance de BusVoltage en moyenne glissante), graphiques HTML ouverts dans le navigateur. Usage : python3 src/analyse_01.py [CSV ou dossiers...] (défaut : data/, sortie dans out/) Documentation : docs/analyses/analyse_01.md """ import importlib.util import os import shutil import subprocess import sys import webbrowser from pathlib import Path ROOT = Path(__file__).resolve().parent.parent VENV = ROOT / ".venv" / "bin" / "python" if importlib.util.find_spec("plotly") is None and VENV.exists(): os.execv(VENV, [str(VENV), *sys.argv]) # plotly n'est installé que dans .venv import energy_plot # noqa: E402 def open_html(path): if shutil.which("explorer.exe") and shutil.which("wslpath"): # WSL : navigateur Windows subprocess.run(["explorer.exe", subprocess.check_output(["wslpath", "-w", path], text=True).strip()]) else: webbrowser.open(Path(path).resolve().as_uri()) if __name__ == "__main__": args = sys.argv[1:] or [str(ROOT / "data")] for p in energy_plot.main([*args, "--out", str(ROOT / "out")]): open_html(p)