i7aof.download

Helpers to download remote files with a progress bar. See i7aof.io for developer details.

i7aof.download.download_file(url, dest_path, quiet=False, overwrite=False)

Download a file from a given URL to a specified destination directory.

Parameters:
  • url (str) – The URL of the file to download.

  • dest_path (str) – The destination directory or filename where the file will be saved. If a directory, it should already exist. If a filename, its directory will be created if it does not exist.

  • quiet (bool, optional) – If True, suppress the progress bar. Default is False.

  • overwrite (bool, optional) – If True, overwrite the file if it already exists. Default is False.

Examples

>>> download_file('http://example.com/file1.txt', '/path/to/destination', quiet=True, overwrite=True)
i7aof.download.download_files(files, base_url, dest_dir, quiet=False, overwrite=False)

Download multiple files from a base URL to a specified destination directory.

Parameters:
  • files (list of str) – The list of file paths to download from the base URL.

  • base_url (str) – The base URL from which the files will be downloaded.

  • dest_dir (str) – The destination directory where the files will be saved.

  • quiet (bool, optional) – If True, suppress the progress bar. Default is False.

  • overwrite (bool, optional) – If True, overwrite the files if they already exist. Default is False.

Examples

>>> download_files(['file1.txt', 'subdir/file2.txt'], 'http://example.com/', '/path/to/destination', quiet=True, overwrite=True)