sign_language_translator.utils.download module
Module for downloading files from URLs and managing package resources.
This module provides functions for downloading files from specified URLs and saving them to the given file paths. It also includes a function for downloading package resources matching a specified filename regex and saving them to the appropriate file paths.
Functions: - download(file_path, url, overwrite=False, progress_bar=False, timeout=20.0, chunk_size=65536):
Downloads a file from the specified URL and saves it to the given file path.
- download_package_resource(filename_regex, overwrite=False, progress_bar=False, timeout=20.0):
Downloads package resources matching the given filename regex and saves them to the appropriate file paths.
- sign_language_translator.utils.download.download(file_path: str, url: str, overwrite=False, progress_bar=False, timeout: float = 20.0, leave=True, chunk_size=65536, status_callback=None) bool[source]
Downloads a file from the specified URL and saves it to the given file path.
- Parameters:
file_path (str) – The path where the downloaded file will be saved.
url (str) – The URL of the file to be downloaded.
overwrite (bool, optional) – If False, skips downloading if the file already exists. Defaults to False.
progress_bar (bool, optional) – If True, displays a progress bar during the download. Defaults to False.
timeout (int, optional) – The maximum number of seconds to wait for a server response. Defaults to 20.0.
leave (bool, optional) – Wether to leave the progress bar behind after the download. Defaults to True.
chunk_size (int, optional) – The number of bytes to fetch in each step. Defaults to 65536.
- Returns:
True if the file is downloaded successfully, False otherwise.
- Return type:
bool
- Raises:
FileExistsError – if overwrite is False and the destination path already contains a file.