-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the ZipFile Interface #35279
Comments
There exist two methods to write to a ZipFile write(self, filename, arcname=None, compress_type=None)
writestr(self, zinfo, bytes) but only one to read from it read(self, name) Additionally, the two 'write's behave differently with respect to compression. --- (b) It is confusing what 'write' and 'read' actually mean. Does 'write' write a file,
(c) BOTH, 'writestr' and 'add' should by default use the 'compress_type' that was |
Logged In: YES In Python 2.3, writestr() has an enhanced signature: the extract() could be moderately useful (although I don't |
Logged In: YES It would also be very useful to be able to have ZipFile I would like to use this module to work with zip files Currently, read() reads all of the compressed data into Likewise for write(), I would like to be able to stream data The implementation of this functionality is quite I, too, am a bit irked by the lack of symmetry exhibited by |
Logged In: YES The zipfile interface should match the tarfile interface. import zipfile
zip = zipfile.open("sample.zip", "r")
for zipinfo in zip:
print tarinfo.name, "is", tarinfo.size, "bytes in size
and is",
zip.extract(zipinfo)
zip.close() This closely matchs the 'tarfile' module. |
Logged In: YES I've been trying to read map files put out by the Census Note: I've never seen a TAR of TAR files because TAR *does* What I've been struggling with is a way to leave these What would be nice is if there already were objects |
Logged In: YES I am currently working on an expanded zipfile module that: What I don't have at the moment is a good set of tests --Scott David Daniels |
Logged In: YES Scott, I had put together some enhancements to ZipFile read/write, https://sourceforge.net/tracker/?func=detail&aid=1121142&group_id=5470&atid=305470 If it seems like it would be helpful, I can go round up the |
Alan's patch has since been committed. Is there any more work on this item? |
There was another issue that also asked for an extract feature, and if I |
I attached a patch with the following changes (as zipfile_extract.diff): (1) Add a note to the docs (under writestr) about how the compression is (2) Add an extract method to ZipFile and associated test/documentation |
Are the method renames/additions suggested in the original issue worth |
I committed your patch (after reviewing the docs) as r59834. I think |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: