geestac.custom_types#

Custom types.

Attributes#

Classes#

ListNamespace

A Namespace to store objects with a unique attribute (key).

Module Contents#

class geestac.custom_types.ListNamespace(*args, key)[source]#

Bases: Generic[T]

A Namespace to store objects with a unique attribute (key).

If the value of the key is not suitable for an attribute, it’ll be converted with format_attribute function. The values of the keys must be unique, else the first occurrence will be kept.

Parameters:
  • args (T) – a list of objects.

  • key (str) – the attribute of the object to get the key from.

__getitem__(index)[source]#

Get item from ListNamepace.

Parameters:

index (int | str) – index of the element in the ListNamespace.

__iter__()[source]#

Iterator.

__len__()[source]#

Length of the ListNamespace.

__repr__()[source]#

Object representation.

__setattr__(key, value)[source]#

Set attribute to this object.

Parameters:
  • key (str)

  • value (Any)

_append(obj)[source]#

Append an object to the list.

Parameters:

obj (T)

as_dict(value=None)[source]#

ListNamespace as a dict.

Parameters:

value (str | None) – attribute of the object to use as value.

Return type:

dict

as_list(key=None)[source]#

ListNamespace as list.

Parameters:

key (str | None) – attribute of the object to put in the list. If None it will put the objects in the list.

Return type:

list

is_empty()[source]#

Is this object empty?.

Return type:

bool

keys()[source]#

Key values as list.

Return type:

list

_args: List[T] = [][source]#
_key[source]#
geestac.custom_types.T[source]#
geestac.custom_types.logger[source]#