"""Trace la répartition des minifigs par genre."""

from pathlib import Path

from lib.plots.minifig_gender_share import plot_minifig_gender_share
from lib.rebrickable.minifig_characters import (
    aggregate_by_gender,
    load_minifigs_by_set,
    write_gender_counts,
)


MINIFIGS_BY_SET_PATH = Path("data/intermediate/minifigs_by_set.csv")
GENDER_COUNTS_PATH = Path("data/intermediate/minifig_gender_counts.csv")
DESTINATION_PATH = Path("figures/step25/minifig_gender_share.png")


def main() -> None:
    """Construit le CSV de répartition par genre et trace le graphique."""
    rows = load_minifigs_by_set(MINIFIGS_BY_SET_PATH)
    aggregates = aggregate_by_gender(rows)
    write_gender_counts(GENDER_COUNTS_PATH, aggregates)
    plot_minifig_gender_share(GENDER_COUNTS_PATH, DESTINATION_PATH)


if __name__ == "__main__":
    main()
