module filehelper.winzipfile

Inheritance diagram of pyquickhelper.filehelper.winzipfile

Short summary

module pyquickhelper.filehelper.winzipfile

Fix a bug: see

source on GitHub



truncated documentation


Overwrite method Issue 6839 happens when …



truncated documentation


The comment text associated with the ZIP file.



truncated documentation


Returns file-like object for ‘name’.


Fix a bug: see

source on GitHub

class pyquickhelper.filehelper.winzipfile.WinZipFile(file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True)[source]

Bases: ZipFile

Overwrite method

Issue 6839 happens when a zip file is created on Windows. The created zip may contain full path with \ when the file list only contains /. This raises exception BadZipFile with the following message: File name in directory … and header … differ due to a mismatch between backslashes. This owerwrite method to fix the line which checks that names are consistent in the file list and in the compressed content.

source on GitHub

Open the ZIP file with mode read ‘r’, write ‘w’, exclusive create ‘x’, or append ‘a’.

open(name, mode='r', pwd=None, *, force_zip64=False)[source]

Returns file-like object for ‘name’.

  • name – is a string for the file name within the ZIP file, or a ZipInfo object.

  • mode – should be ‘r’ to read a file already in the ZIP file, or ‘w’ to write to a file newly added to the archive.

  • pwd – is the password to decrypt files (only used for reading).

When writing, if the file size is not known in advance but may exceed 2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large files. If the size is known in advance, it is best to pass a ZipInfo instance for name, with zinfo.file_size set.

source on GitHub