-
ComicProfile — Comic-side inputs for the matcher.
-
CandidateSummary — Display fields shown in the prompt UX.
-
Candidate — One search result, post-ranking.
comicbox.formats.base.online.profile¶
source module comicbox.formats.base.online.profile
ComicProfile / Candidate types and helpers.
ComicProfile is the input the matcher reads to score candidates against the comic at hand. It’s built once per comic from the normalized non-online source metadata so we don’t depend on what the online lookup itself produced.
Candidate and CandidateSummary are the matcher output unit — one per search hit.
Classes
Functions
-
parse_issue_int — Return the integer form of an issue number when parseable.
-
strip_issue_leading_zeros — Strip leading zeros from an issue number string, preserving any suffix.
-
parse_year — Pull a 4-digit year out of a date-ish input.
-
accumulate_profile_fields — Last-wins accumulation of profile fields across normalized sources.
source class ComicProfile()
Comic-side inputs for the matcher.
source class CandidateSummary()
Display fields shown in the prompt UX.
One search result, post-ranking.
source parse_issue_int(raw: Any) → int | None
Return the integer form of an issue number when parseable.
Strips leading zeros (001 → 1); returns None for non-numeric forms like 1a, 1.5, 0a, Special, etc.
source strip_issue_leading_zeros(raw: str | None) → str | None
Strip leading zeros from an issue number string, preserving any suffix.
Used when building API search params: comicvine, metron, etc. expect 7 not 007. Variant suffixes (a, .5) survive unchanged.
Examples
“007” → “7” “001a” → “1a” “0” → “0” “1.5” → “1.5” “Special” → “Special” None → None
source parse_year(raw: Any) → int | None
Pull a 4-digit year out of a date-ish input.
source accumulate_profile_fields(fields: dict[str, Any], md: dict) → None
Last-wins accumulation of profile fields across normalized sources.
Callers feed sources in MetadataSources enum order, which is the same order the main merge overlays them (box/merge.py, _set_merged_metadata) — and that merge is last-wins: a higher-precedence source overwrites an earlier one. So a later source that supplies a field overwrites the value already collected, which is why embedded archive files (ARCHIVE_FILE) beat the filename parse (ARCHIVE_FILENAME) here, matching the merged metadata the rest of comicbox produces. A later source that lacks the field leaves the earlier value intact (the truthiness guards below), so absent embedded fields still fall back to the filename.