You've already forked etude_lego_jurassic_world
Exclusion des pièces imprimées dans la recherche de rareté
This commit is contained in:
@@ -46,6 +46,7 @@ def aggregate_filtered_parts(
|
||||
parts_catalog: Dict[str, dict],
|
||||
ignored_categories: Set[str] = IGNORED_PART_CATEGORY_IDS,
|
||||
ignored_minifig_categories: Set[str] = MINIFIG_PART_CATEGORY_IDS,
|
||||
exclude_printed: bool = False,
|
||||
) -> Dict[str, dict]:
|
||||
"""Agrège les quantités par pièce pour les sets filtrés (rechanges incluses)."""
|
||||
aggregated: Dict[str, dict] = {}
|
||||
@@ -57,6 +58,8 @@ def aggregate_filtered_parts(
|
||||
continue
|
||||
if part["part_cat_id"] in ignored_minifig_categories:
|
||||
continue
|
||||
if exclude_printed and "print" in part["name"].lower():
|
||||
continue
|
||||
entry = aggregated.get(row["part_num"])
|
||||
if entry is None:
|
||||
entry = {"quantity": 0, "set_numbers": set()}
|
||||
@@ -73,6 +76,7 @@ def compute_other_set_usage(
|
||||
filtered_set_numbers: Set[str],
|
||||
ignored_categories: Set[str] = IGNORED_PART_CATEGORY_IDS,
|
||||
ignored_minifig_categories: Set[str] = MINIFIG_PART_CATEGORY_IDS,
|
||||
exclude_printed: bool = False,
|
||||
) -> Dict[str, int]:
|
||||
"""Compte les occurrences des pièces dans le reste du catalogue (rechanges incluses)."""
|
||||
inventories = select_latest_inventories(inventories_path)
|
||||
@@ -87,6 +91,8 @@ def compute_other_set_usage(
|
||||
continue
|
||||
if part["part_cat_id"] in ignored_minifig_categories:
|
||||
continue
|
||||
if exclude_printed and "print" in part["name"].lower():
|
||||
continue
|
||||
totals[row["part_num"]] = totals.get(row["part_num"], 0) + int(row["quantity"])
|
||||
return totals
|
||||
|
||||
@@ -98,6 +104,7 @@ def build_part_rarity(
|
||||
parts_catalog_path: Path,
|
||||
part_categories_path: Path,
|
||||
filtered_sets_path: Path,
|
||||
exclude_printed: bool = False,
|
||||
) -> List[dict]:
|
||||
"""Construit le classement de rareté des pièces filtrées."""
|
||||
parts_catalog = load_parts_catalog(parts_catalog_path)
|
||||
@@ -105,12 +112,13 @@ def build_part_rarity(
|
||||
filtered_sets = load_filtered_sets(filtered_sets_path)
|
||||
filtered_set_numbers = set(filtered_sets.keys())
|
||||
filtered_rows = read_rows(parts_filtered_path)
|
||||
filtered_usage = aggregate_filtered_parts(filtered_rows, parts_catalog)
|
||||
filtered_usage = aggregate_filtered_parts(filtered_rows, parts_catalog, exclude_printed=exclude_printed)
|
||||
other_usage = compute_other_set_usage(
|
||||
inventories_path,
|
||||
inventory_parts_path,
|
||||
parts_catalog,
|
||||
filtered_set_numbers,
|
||||
exclude_printed=exclude_printed,
|
||||
)
|
||||
rows: List[dict] = []
|
||||
for part_num, entry in filtered_usage.items():
|
||||
|
||||
Reference in New Issue
Block a user