(
    url: str,
    *,
    filename: str = None,
    dirpath: types.PathLike = constants.DEFAULT_DATA_DIR,
    force: bool = False,
)
return str(filepath)
Download a file from ``url`` and save it to disk.

    Args:
        url: Web address from which to download data.
        filename: Name of the file to which downloaded data is saved.
            If None, a filename will be inferred from the ``url``.
        dirpath: Full path to the directory on disk
            under which downloaded data will be saved as ``filename``.
        force: If True, download the data even if it already exists at
            ``dirpath/filename``; otherwise, only download if the data doesn't
            already exist on disk.

    Returns:
        Full path of file saved to disk.
Download a file from ``url`` and save it to disk.
Download a file from url and save it to disk .
def download_file(
    url: str,
    *,
    filename: str = None,
    dirpath: types.PathLike = constants.DEFAULT_DATA_DIR,
    force: bool = False,
) -> Optional[str]:
    """
    Download a file from ``url`` and save it to disk.

    Args:
        url: Web address from which to download data.
        filename: Name of the file to which downloaded data is saved.
            If None, a filename will be inferred from the ``url``.
        dirpath: Full path to the directory on disk
            under which downloaded data will be saved as ``filename``.
        force: If True, download the data even if it already exists at
            ``dirpath/filename``; otherwise, only download if the data doesn't
            already exist on disk.

    Returns:
        Full path of file saved to disk.
    """
    if not filename:
        filename = get_filename_from_url(url)
    filepath = utils.to_path(dirpath).resolve() / filename
    if filepath.is_file() and force is False:
        LOGGER.info(
            "file '%s' already exists and force=False; skipping download...",
            filepath,
        )
        return None
    else:
        write_http_stream(url, filepath, mode="wb", make_dirs=True)
    return str(filepath)
def download_file ( url : str , * , filename : str = None , dirpath : types . PathLike = constants . DEFAULT_DATA_DIR , force : bool = False , ) -> Optional [ str ] : if not filename : filename = get_filename_from_url ( url ) filepath = utils . to_path ( dirpath ) . resolve ( ) / filename if filepath . is_file ( ) and force is False : LOGGER . info ( "file '%s' already exists and force=False; skipping download..." , filepath , ) return None else : write_http_stream ( url , filepath , mode = "wb" , make_dirs = True ) return str ( filepath )