module filehelper.winzipfile
¶
Short summary¶
module pyquickhelper.filehelper.winzipfile
Fix a bug: see https://bugs.python.org/issue6839.
Classes¶
class |
truncated documentation |
---|---|
Overwrite method zipfile.ZipFile.open. Issue 6839 happens when … |
Properties¶
property |
truncated documentation |
---|---|
|
The comment text associated with the ZIP file. |
Methods¶
method |
truncated documentation |
---|---|
Returns file-like object for ‘name’. |
Documentation¶
Fix a bug: see https://bugs.python.org/issue6839.
- class pyquickhelper.filehelper.winzipfile.WinZipFile(file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True)[source]¶
Bases:
ZipFile
Overwrite method zipfile.ZipFile.open.
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 exceptionBadZipFile
with the following message: File name in directory … and header … differ due to a mismatch between backslashes. This owerwrite method zipfile.ZipFile.open to fix the line which checks that names are consistent in the file list and in the compressed content.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’.
- Parameters:
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.