module filehelper.winzipfile

Inheritance diagram of pyquickhelper.filehelper.winzipfile

Short summary

module pyquickhelper.filehelper.winzipfile

Fix a bug: see https://bugs.python.org/issue6839.

source on GitHub

Classes

class

truncated documentation

WinZipFile

Overwrite method zipfile.ZipFile.open. Issue 6839 happens when …

Properties

property

truncated documentation

comment

The comment text associated with the ZIP file.

Methods

method

truncated documentation

open

Returns file-like object for ‘name’.

Documentation

Fix a bug: see https://bugs.python.org/issue6839.

source on GitHub

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

Bases: zipfile.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 exception BadZipFile 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.

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][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.

source on GitHub