comicbox.formats.base.transforms.xml_reprints

[docs] module comicbox.formats.base.transforms.xml_reprints

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Reprint sorting."""

from bidict import frozenbidict

from comicbox.formats.base.transforms.spec import (
    MetaSpec,
    create_specs_from_comicbox,
    create_specs_to_comicbox,
)
from comicbox.formats.comicbox.schema import (
    ISSUE_KEY,
    NAME_KEY,
    SERIES_KEY,
    VOLUME_ISSUE_COUNT_KEY,
    VOLUME_KEY,
    VOLUME_NUMBER_KEY,
)
from comicbox.formats.filename.schema import (
    ISSUE_COUNT_TAG,
    ISSUE_TAG,
    SERIES_TAG,
    VOLUME_TAG,
)

REPRINTS_TO_FILENAME_KEY_MAP = frozenbidict(
    {
        SERIES_TAG: f"{SERIES_KEY}.{NAME_KEY}",
        VOLUME_TAG: f"{VOLUME_KEY}.{VOLUME_NUMBER_KEY}",
        ISSUE_COUNT_TAG: f"{VOLUME_KEY}.{VOLUME_ISSUE_COUNT_KEY}",
        ISSUE_TAG: f"{ISSUE_KEY}",
    }
)
FILENAME_TO_REPRINT_SPECS = create_specs_to_comicbox(
    MetaSpec(key_map=REPRINTS_TO_FILENAME_KEY_MAP.inverse, inherit_root_keypath=False)
)
REPRINT_TO_FILENAME_SPECS = create_specs_from_comicbox(
    MetaSpec(key_map=REPRINTS_TO_FILENAME_KEY_MAP, inherit_root_keypath=False)
)