Bases: ComicboxComputedDate
Computed Stories and Title Methods.
Source code in comicbox/box/computed/stories_title.py
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
39
40
41
42
43
44
45
46
47 | class ComicboxComputedStoriesTitle(ComicboxComputedDate):
"""Computed Stories and Title Methods."""
def _get_computed_from_stories(
self, sub_data: dict[str, Any], **_kwargs: Any
) -> dict[str, str] | None:
"""Build a title out of the stories when the book has no title."""
if sub_data.get(TITLE_KEY):
# A title the source stated is the title. It used to be
# overwritten with the joined stories so Metron, which has no
# title tag, would beat a filename title β but which source wins
# is the merge order's job, not this one's.
return None
stories = sub_data.get(STORIES_KEY)
if not stories:
return None
title = _TITLE_STORIES_JOIN_DELIMITER.join(stories)
return {TITLE_KEY: title}
def _get_computed_from_title(
self, sub_data: dict[str, Any], **_kwargs: Any
) -> dict[str, dict] | None:
"""Read the stories out of a title when the book lists none."""
if sub_data.get(STORIES_KEY):
return None
title = sub_data.get(TITLE_KEY)
if not title:
return None
stories = {
story: {}
for story in (raw.strip() for raw in title.split(_TITLE_STORIES_DELIMITER))
if story
}
if not stories:
return None
return {STORIES_KEY: stories}
|