pymovements.utils.downloads.download_and_extract_archive#
- pymovements.utils.downloads.download_and_extract_archive(url: str, download_dirpath: Path, download_filename: str, extract_dirpath: Path | None = None, md5: str | None = None, recursive: bool = True, remove_finished: bool = False, remove_top_level: bool = True, verbose: int = 1) None[source]#
Download and extract archive file.
- Parameters:
url (str) – URL of archive file to be downloaded.
download_dirpath (Path) – Path to directory where file will be saved to.
download_filename (str, optional) – Target filename of saved file.
extract_dirpath (Path, optional) – Path to directory where archive files will be extracted to.
md5 (str, optional) – MD5 checksum of downloaded file. If None, do not check.
recursive (bool) – Recursively extract archives which are included in extracted archive.
remove_finished (bool) – Remove downloaded file after successful extraction or decompression, default: False.
remove_top_level (bool) – If
True, remove the top-level directory if it has only one child, default:True.verbose (int) – Verbosity levels: (1) Show download progress bar and print info messages on downloading and extracting archive files without printing messages for recursive archive extraction. (2) Print additional messages for each recursive archive extract.
- Raises:
RuntimeError – If the downloaded file has no suffix or suffix is not supported, or in case of a specified MD5 checksum which doesn’t match the checksum of the downloaded file.