classification
Title: ZipFile.writestr "compression_type" argument
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: benjamin.peterson, pitrou, ronaldoussoren
Priority: normal Keywords: patch

Created on 2009-05-12 09:36 by ronaldoussoren, last changed 2010-02-07 20:24 by ronaldoussoren. 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 msg88437
History
Date User Action Args
2010-02-07 20:24:58ronaldoussorensetstatus: open -> closed
resolution: fixed
messages: + msg99015

stage: needs patch -> resolved
2009-05-27 19:53:21pitrousetmessages: + msg88437
2009-05-19 20:15:29ronaldoussorensetmessages: + msg88097
2009-05-19 20:14:25ronaldoussorensetfiles: + zipfile_writestr.patch
keywords: + patch
messages: + msg88096
2009-05-12 13:33:22pitrousetnosy: + benjamin.peterson
messages: + msg87629
2009-05-12 13:30:14ronaldoussorensetmessages: + msg87627
2009-05-12 13:24:27pitrousetpriority: normal

nosy: + pitrou
messages: + msg87625

assignee: ronaldoussoren
components: + Library (Lib)
2009-05-12 09:36:45ronaldoussorencreate