Extract file zip to destiny path folder targeting only some kind of files.
979361
def extract_filezip(path_to_file, dest_path, target_zipfiles=None):
    

    target_zipfiles = ['.*'] if target_zipfiles is None else target_zipfiles

    files = []
    _, ext = os.path.splitext(path_to_file)

    if ext == '.zip':
        file = open(path_to_file, 'rb')
        with zipfile.ZipFile(file) as zip_file:
            regexp = '|'.join(target_zipfiles) if target_zipfiles else '.*'
            search_regex = re.compile(regexp)

            lista = [m.group() for x in zip_file.namelist()
                     for m in [search_regex.search(x)] if m]

            for zp_file in lista:
                try:
                    zip_file.extract(zp_file, dest_path)
                    files.append(os.path.join(dest_path, zp_file))
                except Exception as ex:
                    msg = 'Fail to extract {} in {} to {} - {}'.format(
                        zp_file, path_to_file, dest_path, ex)
                    logger.error(msg)
        file.close()
    else:
        logger.warning('Not zipfile passed in args')
    return files
780251
def extractall(self, directory, auto_create_dir=False, patool_path=None):
        '''
        
        '''
        log.debug('extracting %s into %s (backend=%s)', self.filename, directory, self.backend)
        is_zipfile = zipfile.is_zipfile(self.filename)
        directory = _fullpath(directory)
        if not os.path.exists(self.filename):
            raise ValueError(
                'archive file does not exist:' + str(self.filename))
        if not os.path.exists(directory):
            if auto_create_dir:
                os.makedirs(directory)
            else:
                raise ValueError('directory does not exist:' + str(directory))

        if self.backend == 'auto':
            if is_zipfile:
                self.extractall_zipfile(directory)
            else:
                self.extractall_patool(directory, patool_path)

        if self.backend == 'zipfile':
            if not is_zipfile:
                raise ValueError('file is not zip file:' + str(self.filename))
            self.extractall_zipfile(directory)

        if self.backend == 'patool':
            self.extractall_patool(directory, patool_path)
239998
def _extract_archive(file, target_dir):
    
    if file.endswith('.gz') or file.endswith('.tar') or file.endswith('.tgz'):
        archive = tarfile.open(file, 'r')
    elif file.endswith('.zip'):
        archive = zipfile.ZipFile(file, 'r')
    else:
        raise Exception('Unrecognized file type: ' + file)
    archive.extractall(path=target_dir)
    archive.close()
1263449
def extract_file(self, name, full_path=False, directory="."):
        
        if self.handle:
            for member in self.handle.getmembers():
                if (full_path and member.name == name or
                        not full_path and os.path.basename(
                            member.name) == name):
                    # TODO handle KeyError exception
                    self.handle.extract(member, path=directory)
127137
public static void extractZipFile(final String path, final File dest, final String fileName) throws IOException {
        FilenameFilter filter = null;
        if (null != fileName) {
            filter = new FilenameFilter() {
                public boolean accept(final File file, final String name) {
                    return fileName.equals(name) || fileName.startsWith(name);
                }
            };
        }
        extractZip(path, dest, filter, null, null);
    }
1156099
def from_files(controller, track_path, log_level=logging.ERROR):
        """"""
        rocket = Rocket(controller, track_path=track_path, log_level=log_level)
        rocket.connector = FilesConnector(track_path,
                                          controller=controller,
                                          tracks=rocket.tracks)
        return rocket
197924
def zip(filename, paths, strip_prefix=''):
    
    if isinstance(paths, basestring):
        paths = [paths]

    filelist = set()
    for p in paths:
        if os.path.isfile(p):
            filelist.add(p)
        else:
            for root, dirs, files in os.walk(p):
                for f in files:
                    filelist.add(os.path.join(root, f))

    z = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)
    for f in sorted(filelist):
        arcname = f
        if arcname.startswith(strip_prefix):
            arcname = arcname[len(strip_prefix):]
        if arcname.startswith(os.path.sep):
            arcname = arcname[1:]
        log.debug('Adding %s to %s[%s]', f, filename, arcname)
        z.write(f, arcname)

    z.close()
