Extract an lzma file and return the temporary file name
355411
def extract_lzma(path):
    """"""
    tlfile = pathlib.Path(path)
    # open lzma file
    with tlfile.open("rb") as td:
        data = lzma.decompress(td.read())
    # write temporary tar file
    fd, tmpname = tempfile.mkstemp(prefix="odt_ex_", suffix=".tar")
    with open(fd, "wb") as fo:
        fo.write(data)
    return tmpname
959053
def unpackfile(filename, destdir):
    """"""
    if filename.endswith(".mar"):
        return unpackmar(filename, destdir)
    elif filename.endswith(".exe"):
        return unpackexe(filename, destdir)
    elif filename.endswith(".tar") or filename.endswith(".tar.gz") \
            or filename.endswith(".tgz"):
        return unpacktar(filename, destdir)
    else:
        raise ValueError("Unknown file type: %s" % filename)
1277002
def extract_flac (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    outfile = util.get_single_outfile(outdir, archive, extension=".wav")
    cmdlist = [cmd, '--decode', archive, '--output-name', outfile]
    return cmdlist
637989
def download_extract(url):
    """"""
    logger.info("Downloading %s", url)
    request = urllib2.Request(url)
    request.add_header('User-Agent',
                       'caelum/0.1 +https://github.com/nrcharles/caelum')
    opener = urllib2.build_opener()
    with tempfile.TemporaryFile(suffix='.zip', dir=env.WEATHER_DATA_PATH) \
            as local_file:
        logger.debug('Saving to temporary file %s', local_file.name)
        local_file.write(opener.open(request).read())
        compressed_file = zipfile.ZipFile(local_file, 'r')
        logger.debug('Extracting %s', compressed_file)
        compressed_file.extractall(env.WEATHER_DATA_PATH)
        local_file.close()
1018718
def _extract_file(zip_fp, info, path):
    """"""
    zip_fp.extract(info.filename, path=path)
    out_path = os.path.join(path, info.filename)

    perm = info.external_attr >> 16
    perm |= stat.S_IREAD  # make sure we're not accidentally setting this to 0
    os.chmod(out_path, perm)
371712
def temporary_directory():
    
    dir_name = tempfile.mkdtemp()
    yield dir_name
    if os.path.exists(dir_name):
        shutil.rmtree(dir_name)
709769
def extract_lrzip (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    cmdlist = [cmd, '-d']
    if verbosity > 1:
        cmdlist.append('-v')
    outfile = util.get_single_outfile(outdir, archive)
    cmdlist.extend(["-o", outfile, os.path.abspath(archive)])
    return cmdlist
688678
def get_temp_filename (content):
    """"""
    # store content in temporary file
    fd, filename = fileutil.get_temp_file(mode='wb', suffix='.doc',
        prefix='lc_')
    try:
        fd.write(content)
    finally:
        fd.close()
    return filename
326286
def fromfilenames(cls, filenames, coltype=LIGOTimeGPS):
		
		cache = cls()
		for filename in filenames:
			cache.extend(cls.fromfile(open(filename), coltype=coltype))
		return cache
688692
def tempfile(self):
        ""
        tf = tempfile.NamedTemporaryFile()
        tfn = tf.name
        tf.close()
        os.remove(tf.name)
        shutil.copy(self.fn, tfn)
        return tfn
837907
def extract_lzh (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    opts = 'x'
    if verbosity > 1:
        opts += 'v'
    opts += "w=%s" % outdir
    return [cmd, opts, archive]
897301
def untar(fname, verbose=True):
    
    if fname.lower().endswith(".tar.gz"):
        dirpath = os.path.join(BIGDATA_PATH, os.path.basename(fname)[:-7])
        if os.path.isdir(dirpath):
            return dirpath
        with tarfile.open(fname) as tf:
            members = tf.getmembers()
            for member in tqdm(members, total=len(members)):
                tf.extract(member, path=BIGDATA_PATH)
        dirpath = os.path.join(BIGDATA_PATH, members[0].name)
        if os.path.isdir(dirpath):
            return dirpath
    else:
        logger.warning("Not a tar.gz file: {}".format(fname))
959790
def extract_tar(fileobj):
    """"""
    import time

    archive = tarfile.open(fileobj=fileobj)
    filenames = [info.name for info in archive.getmembers() if info.isfile()]

    for src_name, dst_name in filter_tzfiles(filenames):
        mtime = archive.getmember(src_name).mtime
        modified = tuple(time.gmtime(mtime)[:6])
        bytes = archive.extractfile(src_name).read()

        yield dst_name, modified, bytes
552882
def extract_file_from_zip(bytes_io, expected_file):
    """"""
    zipf = zipfile.ZipFile(bytes_io) 
    return zipf.read(expected_file)
532510
def tmpfile(prefix, direc):
    """"""
    return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc)
120100
def temporary_dir():
    
    d = tempfile.mkdtemp()
    try:
        with cd(d):
            yield d
    finally:
        if os.path.exists(d):
            shutil.rmtree(d)
1179533
def extract_filename(self):
    """"""
    globals_gdbval = self._gdbval['f_globals'].cast(GdbCache.DICT)
    global_dict = libpython.PyDictObjectPtr(globals_gdbval)
    for key, value in global_dict.iteritems():
      if str(key.proxyval(set())) == '__file__':
        return str(value.proxyval(set()))