download

download(url, path, force=True, clean_on_failure=True, backend='urllib', hexdigests=None, hexdigests_remote=None, hexdigests_strict=False, progress_bar=True, tqdm_kwargs=None, **kwargs)[source]

Download a file from a given URL.

Parameters:
  • url (str) – URL to download

  • path (Union[str, Path]) – Path to download the file to

  • force (bool) – If false and the file already exists, will not re-download.

  • clean_on_failure (bool) – If true, will delete the file on any exception raised during download

  • backend (str) – The downloader to use. Choose ‘urllib’ or ‘requests’

  • hexdigests (Optional[Mapping[str, str]]) – The expected hexdigests as (algorithm_name, expected_hex_digest) pairs.

  • hexdigests_remote (Optional[Mapping[str, str]]) – The expected hexdigests as (algorithm_name, url to file with expected hexdigest) pairs.

  • hexdigests_strict (bool) – Set this to false to stop automatically checking for the algorithm(filename)=hash format

  • progress_bar (bool) – Set to true to show a progress bar while downloading

  • tqdm_kwargs (Optional[Mapping[str, Any]]) – Override the default arguments passed to tadm.tqdm when progress_bar is True.

  • kwargs (Any) – The keyword arguments to pass to urllib.request.urlretrieve() or to requests.get depending on the backend chosen. If using ‘requests’ backend, stream is set to True by default.

Raises:
  • Exception – Thrown if an error besides a keyboard interrupt is thrown during download

  • KeyboardInterrupt – If a keyboard interrupt is thrown during download

  • UnexpectedDirectory – If a directory is given for the path argument

  • ValueError – If an invalid backend is chosen

Return type:

None