Slim, always-loaded overview. For the full algorithm, byte offsets, and module contract, read docs/CLAUDE.full.md. For goals and status, read project-plan.md.
pinch retrieves a single file from inside a remote ZIP archive using HTTP
Range requests — without downloading the whole archive. A Python port of
flutter_pinch. Zero runtime
dependencies (stdlib urllib + zlib + struct).
src/pinch/— the librarystructures.py— ZIP binary parsers (EOCD, Central Directory, Local File Header)zip_entry.py—ZipEntrydataclass +find_by_pathhttp.py—RangeGET/HEAD helper overurllib; definesPinchErrorpinch.py—Pinchservice:fetch_directory(),fetch_file()
src/pinch_example/__main__.py— CLI demo (python -m pinch_example)tests/—pytest, ZIPs built with stdlibzipfile, served over a local HTTP server
from pinch import Pinch, ZipEntry, PinchError, find_by_path
pinch = Pinch()
entries = pinch.fetch_directory(url) # list[ZipEntry], directories filtered out
entry = find_by_path(entries, "a/b.txt")
result = pinch.fetch_file(entry) # ZipEntry with .data set (bytes)
pinch.bytes_transferred # int, for demonstrating savingspip install -e ".[test]"
pytest
python -m pinch_example <zip-url> [path-in-zip] [-o out]- Stdlib only — do not add runtime dependencies.
- All ZIP integers are little-endian (
structformat strings start with<). - Network/format failures surface as
PinchError.