schema_validation_util

Utilities used in HED validation/loading using a HED schema.

Functions

find_rooted_entry(tag_entry, schema, ...)

This semi-validates rooted tags, raising an exception on major errors

validate_attributes(attrib_dict, filename)

Validate attributes in the dictionary.

validate_library_name(library_name)

Check the validity of the library name.

validate_present_attributes(attrib_dict, ...)

Validate combinations of attributes

validate_schema_description(tag_name, ...)

Check the description of a single schema term.

validate_schema_term(hed_term)

Check short tag for capitalization and illegal characters.

validate_version_string(version_string)

Check validity of the version.

find_rooted_entry(tag_entry, schema, loading_merged)[source]

This semi-validates rooted tags, raising an exception on major errors

Parameters:
  • tag_entry (HedTagEntry) – the possibly rooted tag

  • schema (HedSchema) – The schema being loaded

  • loading_merged (bool) – If this schema was already merged before loading

Returns:

The base tag entry from the standard schema

Returns None if this tag isn’t rooted

Return type:

rooted_tag(HedTagEntry or None)

Raises:

HedFileError

  • A rooted attribute is found in a non-paired schema

  • A rooted attribute is not a string

  • A rooted attribute was found on a non-root node in an unmerged schema.

  • A rooted attribute is found on a root node in a merged schema.

  • A rooted attribute indicates a tag that doesn’t exist in the base schema.

validate_attributes(attrib_dict, filename)[source]

Validate attributes in the dictionary.

Parameters:
  • attrib_dict (dict) – Dictionary of attributes to be evaluated.

  • filename (str) – File name to use in reporting errors.

Returns:

List of issues. Each issue is a dictionary.

Return type:

list

Raises:

HedFileError

  • Invalid library name

  • Version not present

  • Invalid combinations of attributes in header

validate_library_name(library_name)[source]

Check the validity of the library name.

Parameters:

library_name (str) – Name of the library.

Returns:

If not False, string indicates the issue.

Return type:

bool or str

validate_present_attributes(attrib_dict, filename)[source]

Validate combinations of attributes

Parameters:
  • attrib_dict (dict) – Dictionary of attributes to be evaluated.

  • filename (str) – File name to use in reporting errors.

Returns:

List of issues. Each issue is a dictionary.

Return type:

list

Raises:

HedFileError

  • withStandard is found in th header, but a library attribute is not specified

validate_schema_description(tag_name, hed_description)[source]

Check the description of a single schema term.

Parameters:
  • tag_name (str) – A single hed tag - not validated here, just used for error messages.

  • hed_description (str) – The description string to validate.

Returns:

A list of all formatting issues found in the description.

Return type:

list

validate_schema_term(hed_term)[source]

Check short tag for capitalization and illegal characters.

Parameters:

hed_term (str) – A single hed term.

Returns:

A list of all formatting issues found in the term. Each issue is a dictionary.

Return type:

list

validate_version_string(version_string)[source]

Check validity of the version.

Parameters:

version_string (str) – A version string.

Returns:

If not False, string indicates the issue.

Return type:

bool or str