extracts given ttl file from JHU tar.gz package
 - assumed to live under data/obj/root
 @return [Array<Hash>] the first element is the "work" and the additional elements, if any, are the contributor(s)
15174
def ttl_from_targz(ttl_filename)
      package_dir = config.fetch('package_dir')
      ttl_path = File.join(source_slug, 'data/obj/root', ttl_filename)
      ROF::Utility.file_from_targz(File.join(package_dir, source_slug + '.tar.gz'), ttl_path)
      fetch_from_ttl(File.join(package_dir, ttl_path))
    end
444402
def hash_from_file_content(string)
      hash = {}
      string.split("\n").each do |line|
        uncommented_line = strip_comment(line)
        if include = extract_include(uncommented_line)
          @includes.push normalized_xcconfig_path(include)
        else
          key, value = extract_key_value(uncommented_line)
          next unless key
          value.gsub!(INHERITED_REGEXP) { |m| hash.fetch(key, m) }
          hash[key] = value
        end
      end
      hash
    end
760891
def fetch_libzmq(savedir):
    """"""
    dest = pjoin(savedir, 'zeromq')
    if os.path.exists(dest):
        info("already have %s" % dest)
        return
    path = fetch_archive(savedir, libzmq_url, fname=libzmq, checksum=libzmq_checksum)
    tf = tarfile.open(path)
    with_version = pjoin(savedir, tf.firstmember.path)
    tf.extractall(savedir)
    tf.close()

    # remove version suffix:
    shutil.move(with_version, dest)
416069
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
    
    try:
        tarobj = tarfile.open(filename)
    except tarfile.TarError:
        raise UnrecognizedFormat(
            "%s is not a compressed or uncompressed tar file" % (filename,)
        )
    with contextlib.closing(tarobj):
        # don't do any chowning!
        tarobj.chown = lambda *args: None
        for member in tarobj:
            name = member.name
            # don't extract absolute paths or ones with .. in them
            if not name.startswith('/') and '..' not in name.split('/'):
                prelim_dst = os.path.join(extract_dir, *name.split('/'))

                # resolve any links and to extract the link targets as normal
                # files
                while member is not None and (member.islnk() or member.issym()):
                    linkpath = member.linkname
                    if member.issym():
                        base = posixpath.dirname(member.name)
                        linkpath = posixpath.join(base, linkpath)
                        linkpath = posixpath.normpath(linkpath)
                    member = tarobj._getmember(linkpath)

                if member is not None and (member.isfile() or member.isdir()):
                    final_dst = progress_filter(name, prelim_dst)
                    if final_dst:
                        if final_dst.endswith(os.sep):
                            final_dst = final_dst[:-1]
                        try:
                            # XXX Ugh
                            tarobj._extract_member(member, final_dst)
                        except tarfile.ExtractError:
                            # chown/chmod/mkfifo/mknode/makedev failed
                            pass
        return True
3930
def extract_tarfile(archive_name, destpath):
    ""
    archive = tarfile.open(archive_name)
    archive.extractall(destpath)
1170346
def find_metadata(tarball)
        gzip = Zlib::GzipReader.new(tarball[:tempfile])
        tar = Gem::Package::TarReader.new(gzip)

        tar.each do |entry|
          if entry.full_name =~ /metadata\.json$/
            return Metadata.from_json(entry.read)
          elsif entry.full_name =~ /metadata\.rb$/
            return Metadata.from_ruby(entry.read)
          end
        end
      ensure
        tar.close
      end
1151127
def extract(*path)
      node = payload
      node if path.all? do |sub|
        break unless node.is_a? Hash

        node = node[sub.to_s]
      end
    end
1372592
def extract
      Zip::File.open(package_file) do |zip|
        zip.each do |file|
          file.extract(file.name)
        end
      end
    end
639383
def local_clone
      return @local_clone if @local_clone
      return nil if cache.nil?
      return nil if source.nil?
      hash = Digest::SHA1.hexdigest(source)[0..10]
      path = Zaru.sanitize! source.gsub(%r{[/\\:]}, '_')
      File.join cache, "repo_#{path}_#{hash}"
    end
667391
def extract_tar(url, target_dir, additional_compression="", remove_common_prefix=False, overwrite=False):
    
    try:
        if not os.path.exists(target_dir):
            os.makedirs(target_dir)
        tf = tarfile.TarFile.open(fileobj=download_to_bytesio(url))
        if not os.path.exists(target_dir):
            os.makedirs(target_dir)
        common_prefix = os.path.commonprefix(tf.getnames())
        if not common_prefix.endswith('/'):
            common_prefix += "/"
        for tfile in tf.getmembers():
            if remove_common_prefix:
                tfile.name = tfile.name.replace(common_prefix, "", 1)
            if tfile.name != "":
                target_path = os.path.join(target_dir, tfile.name)
                if target_path != target_dir and os.path.exists(target_path):
                    if overwrite:
                        remove_path(target_path)
                    else:
                        continue
                tf.extract(tfile, target_dir)
    except OSError:
        e = sys.exc_info()[1]
        raise ExtractException(str(e))
    except IOError:
        e = sys.exc_info()[1]
        raise ExtractException(str(e))
