DefValidator

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

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

Methods

DefValidator.__init__([def_dicts, hed_schema])

Initialize for definitions in HED strings.

DefValidator.add_definitions(def_dicts[, ...])

Add definitions from dict(s) or strings(s) to this dict.

DefValidator.check_for_definitions(...[, ...])

Check string for definition tags, adding them to self.

DefValidator.get(def_name)

Get the definition entry for the definition name.

DefValidator.get_as_strings(def_dict)

Convert the entries to strings of the contents

DefValidator.get_definition_entry(def_tag)

Get the entry for a given def tag.

DefValidator.items()

Return the dictionary of definitions.

DefValidator.validate_def_tags(hed_string_obj)

Validate Def/Def-Expand tags.

DefValidator.validate_def_value_units(...[, ...])

Equivalent to HedValidator.validate_units for the special case of a Def or Def-expand tag

DefValidator.validate_onset_offset(...)

Validate onset/offset

Attributes

DefValidator.issues

Return 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) or strings(s) to this dict.

Parameters:
  • def_dicts (list, DefinitionDict, dict, or str) – DefinitionDict or list of DefinitionDicts/strings/dicts whose definitions should be added.

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

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

Note - str or list of strings will parse the strings using the hed_schema. Note - You can mix and match types, eg [DefinitionDict, str, list of str] would be valid input.

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.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:

definition name and contents

Return type:

dict(str)

DefValidator.get_definition_entry(def_tag)

Get the entry for a given def tag.

Does not validate at all.

Parameters:

def_tag (HedTag) – Source HED tag that may be a Def or Def-expand tag.

Returns:

The definition entry if it exists

Return type:

def_entry(DefinitionEntry or None)

DefValidator.items()

Return 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, hed_validator=None)[source]

Validate Def/Def-Expand tags.

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

  • hed_validator (HedValidator) – Used to validate the placeholder replacement.

Returns:

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

Return type:

list

DefValidator.validate_def_value_units(def_tag, hed_validator, allow_placeholders=False)[source]

Equivalent to HedValidator.validate_units for the special case of a Def or Def-expand tag

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

Return issues about duplicate definitions.