archive_fpath = zip_fpath
    archive_file = zip_file
341761
def _extract_archive(archive_fpath, archive_file, archive_namelist, output_dir,
                     force_commonprefix=True, prefix=None,
                     dryrun=False, verbose=not QUIET, overwrite=None):
    
    # force extracted components into a subdirectory if force_commonprefix is
    # on return_path = output_diG
    # FIXMpathE doesn't work right
    if prefix is not None:
        output_dir = join(output_dir, prefix)
        util_path.ensurepath(output_dir)

    archive_basename, ext = split_archive_ext(basename(archive_fpath))
    if force_commonprefix and commonprefix(archive_namelist) == '':
        # use the archivename as the default common prefix
        output_dir = join(output_dir, archive_basename)
        util_path.ensurepath(output_dir)

    for member in archive_namelist:
        (dname, fname) = split(member)
        dpath = join(output_dir, dname)
        util_path.ensurepath(dpath)
        if verbose:
            print('[utool] Unarchive ' + fname + ' in ' + dpath)

        if not dryrun:
            if overwrite is False:
                if exists(join(output_dir, member)):
                    continue
            archive_file.extract(member, path=output_dir)
    return output_dir
1002448
def extract_archive(archive, solver, put_inside = False):
    

    print('extracting {0}'.format(archive))
    root = os.path.join('solvers', solver if put_inside else '')

    if archive.endswith('.tar.gz'):
        if os.path.exists(archive[:-7]):
            shutil.rmtree(archive[:-7])

        tfile = tarfile.open(archive, 'r:gz')
        tfile.extractall(root)

        # normally, directory should be the first name
        # but glucose4.1 has some garbage in the archive
        for name in tfile.getnames():
            if not name.startswith('./.'):
                directory = name
                break
    elif archive.endswith('.zip'):
        if os.path.exists(archive[:-4]):
            shutil.rmtree(archive[:-4])

        myzip = zipfile.ZipFile(archive, 'r')
        myzip.extractall(root)
        directory = myzip.namelist()[0]
        directory = directory.rstrip('/').split('/')[0]
        myzip.close()

    if not put_inside:
        if os.path.exists(os.path.join('solvers', solver)):
            shutil.rmtree(os.path.join('solvers', solver))

        shutil.move(os.path.join('solvers', directory), os.path.join('solvers', solver))
439421
def extract_archive(archive_path, dest):
  
  # Make the dest folder if it does not exist
  if not os.path.isdir(dest):
    os.makedirs(dest)

  try:
    tmpfolder = None

    if (not tf.gfile.Exists(archive_path)) or tf.gfile.IsDirectory(archive_path):
      raise ValueError('archive path %s is not a file' % archive_path)

    if archive_path.startswith('gs://'):
      # Copy the file to a local temp folder
      tmpfolder = tempfile.mkdtemp()
      cmd_args = ['gsutil', 'cp', archive_path, tmpfolder]
      _shell_process.run_and_monitor(cmd_args, os.getpid())
      archive_path = os.path.join(tmpfolder, os.path.name(archive_path))

    if archive_path.lower().endswith('.tar.gz'):
      flags = '-xzf'
    elif archive_path.lower().endswith('.tar'):
      flags = '-xf'
    else:
      raise ValueError('Only tar.gz or tar.Z files are supported.')

    cmd_args = ['tar', flags, archive_path, '-C', dest]
    _shell_process.run_and_monitor(cmd_args, os.getpid())
  finally:
    if tmpfolder:
      shutil.rmtree(tmpfolder)
1056993
def auto_zip_open(filepath, mode):
    """"""
    if filepath.endswith('.gz'):
        outfile = gzip.open(filepath, mode)
    elif filepath.endswith('.bz2'):
        outfile = bz2.BZ2File(filepath, mode)
    else:
        outfile = open(filepath, mode)
    return outfile
1201673
def zipper(root_dir="", name="", path_name_ext=""):
    
    logger_zips.info("re_zip: name: {}, dir_tmp: {}".format(path_name_ext, root_dir))
    # creates a zip archive in current directory. "somefile.lpd.zip"
    shutil.make_archive(path_name_ext, format='zip', root_dir=root_dir, base_dir=name)
    # drop the .zip extension. only keep .lpd
    os.rename("{}.zip".format(path_name_ext), path_name_ext)
    return
