parameters: (self, file, mode="r", compression=ZIP_STORED, allowZip64=False)
docstring: Open the ZIP file with mode read "r", write "w" or append "a".
docstring_summary: Open the ZIP file with mode read "r", write "w" or append "a".
docstring_tokens: Open the ZIP file with mode read r write w or append a .
function: def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=False):
          """Open the ZIP file with mode read "r", write "w" or append "a"."""
          if mode not in ("r", "w", "a"):
              raise RuntimeError('ZipFile() requires mode "r", "w", or "a"')
  
          if compression == ZIP_STORED:
              pass
          elif compression == ZIP_DEFLATED:
              if not zlib:
                  raise RuntimeError,\
                        "Compression requires the (missing) zlib module"
          else:
              raise RuntimeError, "That compression method is not supported"
  
          self._allowZip64 = allowZip64
          self._didModify = False
          self.debug = 0  # Level of printing: 0 through 3
          self.NameToInfo = {}    # Find file info given name
          self.filelist = []      # List of ZipInfo instances for archive
          self.compression = compression  # Method of compression
          self.mode = key = mode.replace('b', '')[0]
          self.pwd = None
          self._comment = ''
  
          # Check if we were passed a file-like object
          if isinstance(file, basestring):
              self._filePassed = 0
              self.filename = file
              modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'}
              try:
                  self.fp = open(file, modeDict[mode])
              except IOError:
                  if mode == 'a':
                      mode = key = 'w'
                      self.fp = open(file, modeDict[mode])
                  else:
                      raise
          else:
              self._filePassed = 1
              self.fp = file
              self.filename = getattr(file, 'name', None)
  
          try:
              if key == 'r':
                  self._RealGetContents()
              elif key == 'w':
                  # set the modified flag so central directory gets written
                  # even if no files are added to the archive
                  self._didModify = True
                  self._start_disk = self.fp.tell()
              elif key == 'a':
                  try:
                      # See if file is a zip file
                      self._RealGetContents()
                      # seek to start of directory and overwrite
                      self.fp.seek(self.start_dir, 0)
                  except BadZipfile:
                      # file is not a zip file, just append
                      self.fp.seek(0, 2)
  
                      # set the modified flag so central directory gets written
                      # even if no files are added to the archive
                      self._didModify = True
                      self._start_disk = self.fp.tell()
              else:
                  raise RuntimeError('Mode must be "r", "w" or "a"')
          except:
              fp = self.fp
              self.fp = None
              if not self._filePassed:
                  fp.close()
              raise
function_tokens: def __init__ ( self , file , mode = "r" , compression = ZIP_STORED , allowZip64 = False ) : if mode not in ( "r" , "w" , "a" ) : raise RuntimeError ( 'ZipFile() requires mode "r", "w", or "a"' ) if compression == ZIP_STORED : pass elif compression == ZIP_DEFLATED : if not zlib : raise RuntimeError , "Compression requires the (missing) zlib module" else : raise RuntimeError , "That compression method is not supported" self . _allowZip64 = allowZip64 self . _didModify = False self . debug = 0 # Level of printing: 0 through 3 self . NameToInfo = { } # Find file info given name self . filelist = [ ] # List of ZipInfo instances for archive self . compression = compression # Method of compression self . mode = key = mode . replace ( 'b' , '' ) [ 0 ] self . pwd = None self . _comment = '' # Check if we were passed a file-like object if isinstance ( file , basestring ) : self . _filePassed = 0 self . filename = file modeDict = { 'r' : 'rb' , 'w' : 'wb' , 'a' : 'r+b' } try : self . fp = open ( file , modeDict [ mode ] ) except IOError : if mode == 'a' : mode = key = 'w' self . fp = open ( file , modeDict [ mode ] ) else : raise else : self . _filePassed = 1 self . fp = file self . filename = getattr ( file , 'name' , None ) try : if key == 'r' : self . _RealGetContents ( ) elif key == 'w' : # set the modified flag so central directory gets written # even if no files are added to the archive self . _didModify = True self . _start_disk = self . fp . tell ( ) elif key == 'a' : try : # See if file is a zip file self . _RealGetContents ( ) # seek to start of directory and overwrite self . fp . seek ( self . start_dir , 0 ) except BadZipfile : # file is not a zip file, just append self . fp . seek ( 0 , 2 ) # set the modified flag so central directory gets written # even if no files are added to the archive self . _didModify = True self . _start_disk = self . fp . tell ( ) else : raise RuntimeError ( 'Mode must be "r", "w" or "a"' ) except : fp = self . fp self . fp = None if not self . _filePassed : fp . close ( ) raise