wags_tails.utils.downloads#
Provide helper functions for downloading data.
- wags_tails.utils.downloads.handle_zip(dl_path, outfile_path)[source]#
Extract the largest file within a given zipfile and save it within the appropriate data directory. Can be passed as a callback to a downloader method.
- Parameters:
dl_path (
Path
) – path to temp data fileoutfile_path (
Path
) – path to save file within
- Return type:
None
- wags_tails.utils.downloads.handle_gzip(dl_path, outfile_path)[source]#
Extract file from gzip. Can be passed as a callback to a downloader method.
- Parameters:
dl_path (
Path
) – path to temp data fileoutfile_path (
Path
) – path to save file within
- Return type:
None
- wags_tails.utils.downloads.download_ftp(host, host_directory_path, host_filename, outfile_path, handler=None, tqdm_params=None)[source]#
Perform FTP download of remote data file.
- Parameters:
host (
str
) – FTP hostnamehost_directory_path (
str
) – path to desired file on hosthost_filename (
str
) – name of desired file on hostoutfile_path (
Path
) – path to where file should be saved. Must be an actual Path instance rather than merely a pathlike string.handler (
Optional
[Callable
[[Path
,Path
],None
]]) – provide if downloaded file requires additional action, e.g. it’s a zip filetqdm_params (
Optional
[Dict
]) – Optional TQDM configuration.
- Return type:
None
- wags_tails.utils.downloads.download_http(url, outfile_path, headers=None, handler=None, tqdm_params=None)[source]#
Perform HTTP download of remote data file.
- Parameters:
url (
str
) – URL to retrieve file fromoutfile_path (
Path
) – path to where file should be saved. Must be an actual Path instance rather than merely a pathlike string.headers (
Optional
[Dict
]) – Any needed HTTP headers to include in requesthandler (
Optional
[Callable
[[Path
,Path
],None
]]) – provide if downloaded file requires additional action, e.g. it’s a zip file.tqdm_params (
Optional
[Dict
]) – Optional TQDM configuration.
- Return type:
None