# -*- coding: utf-8 -*- """Met à jour le seul champ `content` de l'article « La villa romaine ». Rejouer `step2_sections.py` remettrait `contents` à vide et écraserait l'ordre posé par les étapes 6 et 7 : on relit donc la section telle qu'elle est en base et on ne remplace que son contenu. """ import json from pathlib import Path from api import Api, tr from content import ARTICLES STATE = Path(__file__).resolve().parent / "state.json" LABEL = "La villa romaine" def main(): state = json.loads(STATE.read_text(encoding="utf-8")) api = Api() config_id = state["configs"]["echternach"] sections = api.get(f"/api/Section/configuration/{config_id}") or [] listed = next(s for s in sections if s["label"] == LABEL) section = api.get(f"/api/Section/{listed['id']}") article = next(a for a in ARTICLES["echternach"] if a["label"] == LABEL) section["content"] = tr(**article["content"]) api.put("/api/Section", section) print(f" ~ {LABEL} : contenu mis à jour ({len(section['content'])} langues)") if __name__ == "__main__": main()