cottax.consumers.json.interface module

JSON interface asks of a place type:

1.Spelling of places (PlaceCodec) and of node names (LabelCodec)

Of a feature type:

  1. Spelling of node kinds

class Spelling[T: NodeDefinition][source]

Bases: Answer, Generic[T]

NodeDefinition <-> JSON.

about

alias of NodeDefinition

kind: AbstractClassVar[str]

How it is referred to in the file.

checks_answer: PerLevel[tuple[Callable[[Any, tuple[Any, ...]], Iterable[Violation]], ...]] = (<function one_per_kind>,)

why answer is refused beside the answers already registered for its interface (a word two would share).

Type:

check(answer, registered)

abstractmethod write[V: Place](node: T, w: Writer[Any, V])[source]

The node’s fields; recursive through wrapped nodes (Driven/Implemented)

Return type:

dict

abstractmethod read[V: Place](data: dict, r: Reader[Any, V])[source]

The node data spells: recursive through wrapped nodes (Driven/Implemented)

Return type:

T

class PlaceCodec[V: Place][source]

Bases: Answer, Generic[V]

Place <-> JSON, for the place classes it answers for. tag names it in the file header.

about

alias of Place

tag: AbstractClassVar[str]

abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.

Type:

What the level binds in place of the annotation

checks_answer: PerLevel[tuple[Callable[[Any, tuple[Any, ...]], Iterable[Violation]], ...]] = (<function one_per_tag>,)

why answer is refused beside the answers already registered for its interface (a word two would share).

Type:

check(answer, registered)

abstractmethod write_place(place: V, w: Writer[Any, V])[source]

place; a value it holds (a Mint) through w.value.

Return type:

Json

abstractmethod read_place(data: Json, r: Reader[Any, V])[source]

The place data spells; a value it holds through r.value.

Return type:

V

class LabelCodec[N: Label][source]

Bases: Answer, Generic[N]

Node name <-> JSON, for the label classes it answers for. tag names it in the file header.

about: AbstractClassVar[Any] = Label

a class, a type alias of one, a protocol, or a tuple of those. @answers refuses a class that is none; a protocol is met by shape, which a class cannot be asked.

Type:

What the interface is answered per, bound by the interface

tag: AbstractClassVar[str]

abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.

Type:

What the level binds in place of the annotation

checks_answer: PerLevel[tuple[Callable[[Any, tuple[Any, ...]], Iterable[Violation]], ...]] = (<function one_per_tag>,)

why answer is refused beside the answers already registered for its interface (a word two would share).

Type:

check(answer, registered)

abstractmethod write_label(name: N, w: Writer[N, Any])[source]

name; a value it holds (a Mint) through w.value.

Return type:

Json

abstractmethod read_label(data: Json, r: Reader[N, Any])[source]

The node name data spells; a value it holds through r.value.

Return type:

N