cartopy.io.Downloader#

class cartopy.io.Downloader(url_template, target_path_template, pre_downloaded_path_template='')[source]#

Represents a resource, that can be configured easily, which knows how to acquire itself (perhaps via HTTP).

The key interface method is path() - typically all external calls will be made to that method. To get hold of an appropriate Downloader instance the Downloader.from_config() static method should be considered.

Parameters:
  • url_template – The template of the full URL representing this resource.

  • target_path_template – The template of the full path to the file that this Downloader represents. Typically the path will be a subdirectory of config['data_dir'], but this is not a strict requirement. If the file does not exist when calling Downloader.path() it will be downloaded to this location.

  • pre_downloaded_path_template (optional) – The template of a full path of a file which has been downloaded outside of this Downloader which should be used as the file that this resource represents. If the file does not exist when Downloader.path() is called it will not be downloaded to this location (unlike the target_path_template argument).

Note

All *_template arguments should be formattable using the standard string.format() rules. The formatting itself is not done until a call to a subsequent method (such as Downloader.path()).

__init__(url_template, target_path_template, pre_downloaded_path_template='')[source]#

Methods

__init__(url_template, target_path_template)

acquire_resource(target_path, format_dict)

Download, via HTTP, the file that this resource represents.

from_config(specification[, config_dict])

The from_config static method implements the logic for acquiring a Downloader (sub)class instance from the config dictionary.

path(format_dict)

Returns the path to a file on disk that this resource represents.

pre_downloaded_path(format_dict)

The path on disk of the file that this resource represents, if it does not exist, then no further action will be taken with this path, and all further processing will be done using target_path() instead.

target_path(format_dict)

The path on disk of the file that this resource represents, must either exist, or be writable by the current user.

url(format_dict)

The full URL that this resource represents.

Attributes

FORMAT_KEYS

The minimum keys which should be provided in the format_dict argument for the path, url, target_path, pre_downloaded_path and acquire_resource methods.