def _unpack_zipfile(filename, extract_dir):
 try:
  import zipfile
 except ImportError:
  raise ReadError('zlib not supported, cannot unpack this archive.')
 if (not zipfile.is_zipfile(filename)):
  raise ReadError(('%s is not a zip file' % filename))
 zip = zipfile.ZipFile(filename)
 try:
  for info in zip.infolist():
   name = info.filename
   if (name.startswith('/') or ('..' in name)):
    continue
   target = os.path.join(extract_dir, *name.split('/'))
   if (not target):
    continue
   _ensure_directory(target)
   if (not name.endswith('/')):
    data = zip.read(info.filename)
    f = open(target, 'wb')
    try:
     f.write(data)
    finally:
     f.close()
     del data
 finally:
  zip.close()

def _unpack_zipfile ( filename , extract_dir ) : try : import zipfile except ImportError : raise ReadError ( 'zlib not supported, cannot unpack this archive.' ) if ( not zipfile . is_zipfile ( filename ) ) : raise ReadError ( ( '%s is not a zip file' % filename ) ) zip = zipfile . ZipFile ( filename ) try : for info in zip . infolist ( ) : name = info . filename if ( name . startswith ( '/' ) or ( '..' in name ) ) : continue target = os . path . join ( extract_dir , * name . split ( '/' ) ) if ( not target ) : continue _ensure_directory ( target ) if ( not name . endswith ( '/' ) ) : data = zip . read ( info . filename ) f = open ( target , 'wb' ) try : f . write ( data ) finally : f . close ( ) del data finally : zip . close ( )
unpack zip filename to extract_dir .