unzip
unzip(file, path=None, recursive=True)
Unzip all files from a zip file to a certain path
Parameters
| file |
str |
Path to the zip file to unzip |
required |
| path |
Union[None, str] |
Path to the folder where to put the files in. Defaults to the temporary directory. |
None |
| recursive |
bool |
Passed on to zipfile.ZipFile. Defaults to ‘w’: write |
True |
Returns
|
List[str] |
a list with all files in path |
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'])