ait.core.val module

AIT YAML Validator

The ait.core.val module provides validation of content for YAML files based on specified schema.

class ait.core.val.ByteOrderRule(attr, msg, messages=[])

Bases: ait.core.val.ValidationRule

Checks the byte ordering based on the previous set stop byte/bit

__init__(attr, msg, messages=[])

Takes in an attribute name, error message, and list of error messages to append to

check(defn, msg=None)

Uses the definitions slice() method to determine its start/stop range.

class ait.core.val.CmdValidator(ymlfile=None, schema=None)

Bases: ait.core.val.Validator

__init__(ymlfile=None, schema=None)

Creates a new YAML validator for the given schema and yaml file

The schema file should validate against JSON Schema Draft 4 http://json-schema.org/latest/json-schema-core.html

The YAML file should validate against the schema file given

content_val(ymldata=None, messages=None)

Validates the Command Dictionary to ensure the contents for each of the fields meets specific criteria regarding the expected types, byte ranges, etc.

validate(ymldata=None, messages=None)

Validates the Command Dictionary definitions

class ait.core.val.EnumRule(attr, msg, messages=[])

Bases: ait.core.val.ValidationRule

Checks all enumerated values do not contain boolean keys. The YAML standard has a set of allowable boolean strings that are interpretted as boolean True/False unless explicitly quoted in the YAML file. The YAML boolean strings include (TRUE/FALSE/ON/OFF/YES/NO) .

__init__(attr, msg, messages=[])

Takes in an attribute name, error message, and list of error messages to append to

check(defn, msg=None)
class ait.core.val.ErrorHandler(error=None, ymlfile=None, schemafile=None)

Bases: object

ErrorHandler class

Leverages the jsonschema.exceptions.ValidationError API in order to extract useful information from the error to provide more detail on the root cause of the error.

Refer to http://python-jsonschema.readthedocs.io/en/latest/errors/ for more information on JSON Schema errors.

__init__(error=None, ymlfile=None, schemafile=None)

x.__init__(…) initializes x; see help(type(x)) for signature

pretty(start, end, e, messages=None)

Pretties up the output error message so it is readable and designates where the error came from

process(docnum, doclines, error, messages=None)
doclines
error
messages
schemafile
ymlfile
class ait.core.val.SchemaProcessor(schemafile=None)

Bases: object

__init__(schemafile=None)

Creates a new YAML validator for the given schema and yaml file

The schema file should validate against JSON Schema Draft 4 http://json-schema.org/latest/json-schema-core.html

The YAML file should validate against the schema file given

load(schemafile=None)

Load and process the schema file

data
loaded
schemafile
class ait.core.val.TlmValidator(ymlfile=None, schema=None)

Bases: ait.core.val.Validator

__init__(ymlfile=None, schema=None)

Creates a new YAML validator for the given schema and yaml file

The schema file should validate against JSON Schema Draft 4 http://json-schema.org/latest/json-schema-core.html

The YAML file should validate against the schema file given

content_val(ymldata=None, messages=None)

Validates the Telemetry Dictionary to ensure the contents for each of the fields meets specific criteria regarding the expected types, byte ranges, etc.

validate(ymldata=None, messages=None)

Validates the Telemetry Dictionary definitions

class ait.core.val.TypeRule(attr, msg, messages=[])

Bases: ait.core.val.ValidationRule

Checks the object’s type is an allowable types

__init__(attr, msg, messages=[])

Takes in an attribute name, error message, and list of error messages to append to

check(defn)

Performs isinstance check for the definitions data type.

Assumes the defn has ‘type’ and ‘name’ attributes

class ait.core.val.TypeSizeRule(attr, msg, messages=[])

Bases: ait.core.val.ValidationRule

Checks the object size matches the designated type

__init__(attr, msg, messages=[])

Takes in an attribute name, error message, and list of error messages to append to

check(defn, msg=None)

Uses the byte range in the object definition to determine the number of bytes and compares to the size defined in the type.

Assumes the defn has ‘type’ and ‘name’ attributes, and a slice() method

class ait.core.val.UniquenessRule(attr, msg, messages=[])

Bases: ait.core.val.ValidationRule

Checks the uniqueness of an attribute across YAML documents

__init__(attr, msg, messages=[])

Takes in an attribute name, error message, and list of error messages to append to

check(defn)

Performs the uniqueness check against the value list maintained in this rule objects

class ait.core.val.ValidationRule(attr, msg=None, messages=[])

Bases: object

__init__(attr, msg=None, messages=[])

x.__init__(…) initializes x; see help(type(x)) for signature

class ait.core.val.Validator(ymlfile, schemafile)

Bases: object

__init__(ymlfile, schemafile)

Creates a new YAML validator for the given schema and yaml file

The schema file should validate against JSON Schema Draft 4 http://json-schema.org/latest/json-schema-core.html

The YAML file should validate against the schema file given

schema_val(messages=None)

Perform validation with processed YAML and Schema

validate(messages=None)

Provides schema_val validation for objects that do not override in domain-specific validator

ehandler
class ait.core.val.YAMLProcessor(ymlfile=None, clean=True)

Bases: object

__init__(ymlfile=None, clean=True)

Creates a new YAML validator for the given schema and yaml file

The schema file should validate against JSON Schema Draft 4 http://json-schema.org/latest/json-schema-core.html

The YAML file should validate against the schema file given

load(ymlfile=None)

Load and process the YAML file

process(ymlfile)

Cleans out all document tags from the YAML file to make it JSON-friendly to work with the JSON Schema.

data
doclines
loaded
ymlfile