653719
def _extract(archive, compression, cmd, format, verbosity, outdir):
    """"""
    targetname = util.get_single_outfile(outdir, archive)
    try:
        with lzma.LZMAFile(archive, **_get_lzma_options(format)) as lzmafile:
            with open(targetname, 'wb') as targetfile:
                data = lzmafile.read(READ_SIZE_BYTES)
                while data:
                    targetfile.write(data)
                    data = lzmafile.read(READ_SIZE_BYTES)
    except Exception as err:
        msg = "error extracting %s to %s: %s" % (archive, targetname, err)
        raise util.PatoolError(msg)
    return None
822199
def from_zipfile(cls, path, filename, encoding, dialect, fields, converters):
        """"""

        stream = ZipReader(path, filename).readlines(encoding)
        return cls(stream, dialect, fields, converters)
228585
def zipdir(src_path, target_path, wrapdir=''):
    

    zipf = zipfile.ZipFile(target_path, 'w', zipfile.ZIP_DEFLATED)

    for root, dirs, files in os.walk(src_path):
        for file in files:
            path = os.path.join(root, file)
            # get the relative path from the src_path in order to avoid an archive
            # of absolute paths including your home directory.
            rel_path = os.path.relpath(path, src_path)
            zipf.write(path, os.path.join(wrapdir, rel_path))

    zipf.close()
614498
def extract_lzma(archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    cmdlist = [util.shell_quote(cmd), '--format=lzma']
    if verbosity > 1:
        cmdlist.append('-v')
    outfile = util.get_single_outfile(outdir, archive)
    cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
        util.shell_quote(outfile)])
    return (cmdlist, {'shell': True})
3930
def extract_tarfile(archive_name, destpath):
    ""
    archive = tarfile.open(archive_name)
    archive.extractall(destpath)
565139
public function extractZipFile($container, $path, $zip, $clean = false, $drop_path = '')
    {
        if ($clean) {
            try {
                // clear out anything in this directory
                $blobs = $this->listBlobs($container, $path);
                if (!empty($blobs)) {
                    foreach ($blobs as $blob) {
                        if ((0 !== strcasecmp($path, $blob['name']))) { // not folder itself
                            $this->deleteBlob($container, $blob['name']);
                        }
                    }
                }
            } catch (\Exception $ex) {
                throw new InternalServerErrorException("Could not clean out existing directory $path.\n{$ex->getMessage()}");
            }
        }
        for ($i = 0; $i < $zip->numFiles; $i++) {
            try {
                $name = $zip->getNameIndex($i);
                if (empty($name)) {
                    continue;
                }
                if (!empty($drop_path)) {
                    $name = str_ireplace($drop_path, '', $name);
                }
                $fullPathName = $path . $name;
                if ('/' === substr($fullPathName, -1)) {
                    $this->createFolder($container, $fullPathName, true, [], false);
                } else {
                    $parent = FileUtilities::getParentFolder($fullPathName);
                    if (!empty($parent)) {
                        $this->createFolder($container, $parent, true, [], false);
                    }
                    $content = $zip->getFromIndex($i);
                    $this->writeFile($container, $fullPathName, $content);
                }
            } catch (\Exception $ex) {
                throw $ex;
            }
        }

        return ['name' => rtrim($path, DIRECTORY_SEPARATOR), 'path' => $path];
    }
207065
function extractFolders( files ) {
    return files.data.files.map( function extractPath( file ) {
      return path.parse( file ).dir;
    }).filter( function extractUnique( path, index, array ) {
      return array.indexOf( path ) === index;
    });
  }
550403
public void extractZipEntry(final ZipFile zipFile, final ZipEntry target,
		final File toDirectory) throws IOException
	{
		ZipExtensions.extractZipEntry(zipFile, target, toDirectory);
	}
228016
def extract_xz(archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    return _extract(archive, compression, cmd, 'xz', verbosity, outdir)
552882
def extract_file_from_zip(bytes_io, expected_file):
    """"""
    zipf = zipfile.ZipFile(bytes_io) 
    return zipf.read(expected_file)