easycore.common.network

easycore.common.network.download_file(url: str, dir: str, filename: Optional[str] = None, progress: bool = True) → str[source]

Download a file from a given URL to a directory. If the file exists, will not overwrite the existing file.

Parameters:
  • url (str) –
  • dir (str) – the directory to store the file.
  • filename (str or None) – the basename to save the file. Use the name in the URL if not given.
  • progress (bool) – whether to use tqdm to draw a progress bar.
Returns:

str – the path to the downloaded file or the existing one.