Repository Public MIT Research preview
1"""Écrit les cinq fichiers du dossier à partir de dossier.py, à trois endroits :2demos/dossier/, labs/starter/dossier/ et labs/solution/dossier/.34Usage : python ecrire_dossier.py [--check]5"""6from __future__ import annotations78import sys9from pathlib import Path1011sys.path.insert(0, str(Path(__file__).resolve().parent.parent))1213from atlas_s08.dossier import FICHIERS # noqa: E4021415SESSION = Path(__file__).resolve().parents[3]16CIBLES = [SESSION / "demos" / "dossier", SESSION / "labs" / "starter" / "dossier", SESSION / "labs" / "solution" / "dossier"]171819def a_jour() -> bool:20 return all((cible / nom).exists() and (cible / nom).read_text(encoding="utf-8") == contenu()21 for cible in CIBLES for nom, contenu in FICHIERS.items())222324if __name__ == "__main__":25 if "--check" in sys.argv:26 sys.exit(0 if a_jour() else 1)27 for cible in CIBLES:28 cible.mkdir(parents=True, exist_ok=True)29 for nom, contenu in FICHIERS.items():30 (cible / nom).write_text(contenu(), encoding="utf-8", newline="\n")31 print(f"dossier écrit à {len(CIBLES)} endroits : {', '.join(FICHIERS)}")32