目录
当前位置: 首页 > 文档资料 > Edward 中文文档 >

observations.maybe_download_and_extract

优质
小牛编辑
123浏览
2023-12-01
maybe_download_and_extract(
    path,
    url,
    extract=True,
    hash_true=None,
    resume=True,
    save_file_name=None
)

Download file from url unless it already exists in specified directory. Extract the file if extract is True.

The file at url is downloaded to the directory path with its original filename. For example, with url http://example.org/example.txt and path ~/data, the downloaded file is located at ~/data/example.txt.

Args:

  • path: str. Path to directory which either stores file or otherwise file will be downloaded and extracted there.
  • url: str. URL to download from if file doesn’t exist.
  • extract: bool, optional. If True, tries to extract the file if it has format ‘gz’, ‘tar’ (including ‘tar.gz’ and ‘tar.bz’), or ‘zip’.
  • hash_true: str, optional. Hash (md5 or otherwise) string of the remote file to be downloaded.
  • resume: bool, optional. If True, tries to resume partial downloads (if supported by server).
  • save_file_name: str, optional. Save to specified file name, else derives from URL path.

Returns:

str. Path to downloaded or already existing file.