405384
def get_module(author, name, version)
            file_name = "#{author}-#{name}-#{version}.tar.gz"
            path = File.join(File.expand_path(@module_dir.path), file_name)
            if File.exist? path
                File.open(path, 'r')
            else
                nil
            end
        end
265624
def extract
      Zip::File.open(package_file) do |zip|
        batch_size = [1, (zip.size / 100).to_i].max
        dots = 0
        zip.each do |file|
          @output.print "." if (dots % batch_size).zero?
          file.restore_permissions = true
          file.extract { accept_all }
          dots += 1
        end
      end
    end
691059
def get_common_files(self):
        
        # curl -sLu "username:personal-acess-token" \
        # GITAPI + "/hpo-annotation-data/tarball/master" > hpoa.tgz

        repo_dir = self.rawdir + '/git'
        username = CONF['user']['hpoa']
        response = requests.get(
            GITAPI + '/hpo-annotation-data/tarball/master',
            auth=(username, CONF['keys'][username]))

        with open(self.rawdir + '/hpoa.tgz', 'wb') as tgz:
            tgz.write(response.content)

        if os.path.isdir(repo_dir):  # scoarched earth approach
            shutil.rmtree(repo_dir)
        os.mkdir(repo_dir)

        with tarfile.open('raw/hpoa/hpoa.tgz', 'r') as tarball:
            tarball.extractall(repo_dir)

        # TO-DO add this to the dataset object
        # hmm ...kay... have git commit-hash in tarball repo name

        repo_hash = glob.glob(
            str(
                '/'.join(
                    (self.rawdir, 'git', 'monarch-initiative-hpo-annotation-data-*')
                )))[-42:]

        print(repo_hash)
        repo_hash = str(repo_hash)
        # (note this makes little sense as it is a private repo)
        self.dataset.setFileAccessUrl(
            '/'.join((
                'https://github.com/monarch-initiative/hpo-annotation-data/tree',
                repo_hash)))

        return
849553
def extract_site_packages(archive, target_path, compile_pyc, compile_workers=0, force=False):
    
    parent = target_path.parent
    target_path_tmp = Path(parent, target_path.stem + ".tmp")
    lock = Path(parent, target_path.stem + ".lock")

    # If this is the first time that a pyz is being extracted, we'll need to create the ~/.shiv dir
    if not parent.exists():
        parent.mkdir(parents=True, exist_ok=True)

    with FileLock(lock):

        # we acquired a lock, it's possible that prior invocation was holding the lock and has
        # completed bootstrapping, so let's check (again) if we need to do any work
        if not target_path.exists() or force:

            # extract our site-packages
            for filename in archive.namelist():
                if filename.startswith("site-packages"):
                    archive.extract(filename, target_path_tmp)

            if compile_pyc:
                compileall.compile_dir(target_path_tmp, quiet=2, workers=compile_workers)

            # if using `force` we will need to delete our target path
            if target_path.exists():
                shutil.rmtree(str(target_path))

            # atomic move
            shutil.move(str(target_path_tmp), str(target_path))
466126
function extract_to_sync(_path, jszip) {

    var extraction_path = _path === null ? "./" : path.normalize(_path);
    if(extraction_path[extraction_path.length - 1] !== path.sep) {
        extraction_path += path.sep;
    }

    // make sure that the extraction path points to a existing directory
    var stats;
    try { stats = fs.statSync(extraction_path); }
    catch (err) { throw new Error(extraction_path + " doesn't exist"); }
    if (!stats.isDirectory())
        throw new Error(extraction_path + " is not a directory");

    // sort out the unzipped file to directories and files
    var dirs = [];
    var files = [];
    for (var name in jszip.files) {

        var entry = jszip.files[name];

        if (entry.dir)
            dirs.push(name);
        else
            files.push(name);
    }

    // sort the directories ascendingy by level
    dirs.sort(function (a, b) {
        function dir_sep_count(dir) { return (dir.match(/\//g) || []).length; }

        return dir_sep_count(a) - dir_sep_count(b);
    });


    // create the directories
    dirs.forEach(function (dir) {
        try {
            var stats = fs.statSync(extraction_path + dir);
            if(!stats.isDirectory()) {
                throw new Error("!dir");
            }
        }
        catch(err) {
            if(err.code === "ENOENT" || err.message === "!dir") {
                fs.mkdirSync(extraction_path + dir);
            }
            else {
                throw err;
            }
        }
    });

    // write the files
    files.forEach(function (file) {

        var data = jszip.file(file).asNodeBuffer();

        fs.writeFileSync(extraction_path + file, data);
    });

}
1162955
def ttl(self, ttl):
        
        clone = copy.deepcopy(self)
        clone._ttl = ttl
        return clone
185879
def get_sigla(self, work):
        
        return [os.path.splitext(os.path.basename(path))[0]
                for path in glob.glob(os.path.join(self._path, work, '*.txt'))]