Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
**Progress bar** for the download can be printed by
:class:`pooch.HTTPDownloader` by passing the argument
``progressbar=True``:
.. code:: python
progress_download = HTTPDownloader(progressbar=True)
mypooch.fetch("some-data-file.txt", downloader=progress_download)
# Will print a progress bar to standard error like:
# 100%|█████████████████████████████████████████| 336/336 [...]
"""
self._assert_file_in_registry(fname)
# Create the local data directory if it doesn't already exist
make_local_storage(str(self.abspath))
url = self.get_url(fname)
full_path = self.abspath / fname
known_hash = self.registry[fname]
action, verb = download_action(full_path, known_hash)
if action in ("download", "update"):
get_logger().info(
"%s file '%s' from '%s' to '%s'.", verb, fname, url, str(self.abspath),
)
if downloader is None:
downloader = choose_downloader(url)
stream_download(url, full_path, known_hash, downloader, pooch=self)
... print(f.read().strip())
# A tiny data file for test purposes only
1 2 3 4 5 6
>>> for f in fnames:
... os.remove(f)
"""
if path is None:
path = os_cache("pooch")
if fname is None:
fname = unique_file_name(url)
# Create the local data directory if it doesn't already exist and make the
# path absolute.
path = cache_location(path, env=None, version=None)
make_local_storage(path)
full_path = path.resolve() / fname
action, verb = download_action(full_path, known_hash)
if action in ("download", "update"):
get_logger().info(
"%s data from '%s' to file '%s'.", verb, url, str(full_path),
)
if downloader is None:
downloader = choose_downloader(url)
stream_download(url, full_path, known_hash, downloader, pooch=None)
if known_hash is None:
get_logger().info(