Module zipfile :: Class ZipFile
[hide private]
[frames] | no frames]

_ClassType ZipFile

Known Subclasses:

Class with methods to open, read, write, close, list zip files.

z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True)

file: Either the path to the file, or a file-like object.
      If it is a path, the file will be opened and closed by ZipFile.
mode: The mode can be either read "r", write "w" or append "a".
compression: ZIP_STORED (no compression) or ZIP_DEFLATED (requires zlib).
allowZip64: if True ZipFile will create files with ZIP64 extensions when
            needed, otherwise it will raise an exception when this would
            be necessary.

Instance Methods [hide private]
__init__(self, file, mode='r', compression=0, allowZip64=False)
Open the ZIP file with mode read "r", write "w" or append "a".
Read the directory, making sure we close the file if the format is bad.
Read in the table of contents for the ZIP file.
Return a list of file names in the archive.
Return a list of class ZipInfo instances for files in the archive.
Print a table of contents for the zip file.
Read all the files and check the CRC.
getinfo(self, name)
Return the instance of ZipInfo given 'name'.
read(self, name)
Return file bytes (as a string) for name.
_writecheck(self, zinfo)
Check for errors before writing a file to the archive.
write(self, filename, arcname=None, compress_type=None)
Put the bytes from filename into the archive under the name arcname.
writestr(self, zinfo_or_arcname, bytes)
Write a file into the archive.
Call the "close()" method in case the user forgot.
Close the file, and for mode "w" and "a" write the ending records.
Class Variables [hide private]
  fp = None
Method Details [hide private]

writestr(self, zinfo_or_arcname, bytes)


Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.