INNER CODE UNIT · Python
zipdir
allenai/objaverse-xl · scripts/rendering/main.py:43
def zipdir(path: str, ziph: zipfile.ZipFile) -> None:
"""Zip up a directory with an arcname structure.
Args:
path (str): Path to the directory to zip.
ziph (zipfile.ZipFile): ZipFile handler object to write to.
Returns:
None
"""
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
# this ensures the structure inside the zip starts at folder/
arcname = os.path.join(os.path.basename(root), file)
ziph.write(os.path.join(root, file), arcname=arcname)