lair.records.unzip#

lair.records.unzip(zf, dir_path=None)[source]#

Unzip a file into a folder.

Parameters:
  • zf (str) – Path to zip file

  • dir_path (str, optional) – Folder to unzip into; by default the folder that holds the zip file.

See also

wget_download

Downloads files and unzips them.

Examples

>>> import tempfile, zipfile
>>> from pathlib import Path
>>> from lair.records import unzip
>>> folder = Path(tempfile.mkdtemp())
>>> with zipfile.ZipFile(folder / "data.zip", "w") as z:
...     z.writestr("a.txt", "hello")
>>> unzip(str(folder / "data.zip"))
>>> (folder / "a.txt").read_text()
'hello'