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
(yaml_file, 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.
-
-
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 interpreted 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)¶ Initialize self. See help(type(self)) for accurate 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
(yaml_file, 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.
-
-
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
- defn : class
- Class containing attributes to check.
- e.g CmdDefn, ArgDef
-
-
class
ait.core.val.
ValidationRule
(attr, msg=None, messages=[])¶ Bases:
object
-
__init__
(attr, msg=None, messages=[])¶ Initialize self. See help(type(self)) for accurate 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
-
content_val
(yaml_file, ymldata=None, messages=None)¶ Simple base content_val method - needed for unit tests
-
get_included_files
(yml_file)¶ Make a list of yaml files to validate against the schema. The first member of the list will include the full path to the yaml file. The next element will the module yml file (e.g. cmd.yml), followed by the names of any included files. The assumption is made that all the included yml files are found in the same directory as the module yml file.
- yml_file : str
- The module yaml file to validate (cmd.yml or tlm.yml)
- self.validate_list: list
- A set of all files that are to be validated.
-
schema_val
(messages=None)¶ Perform validation with processed YAML and Schema
-
validate
(ymldata=None, messages=None)¶ Validates the Command or Telemetry Dictionary definitions The method will validate module (cmd.yml or tlm.yaml) and included yaml config files
- schema_val boolean:
- The result of the schema test (True/False)
- content_val boolean:
- Results of the schema test on config and included files
- True - all the tested yaml files passed the schema test False - one or more yaml files did not pass the schema test
-
validate_schema
(messages=None)¶ Provides schema_val validation for objects that do not override in domain-specific validator (evr.yaml, table.yaml, limits.yaml)
- valid boolean:
- The result of the schema test (True(Pass)/False(Fail))
-
ehandler
¶
-
validate_list
¶
-
yml_dir
¶
-
yml_files_to_validate
¶
-
-
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
¶
-