comicbox.predict ¶
Public prediction API: where a write would land, before anything is written.
write_metadata(dry_run=True) previews the payload and deliberately keeps reporting final_path=None; it says nothing about the destination. This module is the destination preview.
WriteDestination dataclass ¶
Where a write of one archive would land.
Source code in comicbox/predict.py
21 22 23 24 25 26 27 28 29 30 31 32 33 | |
predict_write_destination(path, *, base_config=None) ¶
Report where a write to path would land, and whether that path is taken.
The archive’s sniffed type decides, never its suffix: a RAR named X.cbz reports converts=False because its repack lands on its own name, and a zip named X.cbr is rewritten in place.
Opens nothing. Construction sniffs the archive type from the file’s leading bytes and stops there – no member listing, no decompression, no schema load – so this is cheap enough to run over a whole batch before any of it is written.
Raises whatever Comicbox construction raises and leaves the handling to the caller: FileNotFoundError and IsADirectoryError for a path that is not a readable file, and :class:comicbox.exceptions.UnsupportedArchiveTypeError for bytes that are no archive comicbox knows.
Pass a prebuilt base_config when predicting a batch. None rebuilds the config from files and environment on every call, which is fine for one file and wasteful for many.
Source code in comicbox/predict.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |