transport_data.util.ckan.Resource

class transport_data.util.ckan.Resource(data: dict | None = None, **kwargs)[source]

Bases: ModelProxy

Proxy for ckan.model.Resource.

__init__(data: dict | None = None, **kwargs) None

Methods

__init__([data])

asdict()

Return the original dictionary of object data.

fetch([max_size])

Fetch the resource file and cache it locally.

from_file(path)

Construct a new instance from a file path.

get(name)

Return the value of a single field.

get_item(name[, index])

Get a member of a collection.

update(data)

Update part or all of the object data.

Attributes

id

Object 'id'.

name

Object 'name'.

hash

size

url

asdict() dict

Return the original dictionary of object data.

fetch(max_size: int = 10000000) Path

Fetch the resource file and cache it locally.

Parameters:

max_size – Maximum size of file to download.

Raises:

AssertionError – if the size of the file is equal to or greater than max_size.

classmethod from_file(path: pathlib.Path) T

Construct a new instance from a file path.

get(name: str)

Return the value of a single field.

get_item(name: str, index: int | None = None)

Get a member of a collection.

id: str | None = None

Object ‘id’. In the CKAN data model, this is often a uuid of some sort.

name: str = None

Object ‘name’. In the CKAN data model, this is often a snake-case string like “name-of-data-set”.

update(data: dict) None

Update part or all of the object data.