You've already forked etude_lego_jurassic_world
Affiche le part_num sur les frises de têtes
This commit is contained in:
@@ -58,6 +58,7 @@ def build_character_collage(
|
||||
font: ImageFont.ImageFont,
|
||||
missing_paths: Set[str] | None = None,
|
||||
image_filename: str = "minifig.jpg",
|
||||
label_field: str = "fig_num",
|
||||
image_height: int = 260,
|
||||
label_height: int = 44,
|
||||
spacing: int = 28,
|
||||
@@ -69,7 +70,8 @@ def build_character_collage(
|
||||
for row in entries:
|
||||
image_path = resources_dir / row["set_id"] / sanitized / image_filename
|
||||
owned = "*" if row.get("in_collection", "").lower() == "true" else ""
|
||||
label = f"{row['year']} - {row['set_num']}{owned} ({row['fig_num']})"
|
||||
label_value = row[label_field]
|
||||
label = f"{row['year']} - {row['set_num']}{owned} ({label_value})"
|
||||
if str(image_path) in missing:
|
||||
image = build_placeholder(image_height)
|
||||
else:
|
||||
@@ -94,6 +96,7 @@ def build_character_collages(
|
||||
destination_dir: Path,
|
||||
missing_paths: Set[str] | None = None,
|
||||
image_filename: str = "minifig.jpg",
|
||||
label_field: str = "fig_num",
|
||||
image_height: int = 260,
|
||||
label_height: int = 44,
|
||||
spacing: int = 28,
|
||||
@@ -111,6 +114,7 @@ def build_character_collages(
|
||||
font,
|
||||
missing_paths=missing_paths,
|
||||
image_filename=image_filename,
|
||||
label_field=label_field,
|
||||
image_height=image_height,
|
||||
label_height=label_height,
|
||||
spacing=spacing,
|
||||
|
||||
@@ -28,17 +28,18 @@ def build_character_sets(
|
||||
) -> List[dict]:
|
||||
"""Associe chaque personnage connu aux sets où il apparaît (hors figurants)."""
|
||||
excluded = set(excluded_characters or [])
|
||||
seen: set[tuple[str, str, str]] = set()
|
||||
seen: set[tuple[str, str, str, str]] = set()
|
||||
character_sets: List[dict] = []
|
||||
for row in minifigs_rows:
|
||||
character = row["known_character"].strip()
|
||||
fig_num = row["fig_num"].strip()
|
||||
part_num = row["part_num"].strip()
|
||||
if character == "" or fig_num == "":
|
||||
continue
|
||||
if character in excluded:
|
||||
continue
|
||||
set_row = sets_lookup[row["set_num"]]
|
||||
key = (character, row["set_num"], fig_num)
|
||||
key = (character, row["set_num"], fig_num, part_num)
|
||||
if key in seen:
|
||||
continue
|
||||
character_sets.append(
|
||||
@@ -49,11 +50,12 @@ def build_character_sets(
|
||||
"year": set_row["year"],
|
||||
"fig_num": fig_num,
|
||||
"in_collection": set_row["in_collection"],
|
||||
"part_num": part_num,
|
||||
}
|
||||
)
|
||||
seen.add(key)
|
||||
character_sets.sort(
|
||||
key=lambda row: (row["known_character"], int(row["year"]), row["set_num"], row["fig_num"])
|
||||
key=lambda row: (row["known_character"], int(row["year"]), row["set_num"], row["fig_num"], row["part_num"])
|
||||
)
|
||||
return character_sets
|
||||
|
||||
@@ -61,7 +63,7 @@ def build_character_sets(
|
||||
def write_character_sets(destination_path: Path, rows: Sequence[dict]) -> None:
|
||||
"""Écrit le CSV listant les sets par personnage."""
|
||||
ensure_parent_dir(destination_path)
|
||||
fieldnames = ["known_character", "set_num", "set_id", "year", "fig_num", "in_collection"]
|
||||
fieldnames = ["known_character", "set_num", "set_id", "year", "fig_num", "in_collection", "part_num"]
|
||||
with destination_path.open("w", newline="") as csv_file:
|
||||
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
|
||||
writer.writeheader()
|
||||
|
||||
Reference in New Issue
Block a user