sndata.utils.downloads¶
The downloads
module supports downloading data files in various file
formats.
-
sndata.utils.downloads.
download_file
(url: str, destination: Union[str, pathlib.Path, IO] = None, force: bool = False, timeout: float = 15, verbose: bool = True)[source]¶ Download content from a url to a file
If
destination
is a path but already exists, skip the download unlessforce
is alsoTrue
.Parameters: - url – URL of the file to download
- destination – Path or file object to download to
- force – Re-Download locally available data (Default: False)
- timeout – Seconds before raising timeout error (Default: 15)
- verbose – Print status to stdout
-
sndata.utils.downloads.
download_tar
(url: str, out_dir: str, mode: str = 'r:gz', force: bool = False, timeout: float = 15, skip_exists: str = None)[source]¶ Download and unzip a .tar.gz file to a given output directory
Parameters: - url – URL of the file to download
- out_dir – The directory to unzip file contents to
- mode – Compression mode (Default: r:gz)
- force – Re-Download locally available data (Default: False)
- timeout – Seconds before raising timeout error (Default: 15)
- skip_exists – Optionally skip the download if given path exists