DefinitionDict

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

Gathers definitions from a single source.

Methods

DefinitionDict.__init__([def_dicts, hed_schema])

Definitions to be considered a single source.

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

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

DefinitionDict.check_for_definitions(...[, ...])

Check string for definition tags, adding them to self.

DefinitionDict.get(def_name)

Get the definition entry for the definition name.

DefinitionDict.get_as_strings(def_dict)

Convert the entries to strings of the contents

DefinitionDict.get_definition_entry(def_tag)

Get the entry for a given def tag.

DefinitionDict.items()

Return the dictionary of definitions.

Attributes

DefinitionDict.issues

Return issues about duplicate definitions.

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

Definitions to be considered a single source.

Parameters:
  • def_dicts (str or list or DefinitionDict) – DefDict or list of DefDicts/strings or a single string whose definitions should be added.

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

Raises:

TypeError

  • Bad type passed as def_dicts.

DefinitionDict.add_definitions(def_dicts, hed_schema=None)[source]

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.

DefinitionDict.check_for_definitions(hed_string_obj, error_handler=None)[source]

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

DefinitionDict.get(def_name)[source]

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 DefinitionDict.get_as_strings(def_dict)[source]

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)

DefinitionDict.get_definition_entry(def_tag)[source]

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)

DefinitionDict.items()[source]

Return the dictionary of definitions.

Alias for .defs.items()

Returns:

DefinitionEntry}): A list of definitions.

Return type:

def_entries({str

DefinitionDict.issues

Return issues about duplicate definitions.