def unzipIter(filename, directory='.', overwrite=0):
 zf = zipfile.ZipFile(filename, 'r')
 names = zf.namelist()
 if (not os.path.exists(directory)):
  os.makedirs(directory)
 remaining = len(zf.namelist())
 for entry in names:
  remaining -= 1
  isdir = (zf.getinfo(entry).external_attr & DIR_BIT)
  f = os.path.join(directory, entry)
  if isdir:
   if (not os.path.exists(f)):
    os.makedirs(f)
  else:
   fdir = os.path.split(f)[0]
   if (not os.path.exists(fdir)):
    os.makedirs(fdir)
   if (overwrite or (not os.path.exists(f))):
    outfile = file(f, 'wb')
    outfile.write(zf.read(entry))
    outfile.close()
  (yield remaining)

def unzipIter ( filename , directory = '.' , overwrite = 0 ) : zf = zipfile . ZipFile ( filename , 'r' ) names = zf . namelist ( ) if ( not os . path . exists ( directory ) ) : os . makedirs ( directory ) remaining = len ( zf . namelist ( ) ) for entry in names : remaining -= 1 isdir = ( zf . getinfo ( entry ) . external_attr & DIR_BIT ) f = os . path . join ( directory , entry ) if isdir : if ( not os . path . exists ( f ) ) : os . makedirs ( f ) else : fdir = os . path . split ( f ) [ 0 ] if ( not os . path . exists ( fdir ) ) : os . makedirs ( fdir ) if ( overwrite or ( not os . path . exists ( f ) ) ) : outfile = file ( f , 'wb' ) outfile . write ( zf . read ( entry ) ) outfile . close ( ) ( yield remaining )
return a generator for the zipfile .