Package grizzled :: Package io :: Class Zip
[frames] | no frames]

Class Zip

zipfile.ZipFile --+
                  |
                 Zip

Zip extends the standard zipfile.ZipFile class and provides a method to extract the contents of a zip file into a directory. Adapted from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252508.
Instance Methods
 
__init__(self, file, mode="r", compression=zipfile.ZIP_STORED, allow_zip64=False)
Constructor.
 
extract(self, output_dir)
Unpack the zip file into the specified output directory.

Inherited from zipfile.ZipFile: __del__, close, getinfo, infolist, namelist, printdir, read, testzip, write, writestr

Class Variables

Inherited from zipfile.ZipFile: fp

Method Details

__init__(self, file, mode="r", compression=zipfile.ZIP_STORED, allow_zip64=False)
(Constructor)

 
Constructor. Initialize a new zip file.
Parameters:
  • file (str) - path to zip file
  • mode (str) - open mode. Valid values are 'r' (read), 'w' (write), and 'a' (append)
  • compression (int) - Compression type. Valid values: zipfile.ZIP_STORED`, ``zipfile.ZIP_DEFLATED
  • allow_zip64 (bool) - Whether or not Zip64 extensions are to be used
Overrides: zipfile.ZipFile.__init__

extract(self, output_dir)

 
Unpack the zip file into the specified output directory.
Parameters:
  • output_dir (str) - path to output directory. The directory is created if it doesn't already exist.