51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
"""Assemble des grilles verticales filtrées sur les personnages multi-variations."""
|
|
|
|
from pathlib import Path
|
|
|
|
from lib.plots.minifig_character_collages import filter_characters_with_variations, stack_collages
|
|
from lib.rebrickable.minifig_character_sets import (
|
|
build_character_sets,
|
|
group_by_character,
|
|
load_minifigs_by_set,
|
|
load_sets,
|
|
)
|
|
from lib.rebrickable.resources import sanitize_name
|
|
from lib.rebrickable.resources import sanitize_name
|
|
|
|
|
|
MINIFIGS_BY_SET_PATH = Path("data/intermediate/minifigs_by_set.csv")
|
|
SETS_ENRICHED_PATH = Path("data/intermediate/sets_enriched.csv")
|
|
CHARACTERS_DIR = Path("figures/step32/minifig_characters")
|
|
HEADS_DIR = Path("figures/step32/minifig_heads")
|
|
CHARACTERS_DEST = Path("figures/step32/minifig_characters_all.png")
|
|
HEADS_DEST = Path("figures/step32/minifig_heads_all.png")
|
|
EXCLUDED_CHARACTERS = ["Figurant"]
|
|
|
|
|
|
def main() -> None:
|
|
"""Superpose les frises de personnages ayant au moins deux variations."""
|
|
minifigs = load_minifigs_by_set(MINIFIGS_BY_SET_PATH)
|
|
sets_lookup = load_sets(SETS_ENRICHED_PATH)
|
|
character_sets = build_character_sets(minifigs, sets_lookup, excluded_characters=EXCLUDED_CHARACTERS)
|
|
grouped = group_by_character(character_sets)
|
|
filtered = filter_characters_with_variations(grouped, min_variations=2)
|
|
keep = {sanitize_name(name) for name in filtered.keys()}
|
|
labels = {sanitize_name(name): name for name in filtered.keys()}
|
|
|
|
for source_dir, destination in (
|
|
(CHARACTERS_DIR, CHARACTERS_DEST),
|
|
(HEADS_DIR, HEADS_DEST),
|
|
):
|
|
stack_collages(
|
|
source_dir,
|
|
destination,
|
|
spacing=12,
|
|
allowed_stems=keep,
|
|
name_panel_width=160,
|
|
labels_by_stem=labels,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|