How to use the pooch.downloaders.choose_downloader function in pooch

To help you get started, we’ve selected a few pooch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fatiando / pooch / pooch / core.py View on Github external
# 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)

        if processor is not None:
            return processor(str(full_path), action, self)

        return str(full_path)
github fatiando / pooch / pooch / core.py View on Github external
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(
                "SHA256 hash of downloaded file: %s\n"
                "Use this value as the 'known_hash' argument of 'pooch.retrieve'"
                " to ensure that the file hasn't changed if it is downloaded again"
                " in the future.",
                file_hash(str(full_path)),
            )

    if processor is not None:
        return processor(str(full_path), action, None)

    return str(full_path)