def get_auteur_name(uid: str) -> str: acteurs = get_data("acteurs") if uid not in acteurs: raise ValueError(f"Unknown auteur {uid}") acteur = acteurs[uid] ident: Dict[str, str] = acteur["etatCivil"]["ident"] return ident["prenom"] + " " + ident["nom"]
def _find_texte(uid: str) -> Texte: # FIXME: this is not efficient dossiers: Dict[str, Dossier] = get_data("dossiers") for dossier in dossiers.values(): for lecture in dossier.lectures: if lecture.texte.uid == uid: return lecture.texte raise ValueError(f"Unknown texte {uid}")
def format_organe(self) -> str: from zam_repondeur.data import get_data # avoid circular imports result: str = self.organe organes = get_data("organes") if self.organe in organes: organe_data = organes[self.organe] result = organe_data["libelleAbrege"] return self.rewrite_organe(result)
def choices_lectures(request: Request) -> dict: uid = request.matchdict["uid"] dossiers_by_uid = get_data("dossiers") dossier = dossiers_by_uid[uid] return { "lectures": [{ "key": f"{lecture.texte.uid}-{lecture.organe}", "label": " – ".join([ str(lecture.chambre), lecture.titre, f"Texte Nº {lecture.texte.numero}", ]), } for lecture in dossier.lectures] }
def __init__(self, context: LectureCollection, request: Request) -> None: self.context = context self.request = request self.dossiers_by_uid: Dict[str, Dossier] = get_data("dossiers")
def get_groupe_name(uid: str) -> str: organes = get_data("organes") if uid not in organes: raise ValueError(f"Unknown groupe {uid}") libelle: str = organes[uid]["libelle"] return libelle
def test_get_organes(): from zam_repondeur.data import get_data organes = get_data("organes") assert "PO717460" in organes
def test_get_dossiers(): from zam_repondeur.data import get_data dossiers = get_data("dossiers") assert "DLR5L15N36030" in dossiers
def test_get_acteurs(): from zam_repondeur.data import get_data acteurs = get_data("acteurs") assert "PA718838" in acteurs