Return an empty object if an archive does not have the requested style

This commit is contained in:
Timmy Welch 2023-12-18 16:56:54 -08:00
parent df781f67e3
commit c3a8221d99
2 changed files with 5 additions and 4 deletions

View File

@ -167,8 +167,10 @@ class ComicArchive:
def read_metadata(self, style: str) -> GenericMetadata:
if style in self.md:
return self.md[style]
md = metadata_styles[style].get_metadata(self.archiver)
md.apply_default_page_list(self.get_page_name_list())
md = GenericMetadata()
if metadata_styles[style].has_metadata(self.archiver):
md = metadata_styles[style].get_metadata(self.archiver)
md.apply_default_page_list(self.get_page_name_list())
return md
def read_metadata_string(self, style: str) -> str:

View File

@ -85,9 +85,8 @@ def test_delete(
# Read the CBZ
md = tmp_comic.read_metadata("cr")
# Currently we set the default page list on load
# The default page list is set on load if the comic has the requested metadata style
empty_md = comicapi.genericmetadata.GenericMetadata()
empty_md.apply_default_page_list(tmp_comic.get_page_name_list())
# Validate that we got an empty metadata back
assert md == empty_md