transport_data.util.ckan.ModelProxy

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

Bases: object

Simple proxy for a CKAN object/model.

ckan itself is a Python package, but is a ‘heavy’ dependency—a large package with many dependencies. ModelProxy allows to interact with the different classes of CKAN objects based on the JSON data returned by the CKAN Action API, without a dependency on ckan itself.

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

Methods

__init__([data])

asdict()

Return the original dictionary of object data.

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'.

asdict() dict

Return the original dictionary of object data.

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 = 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.