Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/to_disk.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | for file_data in files_data: | ||||
content = HIDDEN_MESSAGE | content = HIDDEN_MESSAGE | ||||
elif status == "visible": | elif status == "visible": | ||||
sha1 = file_data["sha1"] | sha1 = file_data["sha1"] | ||||
data = storage.content_get_data(sha1) | data = storage.content_get_data(sha1) | ||||
if data is None: | if data is None: | ||||
content = SKIPPED_MESSAGE | content = SKIPPED_MESSAGE | ||||
else: | else: | ||||
content = data | content = data | ||||
else: | |||||
assert False, ( | |||||
f"unexpected status {status!r} " | |||||
f"for content {hashutil.hash_to_hex(file_data['target'])}" | |||||
) | |||||
yield {"content": content, **file_data} | yield {"content": content, **file_data} | ||||
def apply_chunked(func, input_list, chunk_size): | def apply_chunked(func, input_list, chunk_size): | ||||
"""Apply func on input_list divided in chunks of size chunk_size""" | """Apply func on input_list divided in chunks of size chunk_size""" | ||||
for i in range(0, len(input_list), chunk_size): | for i in range(0, len(input_list), chunk_size): | ||||
yield from func(input_list[i : i + chunk_size]) | yield from func(input_list[i : i + chunk_size]) | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |