(filename, extract_dir)
Unpack zip `filename` to `extract_dir`
Unpack zip `filename` to `extract_dir`
Unpack zip filename to extract_dir
def _unpack_zipfile(filename, extract_dir):
    """Unpack zip `filename` to `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

            # don't extract absolute paths or ones with .. in them
            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('/'):
                # file
                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 # don't extract absolute paths or ones with .. in them 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 ( '/' ) : # file data = zip . read ( info . filename ) f = open ( target , 'wb' ) try : f . write ( data ) finally : f . close ( ) del data finally : zip . close ( )