dival.util.download module

dival.util.download.download_file(url, filename=None, chunk_size=1024, verbose=False, md5sum=True)[source]

Download file with progressbar.

Based on https://gist.github.com/ruxi/5d6803c116ec1130d484a4ab8c00c603 (MIT License).

Parameters
  • url (str) – URL to download from.

  • filename (str, optional) – Local destination filename (including path). By default, the file is stored under the current folder and the name given by the last part of url.

  • chunk_size (int, optional) – Number of bytes in a chunk. Default: 1024

  • verbose (bool, optional) – Whether to print additional information. Default: False

  • md5sum (bool, optional) – Whether to compute and return the MD5 checksum (hex-digest). Default: True

Returns

md5sum – Hex-digest of the MD5 hash, if md5sum=True, otherwise None.

Return type

str or None

dival.util.download.compute_md5sum(filename, show_pbar=True)[source]

Compute MD5 checksum of an existing file.

Parameters
  • filename (str) – Filename including path.

  • show_pbar (str) – Show tqdm progress bar. Default: True

Returns

md5sum – Hex-digest of the MD5 hash.

Return type

str