zip_archive
file=None, mode='w', root='') zip_archive(x,
Zip a folder to a file
Args: x (str): Path to the folder to zip or a list of paths to put in a zip file file (str): Path to the output zip file to create. Defaults to a .zip file in the temporary directory. mode (str): Passed on to zipfile.ZipFile. Defaults to ‘w’: write
Returns: a str with the path to the zip file
Examples: >>> from rlike import * >>> folder = tempdir() >>> f1 = writeLines(text = ‘Hello world. Some more text.’, con = file_path(folder, ‘fname1.txt’)) >>> f2 = writeLines(text = ‘Hello world. Some more text.’, con = file_path(folder, ‘fname2.txt’)) >>> zip_archive(folder, file = ‘xyz.zip’) ‘xyz.zip’ >>> file_exists([f1, f2, ‘xyz.zip’]) [True, True, True] >>> out = unzip(‘xyz.zip’, path = tempdir()) >>> sorted(basename(out)) [‘fname1.txt’, ‘fname2.txt’] >>> zip_archive([f1], file = ‘abc.zip’, root = dirname(f1)) ‘abc.zip’ >>> out = unzip(‘abc.zip’, path = tempdir()) >>> basename(out) [‘fname1.txt’] >>> clean = file_remove([f1, f2, ‘xyz.zip’, ‘abc.zip’])