Can't get compression in Python zip script.
Scott David Daniels
Scott.Daniels at Acm.Org
Mon May 2 18:08:41 EDT 2005
Fredrik Lundh wrote:
> M.E.Farmer wrote:
>
>>I saw compression=0 and assumed that 1 would mean true, but no!
>>zipfile.ZIP_DEFLATED = 8, defies logic, it is the only compression type
>>why not accept any non zero as compression.
>
> "is the only compression type" ? quoting from the ZIP specification:
>
> compression method: (2 bytes)
> (see accompanying documentation for algorithm descriptions)
> 0 - The file is stored (no compression)
> 1 - The file is Shrunk
...
> 8 - The file is Deflated
> 9 - Enhanced Deflating using Deflate64(tm)
> 10 - PKWARE Data Compression Library Imploding
> 11 - Reserved by PKWARE
> 12 - File is compressed using BZIP2 algorithm
> ( http://www.pkware.com/company/standards/appnote/appnote.txt )
> the current zipfile version only supports 0 and 8, but that doesn't mean that
> future versions won't support other ZIP compressions.
>
For example, I am hoping I'll get method 12 into Python 2.5. Please
don't use the unadorned numbers, however. Use zipfile.ZIP_STORE,
zipfile.ZIP_DEFLATED, and (later) zipfile.ZIP_BZIP2. This way you can
catch an exception when using an unimplemented compression format as
you retrieve the compression code, rather than waiting to get into the
midst of compression / decompression before getting a failure.
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list