576725
@Override
    protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath,
            long lastModified, File fromArchive, int mode) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IoUtil.copy(is, baos, buf);
        struct.data = baos.toByteArray();
        struct.name = vPath;
        struct.time = lastModified;
        if (proc.process(struct) != JarProcessor.Result.DISCARD) {
            if (mode == 0)
                mode = ZipFileSet.DEFAULT_FILE_MODE;
            if (!filesOnly) {
                addParentDirs(struct.name, zOut);
            }
            super.zipFile(new ByteArrayInputStream(struct.data),
                    zOut, struct.name, struct.time, fromArchive, mode);
        }
    }
257594
def current_zipfile():
    """"""
    if zipfile.is_zipfile(sys.argv[0]):
        fd = open(sys.argv[0], "rb")
        return zipfile.ZipFile(fd)
373052
def set_artefact_path(self, path_to_zip_file):
        
        self.config["deploy"]["deploy_file"] = path_to_zip_file
        return {'ZipFile': self.build.read(self.config["deploy"]["deploy_file"])}
1235053
def extract_zipped_paths(path):
    
    if os.path.exists(path):
        # this is already a valid path, no need to do anything further
        return path

    # find the first valid part of the provided path and treat that as a zip archive
    # assume the rest of the path is the name of a member in the archive
    archive, member = os.path.split(path)
    while archive and not os.path.exists(archive):
        archive, prefix = os.path.split(archive)
        member = '/'.join([prefix, member])

    if not zipfile.is_zipfile(archive):
        return path

    zip_file = zipfile.ZipFile(archive)
    if member not in zip_file.namelist():
        return path

    # we have a valid zip archive and a valid member of that archive
    tmp = tempfile.gettempdir()
    extracted_path = os.path.join(tmp, *member.split('/'))
    if not os.path.exists(extracted_path):
        extracted_path = zip_file.extract(member, path=tmp)

    return extracted_path
1348498
def zip_dir(path, zip_handler, include_dir=True, use_arc_name=False):
    

    for root, dirs, files in os.walk(path):
        for file_to_zip in files:
            filename = os.path.join(root, file_to_zip)
            zip_con = filename.replace('\\', '/')

            if zip_con in zip_handler.namelist():
                continue

            add_file(filename, zip_handler, include_dir, use_arc_name)
977915
def extract_zip(zip_path, target_folder):
    
    with zipfile.ZipFile(zip_path) as archive:
        archive.extractall(target_folder)
417077
def archive(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "archive", value)
            assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format("archive", value)
        self.__archive = value
802865
def _extract_zip(archive, dest=None, members=None):
    """"""
    # Python 2.5 compatibility.
    dest = dest or os.getcwd()
    members = members or archive.infolist()

    for member in members:
        if isinstance(member, basestring):
            member = archive.getinfo(member)

        _extract_zip_member(archive, member, dest)
109051
public static File zip(List<String> fileNames, String zipPath, String encoding) {
    try {
      FileOutputStream f = new FileOutputStream(zipPath);
      ZipArchiveOutputStream zos = (ZipArchiveOutputStream) new ArchiveStreamFactory()
          .createArchiveOutputStream(ArchiveStreamFactory.ZIP, f);
      if (null != encoding) {
        zos.setEncoding(encoding);
      }
      for (int i = 0; i < fileNames.size(); i++) {
        String fileName = fileNames.get(i);
        String entryName = Strings.substringAfterLast(fileName, File.separator);
        ZipArchiveEntry entry = new ZipArchiveEntry(entryName);
        zos.putArchiveEntry(entry);
        FileInputStream fis = new FileInputStream(fileName);
        IOs.copy(fis, zos);
        fis.close();
        zos.closeArchiveEntry();
      }
      zos.close();
      return new File(zipPath);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
215098
def archive_path(self, real_path):
        
        if (not self.path_prefix):
            return(real_path)
        else:
            return(os.path.relpath(real_path, self.path_prefix))
108488
def _extract_info(archive, info):
    

    if isinstance(archive, zipfile.ZipFile):
        fn = info.filename
        is_dir = fn.endswith('/') or fn.endswith('\\')
        out = archive.read(info)
        if is_dir and out == b'':
            return None
        return out

    info_file = archive.extractfile(info)
    if info_file:
        return info_file.read()
    return None
167583
function extractFile (err, zipPath) {
  if (err) return onerror(err)
  extract(zipPath, { dir: path.join(__dirname, 'dist') }, function (err) {
    if (err) return onerror(err)
    fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) {
      if (err) return onerror(err)
    })
  })
}