[Patches] [ python-Patches-503592 ] Add method readfile() to class ZipFile
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 16 Jan 2002 03:44:18 -0800
Patches item #503592, was opened at 2002-01-14 15:04
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=503592&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Branko Cibej (brane)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add method readfile() to class ZipFile
Initial Comment:
The ZipFile class doesn't provide a method to read
bytes from the
archive directly to a disk-based file. That's
unfortunate, because
reading large files from a zip file using the read()
method will burn
about twice the file size amount of RAM. This patch
adds a readfile()
method that reads small chunks of the archived file and
writes them
directly to disk.
Changes to class ZipFile (src/Lib/zipfile.py):
- New attribute _chunk_size: readfile() and write() use
this to
calculate the read/write buffer sizes.
- New method _readcheck: Like _writecheck, but used for
error checking
before reading from the archive.
- Changes to read(): Factor out error checking and call
_readcheck().
- Changes to write(): Use self._chunk_size as the read
size instead
of a hard-coded value.
- New method readfile().
Changes to the docs (src/Doc/lib/libzipfile.tex):
- Document ZipFile.readfile().
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-01-16 03:44
Message:
Logged In: YES
user_id=21627
I'd rather prefer a different solution: create a .open()
method on ZipFile opjects, which return file-like objects.
With that, you can shutils.copyfileobj to achive what you want.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=503592&group_id=5470