classResource#

class Resource(
urls: tuple[str, ...],
path: Path,
hashes: Mapping[str, str] = {},
size: int | None = None,
)#

A file to download: where from, where to, and how to verify it.

urls#

Download locations, tried in order.

Type:

tuple[str, …]

path#

The destination.

Type:

Path

hashes#

Expected digests keyed by algorithm name.

Type:

Mapping[str, str]

size#

The expected size in bytes, or None if unknown.

Type:

int | None

classmethod of(
url: str,
path: Path,
hashes: Mapping[str, str] | None = None,
size: int | None = None,
) → Resource#

Create a resource with one URL.

Parameters:
  • url (str) – The download location.

  • path (Path) – The destination.

  • hashes (Mapping[str, str] | None) – Expected digests keyed by algorithm name.

  • size (int | None) – The expected size in bytes, or None if unknown.

Returns:

The resource.

Return type:

Resource

is_present() → bool#

Return whether the destination already passes the size and hash checks.

With no size or hashes to check, any existing file counts as present.