"""Calcule les têtes dual-face des minifigs et leurs agrégats.""" from pathlib import Path from lib.rebrickable.minifig_head_faces import ( aggregate_by_character, aggregate_by_set, aggregate_by_year, build_head_faces, write_csv, ) MINIFIGS_BY_SET_PATH = Path("data/intermediate/minifigs_by_set.csv") PARTS_CATALOG_PATH = Path("data/raw/parts.csv") SETS_ENRICHED_PATH = Path("data/intermediate/sets_enriched.csv") HEAD_FACES_PATH = Path("data/intermediate/minifig_head_faces.csv") HEAD_FACES_BY_YEAR_PATH = Path("data/intermediate/minifig_head_faces_by_year.csv") HEAD_FACES_BY_SET_PATH = Path("data/intermediate/minifig_head_faces_by_set.csv") HEAD_FACES_BY_CHARACTER_PATH = Path("data/intermediate/minifig_head_faces_by_character.csv") def main() -> None: """Construit les listes et agrégats des têtes à visages multiples.""" heads = build_head_faces(MINIFIGS_BY_SET_PATH, PARTS_CATALOG_PATH, SETS_ENRICHED_PATH) by_year = aggregate_by_year(heads) by_set = aggregate_by_set(heads) by_character = aggregate_by_character(heads) write_csv( HEAD_FACES_PATH, heads, [ "set_num", "set_id", "year", "name", "in_collection", "part_num", "part_name", "fig_num", "known_character", "gender", "is_dual_face", ], ) write_csv( HEAD_FACES_BY_YEAR_PATH, by_year, ["year", "total_heads", "dual_heads", "share_dual"], ) write_csv( HEAD_FACES_BY_SET_PATH, by_set, ["set_num", "set_id", "name", "year", "in_collection", "total_heads", "dual_heads", "share_dual"], ) write_csv( HEAD_FACES_BY_CHARACTER_PATH, by_character, ["known_character", "gender", "total_heads", "dual_heads", "share_dual"], ) if __name__ == "__main__": main()