gws.spec.reader

Read and validate values according to spec types.

Source code: gws.spec.reader

Module Contents

class gws.spec.reader.Reader(runtime, path, options)

Reads a raw value against a spec type and returns the parsed value.

Readers are selected first by type uid (built-in atoms and special types like gws.CrsName or gws.Duration) and then by type kind. Objects are returned as gws.Data. Some special types are converted, e.g. a gws.CrsName is read as an SRID and a gws.Duration as seconds.

accept_extra_props
allow_skip_required
atom

Placeholder type passed to readers of types that are not in the specs.

case_insensitive
convert_values
ignore_extra_props
path
pop
push
runtime
stack = None
verbose_errors
add_config_error_info(exc: Exception)

Add the value and the read stack to a read error.

Parameters:

exc – Read error with the message and the value as arguments.

Returns:

The same exception with a gws.ConfigErrorInfo as the third argument.

read(value, type_uid)

Read a value.

With the verboseErrors option, the reader tracks its position in the value and adds a gws.ConfigErrorInfo to the error.

Parameters:
  • value – Raw value.

  • type_uid – Type uid or extension name.

Returns:

The parsed value.

Raises:

core.ReadError – If the value does not match the type.

read2(value, type_uid)

Read a value without adding error information, used recursively by the readers.

Parameters:
  • value – Raw value.

  • type_uid – Type uid or extension name.

Returns:

The parsed value.

Raises:

core.ReadError – If the value does not match the type or the type is unknown.