Import latest creature artwork
This commit is contained in:
parent
7050ca2f23
commit
ea4d38cb49
44 changed files with 540 additions and 35 deletions
|
|
@ -105,6 +105,7 @@ def catalog_lookup(records: list[dict[str, str]]) -> dict[str, dict[str, str]]:
|
|||
lookup: dict[str, dict[str, str]] = {}
|
||||
for record in records:
|
||||
keys = {
|
||||
normalize_name(record["catalog_number"]),
|
||||
normalize_name(record["id"]),
|
||||
normalize_name(record["display_name"]),
|
||||
}
|
||||
|
|
@ -173,8 +174,7 @@ def main() -> int:
|
|||
if not source_paths:
|
||||
raise ValueError(f"no PNG files found under {arguments.source}")
|
||||
|
||||
resolved: list[tuple[Path, dict[str, str]]] = []
|
||||
output_names: set[str] = set()
|
||||
resolved_by_output: dict[str, tuple[Path, dict[str, str]]] = {}
|
||||
for source_path in source_paths:
|
||||
record = resolve_record(source_path, lookup)
|
||||
source_key = normalize_name(source_path.stem)
|
||||
|
|
@ -183,10 +183,36 @@ def main() -> int:
|
|||
print(f"SKIP {source_path.name} -> {record['id']}")
|
||||
continue
|
||||
output_name = f"{record['catalog_number']}.png"
|
||||
if output_name in output_names:
|
||||
raise ValueError(f"duplicate output filename {output_name}")
|
||||
output_names.add(output_name)
|
||||
resolved.append((source_path, record))
|
||||
previous = resolved_by_output.get(output_name)
|
||||
if previous is not None:
|
||||
previous_path, _previous_record = previous
|
||||
catalog_key = normalize_name(record["catalog_number"])
|
||||
previous_is_numbered = (
|
||||
normalize_name(previous_path.stem) == catalog_key
|
||||
)
|
||||
current_is_numbered = source_key == catalog_key
|
||||
if current_is_numbered and not previous_is_numbered:
|
||||
print(
|
||||
"SUPERSEDE "
|
||||
f"{previous_path.name} with numbered source "
|
||||
f"{source_path.name} -> {record['id']}"
|
||||
)
|
||||
resolved_by_output[output_name] = (source_path, record)
|
||||
continue
|
||||
if previous_is_numbered and not current_is_numbered:
|
||||
print(
|
||||
"SKIP "
|
||||
f"{source_path.name}; numbered source "
|
||||
f"{previous_path.name} takes precedence -> {record['id']}"
|
||||
)
|
||||
continue
|
||||
raise ValueError(
|
||||
f"duplicate sources for output filename {output_name}: "
|
||||
f"{previous_path.name} and {source_path.name}"
|
||||
)
|
||||
resolved_by_output[output_name] = (source_path, record)
|
||||
|
||||
resolved = list(resolved_by_output.values())
|
||||
|
||||
if not arguments.dry_run:
|
||||
arguments.output.mkdir(parents=True, exist_ok=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue