Skip to content

comicbox.formats.versedb_api.transform ¶

VerseDB API transform.

Converts a VerseDB issue-detail data object (the server’s JSON, as the versedb_api.client adapter returns it) into the comicbox internal schema. Same explicit-Python, block-tuple style as ComicVineApiTransform: the detail already nests the series, publisher, imprint, credits, characters, teams, arcs and universes, so one dict carries everything.

VerseDB’s web pages need the issue’s exact slug, so the issue’s real link is written to urls; its identifier holds only the id and derives no link of its own (see the versedb.com entry in identifiers.identifiers).

VerseDBApiTransform ¶

Bases: BaseTransform

VerseDB issue detail → comicbox internal schema.

Source code in comicbox/formats/versedb_api/transform.py
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
class VerseDBApiTransform(BaseTransform):
    """VerseDB issue detail → comicbox internal schema."""

    SCHEMA_CLASS = VerseDBApiSchema
    SPECS_TO = MappingProxyType({})  # not used; we override to_comicbox
    SPECS_FROM = MappingProxyType({})

    @override
    def to_comicbox(self, data: Mapping) -> MappingProxyType:
        """Convert a VerseDB issue detail into a validated comicbox dict."""
        issue_data = data.get(VerseDBApiSchema.ROOT_TAG) or data
        if not issue_data:
            return MappingProxyType({})

        wrapped = {ComicboxSchemaMixin.ROOT_TAG: _to_comicbox_dict(issue_data)}
        schema = get_schema(ComicboxYamlSchema, path=self._path)
        loaded: dict = schema.load(wrapped)  # pyright: ignore[reportAssignmentType]
        return MappingProxyType(loaded)

to_comicbox(data) ¶

Convert a VerseDB issue detail into a validated comicbox dict.

Source code in comicbox/formats/versedb_api/transform.py
338
339
340
341
342
343
344
345
346
347
348
@override
def to_comicbox(self, data: Mapping) -> MappingProxyType:
    """Convert a VerseDB issue detail into a validated comicbox dict."""
    issue_data = data.get(VerseDBApiSchema.ROOT_TAG) or data
    if not issue_data:
        return MappingProxyType({})

    wrapped = {ComicboxSchemaMixin.ROOT_TAG: _to_comicbox_dict(issue_data)}
    schema = get_schema(ComicboxYamlSchema, path=self._path)
    loaded: dict = schema.load(wrapped)  # pyright: ignore[reportAssignmentType]
    return MappingProxyType(loaded)

issue_url(issue_id, slug) ¶

Build the issue’s versedb.com link, which needs its exact slug.

Source code in comicbox/formats/versedb_api/transform.py
116
117
118
119
120
def issue_url(issue_id: Any, slug: str | None) -> str | None:
    """Build the issue's versedb.com link, which needs its exact slug."""
    if issue_id is None or not slug:
        return None
    return f"{WEBSITE}/issue/{issue_id}/{slug}"

original_format(series) ¶

Prefer a collected physical format; else map the publication type.

Source code in comicbox/formats/versedb_api/transform.py
158
159
160
161
162
def original_format(series: Mapping[str, Any]) -> str | None:
    """Prefer a collected physical format; else map the publication type."""
    return _PHYSICAL_FORMATS.get(series.get("format") or "") or _PUBLICATION_TYPES.get(
        series.get("publication_type") or ""
    )

split_issue_number(raw) ¶

Split VerseDB’s “1 [10]” into the issue’s number and its other number.

Seen on G.I. Joe (Ziff-Davis, 1951), recorded 2026-11-21: its first five issues read “1 [10]” to “5 [14]”, and the numbers before the brackets then run on, 6 to 51, through issues of their own numbered 10 to 14. So the number before the bracket is the series’ running number, and the bracket is a second number the same issue carries, which comicbox keeps as its alternative issue number, as Metron’s alt_number is kept.

Source code in comicbox/formats/versedb_api/transform.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
def split_issue_number(raw: Any) -> tuple[str, str | None]:
    """
    Split VerseDB's "1 [10]" into the issue's number and its other number.

    Seen on G.I. Joe (Ziff-Davis, 1951), recorded 2026-11-21: its first five
    issues read "1 [10]" to "5 [14]", and the numbers before the brackets
    then run on, 6 to 51, through issues of their own numbered 10 to 14. So
    the number before the bracket is the series' running number, and the
    bracket is a second number the same issue carries, which comicbox keeps
    as its alternative issue number, as Metron's ``alt_number`` is kept.
    """
    text = str(raw or "").strip()
    if match := _DUAL_NUMBER_RE.match(text):
        return match.group("number").strip(), match.group("alt").strip() or None
    return text, None