예제 #1
0
파일: tar.py 프로젝트: neko259/pkgcore
def generate_contents(filepath, compressor="bz2", parallelize=True):
    """
    generate a contentset from a tarball

    :param filepath: string path to location on disk
    :param compressor: defaults to bz2; decompressor to use, see
        :obj:`known_compressors` for list of valid compressors
    """

    if compressor == "bz2":
        compressor = "bzip2"

    tar_handle = None
    handle = compression.decompress_handle(compressor, filepath, parallelize=parallelize)

    try:
        tar_handle = tarfile.TarFile(name=filepath, fileobj=handle, mode="r")
    except tarfile.ReadError as e:
        if not e.message.endswith("empty header"):
            raise
        tar_handle = []
    return convert_archive(tar_handle)
예제 #2
0
def generate_contents(filepath, compressor="bz2", parallelize=True):
    """
    generate a contentset from a tarball

    :param filepath: string path to location on disk
    :param compressor: defaults to bz2; decompressor to use, see
        :obj:`known_compressors` for list of valid compressors
    """

    if compressor == 'bz2':
        compressor = 'bzip2'

    tar_handle = None
    handle = compression.decompress_handle(compressor, filepath,
        parallelize=parallelize)

    try:
        tar_handle = tarfile.TarFile(name=filepath, fileobj=handle, mode='r')
    except tarfile.ReadError as e:
        if not e.message.endswith("empty header"):
            raise
        tar_handle = []
    return convert_archive(tar_handle)