のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

untar_data

def untar_data(
  url:str,
  fname:PathOrStr=None,
 dest:PathOrStr=None, 
 data=True, 
 force_download=False) -> Path:

    "Download `url` to `fname` if it doesn't exist, and un-tgz to folder `dest`."

    dest = url2path(url, data) if dest is None else Path(dest)/url2name(url)
    fname = Path(ifnone(fname, _url2tgz(url, data)))
    if force_download or (fname.exists() and url in _checks and _check_file(fname) != _checks[url]):
        print(f"A new version of the {'dataset' if data else 'model'} is available.")
        os.remove(fname)
        shutil.rmtree(dest)
    if not dest.exists():
        fname = download_data(url, fname=fname, data=data)
        data_dir = Config().data_path()
        if url in _checks:
            assert _check_file(fname) == _checks[url], f"Downloaded file {fname} does not match checksum expected! Remove that file from {data_dir} and try your code again."
        tarfile.open(fname, 'r:gz').extractall(dest.parent)
    return dest

fastai/datasets.py at master · fastai/fastai · GitHub
https://docs.fast.ai/datasets.html#untar_data

"->" アノテーション

qiita.com

この、Pathは、PathlibのPathなのかな?
docs.python.jp