torch_ecg.utils.http_get#

torch_ecg.utils.http_get(url: str, dst_dir: str | bytes | PathLike, proxies: dict | None = None, extract: Literal[True, False, 'auto'] = 'auto', filename: str | None = None, *, timeout: Tuple[float, float] | float = (5.0, 60.0), verify_length: bool = True) → Path[source]#

Download contents of a URL and save to a file.

This function is a modified version of the download_file function in transformers.file_utils [1].

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

  • dst_dir (path-like) – Directory to save the file. If extract is True, the extracted content will be saved to dst_dir.

  • proxies (dict, optional) – Dictionary of proxy settings.

  • extract ({True, False, "auto"}, default "auto") – Whether to extract the downloaded file. “auto” will extract if the file is a zip file or a compressed tar file.

  • filename (str, optional) –

    Name of the downloaded file. If None, the filename will be the basename of the URL. If extract is True, the filename will NOT affect the extracted folder name, which is set to dst_dir, and filename is only the downloaded file name.

    Added in version 0.0.20.

  • timeout (float or tuple, default (5.0, 60.0)) –

    How many seconds to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.

    Added in version 0.0.32.

  • verify_length (bool, default True) –

    Whether to verify the length of the downloaded file with the Content-Length header in the HTTP response.

    Added in version 0.0.32.

Returns:

final_dst – Path to the downloaded file or the extracted folder.

Return type:

pathlib.Path

References