fs.compress¶
This module can compress the contents of a filesystem.
Currently zip and tar are supported.
-
fs.compress.
write_tar
(src_fs, file, compression=None, encoding=u'utf-8', walker=None)¶ Write the contents of a filesystem to a tar file.
Parameters: - file (str or file-like.) – Destination file, may be a file name or an open file object.
- compression (str) – Compression to use.
- encoding (str) – The encoding to use for filenames. The default is
"utf-8"
. - walker (Walker or None) – A
Walker
instance, or None to use default walker. You can use this to specify which files you want to compress.
-
fs.compress.
write_zip
(src_fs, file, compression=8, encoding=u'utf-8', walker=None)¶ Write the contents of a filesystem to a zip file.
Parameters: - file (str or file-like.) – Destination file, may be a file name or an open file object.
- compression (str) – Compression to use (one of the constants defined in the zipfile module in the stdlib).
- encoding (str) – The encoding to use for filenames. The default is
"utf-8"
, use"CP437"
if compatibility with WinZip is desired. - walker (Walker or None) – A
Walker
instance, or None to use default walker. You can use this to specify which files you want to compress.