Issue 6003: ZipFile.writestr "compression_type" argument (original) (raw)

Created on 2009-05-12 09:36 by ronaldoussoren, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
zipfile_writestr.patch ronaldoussoren,2009-05-19 20:14
Messages (8)
msg87610 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-05-12 09:36
Class zipfile.ZipFile has two methods for adding data to a zipfile: 'write' and 'writestr'. The former has a "compression_type" argument that can be used to specify the compression to be used. That latter doesn't have that argument. Could a "compression_type" argument be added to "writestr" as well? I regularly create zipfiles from scratch using the writestr method to add content and currently have to modify the 'compression' attribute of the zipfile object to control compression and that leads to ugly code. The other alternative is to use a ZipInfo object as the archive-name of the newly added file, but that leads to even uglier code.
msg87625 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-12 13:24
This sounds like a good idea. Can you provide a patch (including tests)?
msg87627 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-05-12 13:30
I will. I guess it's too late to merge this into 3.1 (as the first beta has already been released).
msg87629 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-12 13:33
> I guess it's too late to merge this into 3.1 (as the first beta has > already been released). Since the change should be small and uncontroversial, I think it could go in. Benjamin has the final word.
msg88096 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-05-19 20:14
The attached patch implements my proposal, including documentation and tests. I'm not 100% happy about the tests, they may be a bit too minimal.
msg88097 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-05-19 20:15
Argh... The patch includes an update to configure.in, please ignore that bit.
msg88437 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-27 19:53
The patch looks ok. It can certainly go in trunk, as for 3.1 it's up to Benjamin to decide. Note: the docs should state that the new argument appeared in 2.7.
msg99015 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-02-07 20:24
Committed in r78097 (trunk) and r78098 (3.2). This includes the documentation change suggested in
History
Date User Action Args
2022-04-11 14:56:48 admin set github: 50253
2010-02-07 20:24:58 ronaldoussoren set status: open -> closedresolution: fixedmessages: + stage: needs patch -> resolved
2009-05-27 19:53:21 pitrou set messages: +
2009-05-19 20:15:29 ronaldoussoren set messages: +
2009-05-19 20:14:25 ronaldoussoren set files: + zipfile_writestr.patchkeywords: + patchmessages: +
2009-05-12 13:33:22 pitrou set nosy: + benjamin.petersonmessages: +
2009-05-12 13:30:14 ronaldoussoren set messages: +
2009-05-12 13:24:27 pitrou set priority: normalnosy: + pitroumessages: + assignee: ronaldoussorencomponents: + Library (Lib)
2009-05-12 09:36:45 ronaldoussoren create