zipfile
index
/usr/lib/python2.2/zipfile.py

Read and write ZIP files.

 
Modules
            
binascii
os
struct
time
types
zlib
 
Classes
            
exceptions.Exception
BadZipfile
BadZipfile
ZipFile
PyZipFile
ZipInfo
 
class BadZipfile(exceptions.Exception)
       
   Data and non-method functions defined here:
__doc__ = None
__module__ = 'zipfile'

Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)
 
class PyZipFile(ZipFile)
      Class to create ZIP archives with Python library files and packages.
 
   Methods defined here:
_get_codename(self, pathname, basename)
Return (filename, archivename) for the path.
 
Given a module name path, return the correct file path and
archive name, compiling if necessary.  For example, given
/python/lib/string, return (/python/lib/string.pyc, string).
writepy(self, pathname, basename='')
Add all files from "pathname" to the ZIP archive.
 
If pathname is a package directory, search the directory and
all package subdirectories recursively for all *.py and enter
the modules into the archive.  If pathname is a plain
directory, listdir *.py and enter all modules.  Else, pathname
must be a Python *.py file and the module will be put into the
archive.  Added modules are always module.pyo or module.pyc.
This method will compile the module.py into module.pyc if
necessary.

Data and non-method functions defined here:
__doc__ = 'Class to create ZIP archives with Python library files and packages.'
__module__ = 'zipfile'

Methods inherited from ZipFile:
_GetContents(self)
Read the directory, making sure we close the file if the format
is bad.
_RealGetContents(self)
Read in the table of contents for the ZIP file.
__del__(self)
Call the "close()" method in case the user forgot.
__init__(self, file, mode='r', compression=0)
Open the ZIP file with mode read "r", write "w" or append "a".
_writecheck(self, zinfo)
Check for errors before writing a file to the archive.
close(self)
Close the file, and for mode "w" and "a" write the ending
records.
getinfo(self, name)
Return the instance of ZipInfo given 'name'.
infolist(self)
Return a list of class ZipInfo instances for files in the
archive.
namelist(self)
Return a list of file names in the archive.
printdir(self)
Print a table of contents for the zip file.
read(self, name)
Return file bytes (as a string) for name.
testzip(self)
Read all the files and check the CRC.
write(self, filename, arcname=None, compress_type=None)
Put the bytes from filename into the archive under the name
arcname.
writestr(self, zinfo, bytes)
Write a file into the archive.  The contents is the string
'bytes'.

Data and non-method functions inherited from ZipFile:
fp = None
 
class ZipFile
       Class with methods to open, read, write, close, list zip files.
 
z = ZipFile(file, mode="r", compression=ZIP_STORED)
 
/get.cgi/ 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).
 
   Methods defined here:
_GetContents(self)
Read the directory, making sure we close the file if the format
is bad.
_RealGetContents(self)
Read in the table of contents for the ZIP file.
__del__(self)
Call the "close()" method in case the user forgot.
__init__(self, file, mode='r', compression=0)
Open the ZIP file with mode read "r", write "w" or append "a".
_writecheck(self, zinfo)
Check for errors before writing a file to the archive.
close(self)
Close the file, and for mode "w" and "a" write the ending
records.
getinfo(self, name)
Return the instance of ZipInfo given 'name'.
infolist(self)
Return a list of class ZipInfo instances for files in the
archive.
namelist(self)
Return a list of file names in the archive.
printdir(self)
Print a table of contents for the zip file.
read(self, name)
Return file bytes (as a string) for name.
testzip(self)
Read all the files and check the CRC.
write(self, filename, arcname=None, compress_type=None)
Put the bytes from filename into the archive under the name
arcname.
writestr(self, zinfo, bytes)
Write a file into the archive.  The contents is the string
'bytes'.

Data and non-method functions defined here:
__doc__ = ' Class with methods to open, read, write, close...pression) or ZIP_DEFLATED (requires zlib).\n '
__module__ = 'zipfile'
fp = None
 
class ZipInfo
      Class with attributes describing each file in the ZIP archive.
 
   Methods defined here:
FileHeader(self)
Return the per-file header as a string.
__init__(self, filename='NoName', date_time=(1980, 1, 1, 0, 0, 0))

Data and non-method functions defined here:
__doc__ = 'Class with attributes describing each file in the ZIP archive.'
__module__ = 'zipfile'
 
error = class BadZipfile(exceptions.Exception)
       
   Data and non-method functions defined here:
__doc__ = None
__module__ = 'zipfile'

Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)
 
Functions
            
_normpath(path)
is_zipfile(filename)
Quickly see if file is a ZIP file by checking the magic number.
 
Will not accept a ZIP archive with an ending comment.
 
Data
             ZIP_DEFLATED = 8
ZIP_STORED = 0
_CD_COMMENT_LENGTH = 14
_CD_COMPRESSED_SIZE = 10
_CD_COMPRESS_TYPE = 6
_CD_CRC = 9
_CD_CREATE_SYSTEM = 2
_CD_CREATE_VERSION = 1
_CD_DATE = 8
_CD_DISK_NUMBER_START = 15
_CD_EXTERNAL_FILE_ATTRIBUTES = 17
_CD_EXTRACT_SYSTEM = 4
_CD_EXTRACT_VERSION = 3
_CD_EXTRA_FIELD_LENGTH = 13
_CD_FILENAME_LENGTH = 12
_CD_FLAG_BITS = 5
_CD_INTERNAL_FILE_ATTRIBUTES = 16
_CD_LOCAL_HEADER_OFFSET = 18
_CD_SIGNATURE = 0
_CD_TIME = 7
_CD_UNCOMPRESSED_SIZE = 11
_FH_COMPRESSED_SIZE = 8
_FH_COMPRESSION_METHOD = 4
_FH_CRC = 7
_FH_EXTRACT_SYSTEM = 2
_FH_EXTRACT_VERSION = 1
_FH_EXTRA_FIELD_LENGTH = 11
_FH_FILENAME_LENGTH = 10
_FH_GENERAL_PURPOSE_FLAG_BITS = 3
_FH_LAST_MOD_DATE = 6
_FH_LAST_MOD_TIME = 5
_FH_SIGNATURE = 0
_FH_UNCOMPRESSED_SIZE = 9
_STRING_TYPES = (<type 'str'>, <type 'unicode'>)
__all__ = ['BadZipfile', 'error', 'ZIP_STORED', 'ZIP_DEFLATED', 'is_zipfile', 'ZipInfo', 'ZipFile', 'PyZipFile']
__file__ = '/usr/lib/python2.2/zipfile.pyc'
__name__ = 'zipfile'
stringCentralDir = 'PK\x01\x02'
stringEndArchive = 'PK\x05\x06'
stringFileHeader = 'PK\x03\x04'
structCentralDir = '<4s4B4H3l5H2l'
structEndArchive = '<4s4H2lH'
structFileHeader = '<4s2B4H3l2H'