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.CrsNameorgws.Duration) and then by type kind. Objects are returned asgws.Data. Some special types are converted, e.g. agws.CrsNameis read as an SRID and agws.Durationas 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.ConfigErrorInfoas the third argument.
- read(value, type_uid)¶
Read a value.
With the
verboseErrorsoption, the reader tracks its position in the value and adds agws.ConfigErrorInfoto 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.