schema_salad.validate

Attributes

INT_MIN_VALUE

INT_MAX_VALUE

LONG_MIN_VALUE

LONG_MAX_VALUE

saladp

primitives

Exceptions

ClassValidationException

Indicates error with document against the provided schema.

SchemaSaladException

Base class for all schema-salad exceptions.

ValidationException

Indicates error with document against the provided schema.

Classes

Schema

Base class for all Schema classes.

SourceLine

Functions

validate(expected_schema, datum[, identifiers, ...])

avro_shortname(name)

Produce an avro friendly short name.

avro_type_name(url)

Turn a URL into an Avro-safe name.

friendly(v)

Format an Avro schema into a pretty-printed representation.

vpformat(datum)

Truncate a pretty-printed representation of a Python object to 160 characters.

validate_ex(expected_schema, datum[, identifiers, ...])

Determine if a python datum is an instance of a schema.

Module Contents

class schema_salad.validate.Schema(atype, other_props=None)

Base class for all Schema classes.

Parameters:
  • atype (str)

  • other_props (Optional[PropsType])

property props: PropsType
Return type:

PropsType

get_prop(key)
Parameters:

key (str)

Return type:

Optional[PropType]

set_prop(key, value)
Parameters:
  • key (str)

  • value (Optional[PropType])

Return type:

None

exception schema_salad.validate.ClassValidationException(msg, sl=None, children=None, bullet_for_children='')

Bases: ValidationException

digraph inheritance76a5ce2784 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ClassValidationException" [URL="../exceptions/index.html#schema_salad.exceptions.ClassValidationException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ValidationException" -> "ClassValidationException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaSaladException" [URL="../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all schema-salad exceptions."]; "ValidationException" [URL="../exceptions/index.html#schema_salad.exceptions.ValidationException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Indicates error with document against the provided schema."]; "SchemaSaladException" -> "ValidationException" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Indicates error with document against the provided schema.

Parameters:
exception schema_salad.validate.SchemaSaladException(msg, sl=None, children=None, bullet_for_children='')

Bases: Exception

digraph inheritancee65ab93aef { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "SchemaSaladException" [URL="../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all schema-salad exceptions."]; }

Base class for all schema-salad exceptions.

Parameters:
propagate_sourceline()
Return type:

None

as_warning()
Return type:

SchemaSaladException

with_sourceline(sl)
Parameters:

sl (Optional[schema_salad.sourceline.SourceLine])

Return type:

SchemaSaladException

leaves()
Return type:

List[SchemaSaladException]

prefix()
Return type:

str

summary(level=0, with_bullet=False)
Parameters:
Return type:

str

__str__()

Convert to a string using pretty_str().

Return type:

str

pretty_str(level=0)
Parameters:

level (int)

Return type:

str

exception schema_salad.validate.ValidationException(msg, sl=None, children=None, bullet_for_children='')

Bases: SchemaSaladException

digraph inheritancecb0097729f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "SchemaSaladException" [URL="../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all schema-salad exceptions."]; "ValidationException" [URL="../exceptions/index.html#schema_salad.exceptions.ValidationException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Indicates error with document against the provided schema."]; "SchemaSaladException" -> "ValidationException" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Indicates error with document against the provided schema.

Parameters:
class schema_salad.validate.SourceLine(item, key=None, raise_type=str, include_traceback=False)
Parameters:
  • item (Any)

  • key (Optional[Any])

  • raise_type (Callable[[str], Any])

  • include_traceback (bool)

__enter__()
Return type:

SourceLine

__exit__(exc_type, exc_value, tb)
Parameters:
  • exc_type (Any)

  • exc_value (Any)

  • tb (Any)

Return type:

None

file()
Return type:

Optional[str]

start()
Return type:

Optional[Tuple[int, int]]

end()
Return type:

Optional[Tuple[int, int]]

makeLead()
Return type:

str

makeError(msg)
Parameters:

msg (str)

Return type:

Any

schema_salad.validate.validate(expected_schema, datum, identifiers=None, strict=False, foreign_properties=None, vocab=None)
Parameters:
Return type:

bool

schema_salad.validate.INT_MIN_VALUE
schema_salad.validate.INT_MAX_VALUE
schema_salad.validate.LONG_MIN_VALUE
schema_salad.validate.LONG_MAX_VALUE
schema_salad.validate.avro_shortname(name)

Produce an avro friendly short name.

Parameters:

name (str)

Return type:

str

schema_salad.validate.saladp = 'https://w3id.org/cwl/salad#'
schema_salad.validate.primitives
schema_salad.validate.avro_type_name(url)

Turn a URL into an Avro-safe name.

If the URL has no fragment, return this plain URL.

Extract either the last part of the URL fragment past the slash, otherwise the whole fragment.

Parameters:

url (str)

Return type:

str

schema_salad.validate.friendly(v)

Format an Avro schema into a pretty-printed representation.

Parameters:

v (Any)

Return type:

Any

schema_salad.validate.vpformat(datum)

Truncate a pretty-printed representation of a Python object to 160 characters.

Parameters:

datum (Any)

Return type:

str

schema_salad.validate.validate_ex(expected_schema, datum, identifiers=None, strict=False, foreign_properties=None, raise_ex=True, strict_foreign_properties=False, logger=_logger, skip_foreign_properties=False, vocab=None)

Determine if a python datum is an instance of a schema.

Parameters:
Return type:

bool