You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
ronaldoussoren commentedon May 12, 2009
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.
pitrou commentedon May 12, 2009
This sounds like a good idea. Can you provide a patch (including tests)?
ronaldoussoren commentedon May 12, 2009
I will.
I guess it's too late to merge this into 3.1 (as the first beta has
already been released).
pitrou commentedon May 12, 2009
Since the change should be small and uncontroversial, I think it could
go in.
Benjamin has the final word.
ronaldoussoren commentedon May 19, 2009
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.
ronaldoussoren commentedon May 19, 2009
Argh... The patch includes an update to configure.in, please ignore that
bit.
pitrou commentedon May 27, 2009
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.
ronaldoussoren commentedon Feb 7, 2010
Committed in r78097 (trunk) and r78098 (3.2). This includes the documentation change suggested in msg88437