PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
288 stars 63 forks source link

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

Closed mihailim closed 7 months ago

mihailim commented 8 years ago

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 commented 7 years ago

Hi!

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