comicbox.readinglists.registry ¶
Reading-list format registry and content detection.
A registry of its own, apart from MetadataFormats: that enum’s order is the masking order for comic metadata and its keys are collision-checked against every comic format, where cbl, json and yaml are taken. Within reading lists those tokens are free.
ReadingListFormats ¶
Bases: Enum
Reading-list file formats.
Source code in comicbox/readinglists/registry.py
35 36 37 38 39 40 41 | |
as_text(data) ¶
Decode bytes, dropping a byte order mark.
Source code in comicbox/readinglists/registry.py
90 91 92 93 94 | |
detect_format(data) ¶
Detect a reading list’s format by its content, not its file name.
XML by its root element; JSON and YAML by their top-level keys. JSON is tried before YAML, since every JSON document is also YAML.
Source code in comicbox/readinglists/registry.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
get_format(fmt) ¶
Resolve a format token such as yaml, or pass a member through.
Source code in comicbox/readinglists/registry.py
62 63 64 65 66 67 68 69 70 | |
xml_root(text) ¶
Name an XML document’s first element, past its declaration and comments.
A scan, not one pattern: each part of the prolog is skipped by finding its end, so the time is linear in the text however it is built.
Source code in comicbox/readinglists/registry.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |