roboto.domain.files.file_downloader#
Module Contents#
- class roboto.domain.files.file_downloader.FileDownloader(roboto_client)#
A utility for downloading Roboto files.
- Parameters:
roboto_client (Optional[roboto.http.roboto_client.RobotoClient])
- download_files(out_path, files)#
Downloads the specified files to the provided local directory.
The files could come from different datasets. All that is required is that the caller have appropriate file download permissions.
An example use case is downloading files that are results of a search query:
>>> import pathlib >>> from roboto import RobotoSearch >>> from roboto.domain.files import FileDownloader >>> >>> roboto_search = RobotoSearch() >>> file_downloader = FileDownloader() >>> >>> downloaded = file_downloader.download_files( ... out_path=pathlib.Path("/dest/path"), ... files=roboto_search.find_files('tags CONTAINS "CSV"') ... ) >>> >>> for file, path in downloaded: ... # Process the file
- Parameters:
out_path (pathlib.Path) – Destination directory for the downloaded files. It is created if it doesn’t exist.
files (collections.abc.Iterable[roboto.domain.files.file.File]) – Files to download.
- Returns:
A list of (
File
,Path
) tuples, relating each provided file to its download path.- Return type:
list[tuple[roboto.domain.files.file.File, pathlib.Path]]