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)
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)