schema_validation_util

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

Functions

get_allowed_characters(value_classes)

Returns the allowed characters in a given container of value classes

get_allowed_characters_by_name(...)

Returns the allowed characters from a list of character set names

get_problem_indexes(validation_string, ...)

Finds indexes with values not in character set

schema_version_for_library(hed_schema, ...)

Given the library name and hed schema object, return the version

validate_schema_description_new(hed_entry)

Check the description of the entry for invalid character issues

validate_schema_tag_new(hed_entry)

Check tag entry for capitalization and illegal characters.

validate_schema_term_new(hed_entry[, hed_term])

Check the term for invalid character issues

get_allowed_characters(value_classes)[source]

Returns the allowed characters in a given container of value classes

Parameters:

value_classes (list of HedSchemaEntry) – A list of schema entries that should have the allowedCharacter attribute

Returns:

The set of all characters from the given classes

Return type:

character_set(set)

get_allowed_characters_by_name(character_set_names)[source]

Returns the allowed characters from a list of character set names

Note: “nonascii” is a special case “character” that can be included as well

Parameters:

character_set_names (list of str) – A list of character sets to allow. See hed_schema_constants.character_types

Returns:

The set of all characters from the names

Return type:

character_set(set)

get_problem_indexes(validation_string, character_set, index_adj=0)[source]

Finds indexes with values not in character set

Parameters:
  • validation_string (str) – The string to check characters in

  • character_set (set) – the list of valid characters(or the value “nonascii” as a set entry)

  • index_adj (int) – the value to adjust the reported indices by, if this isn’t the start of a string.

Returns:

The list of problematic characters and indices

Return type:

index_list(tuple of (str, int))

schema_version_for_library(hed_schema, library_name)[source]

Given the library name and hed schema object, return the version

Parameters:
  • hed_schema (HedSchema) – the schema object

  • library_name (str or None) – The library name you’re interested in. “” for the standard schema.

Returns:

The version number of the given library name. Returns None if unknown library_name.

Return type:

version_number (str)

validate_schema_description_new(hed_entry)[source]

Check the description of the entry for invalid character issues

Parameters:

hed_entry (HedSchemaEntry) – A single schema entry

Returns:

A list of all invalid characters found in description. Each issue is a dictionary.

Return type:

list

validate_schema_tag_new(hed_entry)[source]

Check tag entry for capitalization and illegal characters.

Parameters:

hed_entry (HedTagEntry) – A single tag entry

Returns:

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

Return type:

list

validate_schema_term_new(hed_entry, hed_term=None)[source]

Check the term for invalid character issues

Parameters:
  • hed_entry (HedSchemaEntry) – A single schema entry

  • hed_term (str or None) – Use instead of hed_entry.name if present.

Returns:

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

Return type:

list