DefValidator

class DefValidator(def_dicts=None, hed_schema=None)[source]

Handles validating Def/ and Def-expand/, as well as Temporal groups: Onset, Inset, and Offset

Methods

hed.validator.def_validator.DefValidator.__init__([...])

Initialize for definitions in hed strings.

hed.validator.def_validator.DefValidator.add_definitions(...)

Add definitions from dict(s) to this dict.

hed.validator.def_validator.DefValidator.check_for_definitions(...)

Check string for definition tags, adding them to self.

hed.validator.def_validator.DefValidator.construct_def_tag(hed_tag)

Identify def/def-expand tag contents in the given HedTag.

hed.validator.def_validator.DefValidator.construct_def_tags(...)

Identify def/def-expand tag contents in the given string.

hed.validator.def_validator.DefValidator.get(...)

Get the definition entry for the definition name.

hed.validator.def_validator.DefValidator.get_as_strings(...)

Convert the entries to strings of the contents

hed.validator.def_validator.DefValidator.items()

Returns the dictionary of definitions

hed.validator.def_validator.DefValidator.validate_def_tags(...)

Validate Def/Def-Expand tags.

hed.validator.def_validator.DefValidator.validate_onset_offset(...)

Validate onset/offset

Attributes

hed.validator.def_validator.DefValidator.issues

Returns issues about duplicate definitions.

DefValidator.__init__(def_dicts=None, hed_schema=None)[source]

Initialize for definitions in hed strings.

Parameters:
  • def_dicts (list or DefinitionDict or str) – DefinitionDicts containing the definitions to pass to baseclass

  • hed_schema (HedSchema or None) – Required if passing strings or lists of strings, unused otherwise.

DefValidator.add_definitions(def_dicts, hed_schema=None)

Add definitions from dict(s) to this dict.

Parameters:
  • def_dicts (list, DefinitionDict, or dict) –

    DefinitionDict or list of DefinitionDicts/strings/dicts whose

    definitions should be added.

    Note dict form expects DefinitionEntries in the same form as a DefinitionDict

  • hed_schema (HedSchema or None) – Required if passing strings or lists of strings, unused otherwise.

Raises:

TypeError

  • Bad type passed as def_dicts

DefValidator.check_for_definitions(hed_string_obj, error_handler=None)

Check string for definition tags, adding them to self.

Parameters:
  • hed_string_obj (HedString) – A single hed string to gather definitions from.

  • error_handler (ErrorHandler or None) – Error context used to identify where definitions are found.

Returns:

List of issues encountered in checking for definitions. Each issue is a dictionary.

Return type:

list

DefValidator.construct_def_tag(hed_tag)

Identify def/def-expand tag contents in the given HedTag.

Parameters:

hed_tag (HedTag) – The hed tag to identify definition contents in

DefValidator.construct_def_tags(hed_string_obj)

Identify def/def-expand tag contents in the given string.

Parameters:

hed_string_obj (HedString) – The hed string to identify definition contents in

DefValidator.get(def_name)

Get the definition entry for the definition name.

Not case-sensitive

Parameters:

def_name (str) – Name of the definition to retrieve.

Returns:

Definition entry for the requested definition.

Return type:

DefinitionEntry

static DefValidator.get_as_strings(def_dict)

Convert the entries to strings of the contents

Parameters:

def_dict (DefinitionDict or dict) – A dict of definitions

Returns:

str): definition name and contents

Return type:

dict(str

DefValidator.items()

Returns the dictionary of definitions

Alias for .defs.items()

Returns:

DefinitionEntry}): A list of definitions

Return type:

def_entries({str

DefValidator.validate_def_tags(hed_string_obj, tag_validator=None)[source]

Validate Def/Def-Expand tags.

Parameters:
  • hed_string_obj (HedString) – The hed string to process.

  • tag_validator (TagValidator) – Used to validate the placeholder replacement.

Returns:

Issues found related to validating defs. Each issue is a dictionary.

Return type:

list

DefValidator.validate_onset_offset(hed_string_obj)[source]

Validate onset/offset

Parameters:

hed_string_obj (HedString) – The hed string to check.

Returns:

A list of issues found in validating onsets (i.e., out of order onsets, unknown def names).

Return type:

list

DefValidator.issues

Returns issues about duplicate definitions.