Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
zip.py27 linesDownload Raw Back to tests
1"""2Generate zip test data files.3"""4 5import zipfile6 7import zipp8 9 10def make_zip_file(tree, dst):11    """12    Zip the files in tree into a new zipfile at dst.13    """14    with zipfile.ZipFile(dst, 'w') as zf:15        for name, contents in walk(tree):16            zf.writestr(name, contents)17        zipp.CompleteDirs.inject(zf)18    return dst19 20 21def walk(tree, prefix=''):22    for name, contents in tree.items():23        if isinstance(contents, dict):24            yield from walk(contents, prefix=f'{prefix}{name}/')25        else:26            yield f'{prefix}{name}', contents27 
codekingpro/portable-devtools · Team Ai