pyfilesystem icon indicating copy to clipboard operation
pyfilesystem copied to clipboard

Support setting compress_type on individual files in ZipFS.write()

Open mihailim opened this issue 9 years ago • 1 comments

ZipFS: Support writing files with individual compress_type instead of always using the default set at ZipFS() instance creation time.

All this patch does is pass through the additional, optional compress_type parameter supported by ZipFile.write() since at least Python 2.6 through to the write() invocation (see https://docs.python.org/2.6/library/zipfile.html#zipfile.ZipFile.write up to https://docs.python.org/3.5/library/zipfile.html#zipfile.ZipFile.write -- there are no additional compatibility restrictions compared to the status quo.)

compress_type defaults to None which is ZipFile.write()'s default as well, so nothing changes for library consumers unaware of this change. There are no performance implications I can think of.

Use case: Wanting to write files to a ZIP archive opened using mode="w", compression="deflate" using the ZIP_STORE method--e.g. incompressible files (or, in my case, the leading "mimetype" file that absolutely must be archived using ZIP_STORE in order to produce OCF-conformant EPUB files.)

mihailim avatar Feb 04 '16 18:02 mihailim

Hi!

It's been ten months at this point... Is there any interest in merging this (trivial) change?

mihailim avatar Dec 20 '16 01:12 mihailim