Repository navigation
Changes
🐛 Bug Fixes
- Fix XML element errors pyright reports in the metadata handlers @bpepple (#282)
- Fix annotation errors pyright reports in the metadata classes @bpepple (#281)
- Return empty lists instead of None for missing list fields @bpepple (#279)
- Don't modify the caller's Metadata in write_metadata() @bpepple (#278)
- Remove the stale case-variant metadata copy a write replaces @bpepple (#277)
- Fill in ComicInfo page ImageSize when Pillow is missing @bpepple (#276)
- Drop stale MetronInfo dates when a pre-1900 date is skipped @bpepple (#275)
- Narrow Comic's exception handling and close archiver read-error gaps @bpepple (#273)
- Fix overlay, page list cache, metadata filename and Pillow warning bugs @bpepple (#271)
- Cache parsed metadata per format in Comic @bpepple (#270)
- Add strict mode to Comic.read_metadata() for unreadable metadata @bpepple (#269)
🧰 Maintenance
- Run pyright in make lint @bpepple (#284)
- Fix the remaining pyright errors in the archivers, comic and validate @bpepple (#283)
- Remove unused constants and vulture's archiver.py exclusion @bpepple (#280)
- Remove duplicated constants, dead code and copied element setters @bpepple (#274)
- Refactor metadata format handling and unify archiver caching and errors @bpepple (#272)
⚠️ Migrating from 9.x
Most code that only uses Comic won't need changes. Check the items below if you rely on write_metadata() changing your Metadata object, catch exceptions from Comic, or use the archiver classes directly.
Comic
-
write_metadata()no longer modifies yourMetadataobject (#278). It used to fill inpage_countand each page'sImageSize/ImageWidth/ImageHeight, and turn pageImageindexes into strings. The written file still has those values. If you need them, read the metadata back:comic.write_metadata(metadata, MetadataFormat.COMIC_INFO) written = comic.read_metadata(MetadataFormat.COMIC_INFO) written.page_count, written.pages[0]["ImageSize"]
-
write_metadata()raises on malformedMetadata(#273). A field holding the wrong type (for example,metadata.series = "Batman"instead of aSeries) raisesTypeErrororAttributeErrorinstead of returningFalse. Archive, I/O and invalid-value errors still returnFalse. -
Unexpected errors are no longer swallowed (#273).
Comicused to catch everyException. It now catches onlyArchiverError,OSErrorand the documented parsing errors, so bugs in your code or in a custom archiver propagate instead of being logged. -
remove_metadata()returnsFalsefor an unreadable archive instead ofTrue, and now removes metadata from archives that have no pages (#273). -
Metadata in subfolders is ignored (#271). Only
ComicInfo.xml/MetronInfo.xmlat the archive root count, matched case-insensitively.has_metadata()no longer reports a file such asIssue1/ComicInfo.xml, which could never be read anyway. -
Writing replaces a case-variant metadata file (#277). If an archive only has
comicinfo.xml, a write createsComicInfo.xmlwith its contents and removescomicinfo.xml. -
New:
read_metadata(fmt, strict=True)raisesComicMetadataErrorwhen a metadata file exists but can't be read or parsed (#269). The default is unchanged. If you opened a secondComicto read the other metadata format, you can drop that workaround: each format is now cached separately (#270).
Metadata classes
- Missing list fields read as
[], notNone(#279). A ComicInfo without<Title>,<Genre>,<Characters>,<Teams>,<Locations>or<StoryArc>, and a MetronInfo without<Credits>, used to set that field toNone. Replace checks such asmd.genres is Noneormd.credits is Nonewithnot md.genres. SeriesandPublisherno longer subclassBasic(#281).isinstance(series, Basic)andisinstance(publisher, Basic)now returnFalse. Their fields, field order and behaviour are unchanged. Theirnameis now typedstr | None, matching what a ComicInfo without<Series>or<Publisher>already produced, andCredit.id_is typedint | str | None, likeBasic.id_.
Archivers (only if you use them directly)
get_filename_list()raisesArchiverReadErroron failure on every backend (#272). A corrupt Zip, Tar or 7z archive used to list as[]. A missing Rar or Pdf file now lists as[]instead of raising, the same as the others.write_file()returnsFalseon failure on every backend (#272).TarArchiverandSevenZipArchiverused to raiseArchiverWriteError/ArchiverReadError.ArchiverWriteErroris still exported, but no built-in archiver raises it.RarArchiver.read_file()andZipArchiver.read_file()raiseArchiverReadError(#273) for encrypted, damaged, multi-volume or unsupported members instead of the rawrarfile/zipfileexception. The original is kept as__cause__.- Custom archivers should implement
_list_files()instead ofget_filename_list()(#272). The base class now caches the listing. An archiver that still overridesget_filename_list()keeps working. Call the newinvalidate_cache()if the file may have changed outside the archiver. PdfArchiver.PAGE_DPIis144, not150(#274). Rendering hasn't changed; the constant now matches it.
Removed
These were never exported or documented: