(path)
| 23 | |
| 24 | |
| 25 | def read_zip(path): |
| 26 | entries = {} |
| 27 | with zipfile.ZipFile(path) as archive: |
| 28 | for info in archive.infolist(): |
| 29 | if info.is_dir(): |
| 30 | continue |
| 31 | if info.compress_type != zipfile.ZIP_STORED: |
| 32 | raise ValueError( |
| 33 | f"{path}: {info.filename} uses unsupported compression " |
| 34 | f"method {info.compress_type}; expected ZIP_STORED" |
| 35 | ) |
| 36 | entries[info.filename] = { |
| 37 | "data": archive.read(info.filename), |
| 38 | "size": info.file_size, |
| 39 | } |
| 40 | return entries |
| 41 | |
| 42 | |
| 43 | def decode_text(name, data): |