Release v3.3.0

This commit is contained in:
hyugogirubato
2024-07-14 18:57:07 +02:00
parent 9902a7872d
commit 6a3f1fefbb
21 changed files with 1349 additions and 1193 deletions
+74 -67
View File
@@ -1,7 +1,17 @@
from enum import Enum
from typing import Union
from langcodes import Language
xml_name = 'ComicInfo.xml'
XML_NAME = 'ComicInfo.xml'
IMAGE_FORMAT = {
'.jpeg', ' .jpg', # Joint Photographic Experts Group
'.png', # Portable Network Graphics
'.gif', # Graphics Interchange Format
'.bmp', # Bitmap Image File
'.tiff', '.tif', # Tagged Image File Format
'.webp' # Web Picture Format
}
class YesNo(Enum):
@@ -103,74 +113,71 @@ class Format(Enum):
YEAR_ONE = 'Year One'
class ValidRating(float):
def __init__(self, val):
assert -1 <= float(val) <= 5, f'Rating must be between 0 and 5, input {val}'
super(ValidRating, self).__init__()
class Rating(float):
def __new__(cls, value: Union[int, float] = -1) -> float:
assert -1 <= float(value) <= 5, f'Rating must be between 0 and 5, input {value}'
return super().__new__(cls, value)
class ValidLanguage(str):
def __init__(self, val):
if val and not Language.get(str(val)).is_valid():
raise ValueError(f'Invalid {val} language')
super(ValidLanguage, self).__init__()
class LanguageISO(str):
def __new__(cls, value: str = '') -> str:
assert not value or Language.get(str(value)).is_valid(), f'Invalid {value} language'
return super().__new__(cls, value)
FIELDS = (
# model: (key, xml key): (variable name, (expected type, second expected type,...))
# in case of multiple expected formats, value cast to first type in tuple
(('title', 'Title'), ('title', (str,))),
(('series', 'Series'), ('series', (str,))),
(('number', 'Number'), ('number', (str, int, float))),
(('count', 'Count'), ('count', (int,))),
(('volume', 'Volume'), ('volume', (int,))),
(('alternate_series', 'AlternateSeries'), ('alternate_series', (str,))),
(('alternate_number', 'AlternateNumber'), ('alternate_number', (str, int, float))),
(('alternate_count', 'AlternateCount'), ('alternate_count', (int,))),
(('summary', 'Summary'), ('summary', (str,))),
(('notes', 'Notes'), ('notes', (str,))),
(('year', 'Year'), ('year', (int,))),
(('month', 'Month'), ('month', (int,))),
(('day', 'Day'), ('day', (int,))),
(('writer', 'Writer'), ('writer', (str,))),
(('penciller', 'Penciller'), ('penciller', (str,))),
(('inker', 'Inker'), ('inker', (str,))),
(('colorist', 'Colorist'), ('colorist', (str,))),
(('letterer', 'Letterer'), ('letterer', (str,))),
(('cover_artist', 'CoverArtist'), ('cover_artist', (str,))),
(('editor', 'Editor'), ('editor', (str,))),
(('translator', 'Translator'), ('translator', (str,))),
(('publisher', 'Publisher'), ('publisher', (str,))),
(('imprint', 'Imprint'), ('imprint', (str,))),
(('genre', 'Genre'), ('genre', (str,))),
(('tags', 'Tags'), ('tags', (str,))),
(('web', 'Web'), ('web', (str,))),
(('format', 'Format'), ('format', (Format, str))),
(('ean', 'EAN'), ('ean', (str,))),
(('black_white', 'BlackAndWhite'), ('black_white', (YesNo, str))),
(('manga', 'Manga'), ('manga', (Manga, str))),
(('characters', 'Characters'), ('characters', (str,))),
(('teams', 'Teams'), ('teams', (str,))),
(('locations', 'Locations'), ('locations', (str,))),
(('scan_information', 'ScanInformation'), ('scan_information', (str,))),
(('story_arc', 'StoryArc'), ('story_arc', (str,))),
(('story_arc_number', 'StoryArcNumber'), ('story_arc_number', (str,))),
(('series_group', 'SeriesGroup'), ('series_group', (str,))),
(('age_rating', 'AgeRating'), ('age_rating', (AgeRating, str))),
(('main_character_or_team', 'MainCharacterOrTeam'), ('main_character_or_team', (str,))),
(('review', 'Review'), ('review', (str,))),
(('language_iso', 'LanguageISO'), ('language_iso', (ValidLanguage, str))),
(('community_rating', 'CommunityRating'), ('community_rating', (ValidRating, float, int, str))),
)
COMIC_FIELDS = {
'title': ('Title', str),
'series': ('Series', str),
'number': ('Number', int),
'count': ('Count', int),
'volume': ('Volume', int),
'alternate_series': ('AlternateSeries', str),
'alternate_number': ('AlternateNumber', int),
'alternate_count': ('AlternateCount', int),
'summary': ('Summary', str),
'notes': ('Notes', str),
'year': ('Year', int),
'month': ('Month', int),
'day': ('Day', int),
'writer': ('Writer', str),
'penciller': ('Penciller', str),
'inker': ('Inker', str),
'colorist': ('Colorist', str),
'letterer': ('Letterer', str),
'cover_artist': ('CoverArtist', str),
'editor': ('Editor', str),
'translator': ('Translator', str),
'publisher': ('Publisher', str),
'imprint': ('Imprint', str),
'genre': ('Genre', str),
'tags': ('Tags', str),
'web': ('Web', str),
'format': ('Format', Format),
'ean': ('EAN', str),
'black_white': ('BlackAndWhite', YesNo),
'manga': ('Manga', Manga),
'characters': ('Characters', str),
'teams': ('Teams', str),
'locations': ('Locations', str),
'scan_information': ('ScanInformation', str),
'story_arc': ('StoryArc', str),
'story_arc_number': ('StoryArcNumber', int),
'series_group': ('SeriesGroup', str),
'age_rating': ('AgeRating', AgeRating),
'main_character_or_team': ('MainCharacterOrTeam', str),
'review': ('Review', str),
'language_iso': ('LanguageISO', LanguageISO),
'community_rating': ('CommunityRating', Rating)
}
PAGE_FIELDS = (
# model: (key, xml key): (variable name, (expected type, second expected type,...))
# in case of multiple expected formats, value cast to first type in tuple
(('type', 'Type'), ('type', (PageType, str))),
(('double', 'DoublePage'), ('double', (bool,))),
(('key', 'Key'), ('key', (str,))),
(('bookmark', 'Bookmark'), ('bookmark', (str,))),
(('image_size', 'ImageSize'), ('_image_size', (int,))),
(('image_width', 'ImageWidth'), ('_image_width', (int,))),
(('image_height', 'ImageHeight'), ('_image_height', (int,))),
)
PAGE_FIELDS = {
'type': ('Type', PageType),
'double': ('DoublePage', bool),
'key': ('Key', str),
'bookmark': ('Bookmark', str),
'image_size': ('ImageSize', int),
'image_width': ('ImageWidth', int),
'image_height': ('ImageHeight', int)
}