def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
 if (not zipfile.is_zipfile(filename)):
  raise UnrecognizedFormat(('%s is not a zip file' % (filename,)))
 z = zipfile.ZipFile(filename)
 try:
  for info in z.infolist():
   name = info.filename
   if (name.startswith('/') or ('..' in name)):
    continue
   target = os.path.join(extract_dir, *name.split('/'))
   target = progress_filter(name, target)
   if (not target):
    continue
   if name.endswith('/'):
    ensure_directory(target)
   else:
    ensure_directory(target)
    data = z.read(info.filename)
    f = open(target, 'wb')
    try:
     f.write(data)
    finally:
     f.close()
     del data
 finally:
  z.close()

def unpack_zipfile ( filename , extract_dir , progress_filter = default_filter ) : if ( not zipfile . is_zipfile ( filename ) ) : raise UnrecognizedFormat ( ( '%s is not a zip file' % ( filename , ) ) ) z = zipfile . ZipFile ( filename ) try : for info in z . infolist ( ) : name = info . filename if ( name . startswith ( '/' ) or ( '..' in name ) ) : continue target = os . path . join ( extract_dir , * name . split ( '/' ) ) target = progress_filter ( name , target ) if ( not target ) : continue if name . endswith ( '/' ) : ensure_directory ( target ) else : ensure_directory ( target ) data = z . read ( info . filename ) f = open ( target , 'wb' ) try : f . write ( data ) finally : f . close ( ) del data finally : z . close ( )
unpack a zipfile .