"""Calcule les pièces rares (variantes exclusives) et leurs agrégats."""

from pathlib import Path

from lib.rebrickable.rare_parts import (
    build_rare_parts,
    write_rare_parts_by_set,
    write_rare_parts_list,
)


PARTS_PATH = Path("data/intermediate/parts_filtered.csv")
SETS_PATH = Path("data/intermediate/sets_enriched.csv")
PARTS_CATALOG_PATH = Path("data/raw/parts.csv")
COLORS_PATH = Path("data/raw/colors.csv")
RARE_PARTS_PATH = Path("data/intermediate/rare_parts.csv")
RARE_PARTS_BY_SET_PATH = Path("data/intermediate/rare_parts_by_set.csv")


def main() -> None:
    """Construit les fichiers listant les pièces rares et leur répartition par set."""
    rare_parts, rare_by_set = build_rare_parts(PARTS_PATH, SETS_PATH, PARTS_CATALOG_PATH, COLORS_PATH)
    write_rare_parts_list(RARE_PARTS_PATH, rare_parts)
    write_rare_parts_by_set(RARE_PARTS_BY_SET_PATH, rare_by_set)


if __name__ == "__main__":
    main()
