DefinitionEntry

class DefinitionEntry(name, contents, takes_value, source_context)[source]

A single definition.

Methods

hed.models.definition_entry.DefinitionEntry.__init__(...)

Initialize info for a single definition.

hed.models.definition_entry.DefinitionEntry.get_definition(...)

Return a copy of the definition with the tag expanded and the placeholder plugged in.

Attributes

DefinitionEntry.__init__(name, contents, takes_value, source_context)[source]

Initialize info for a single definition.

Parameters:
  • name (str) – The label portion of this name (not including Definition/).

  • contents (HedGroup) – The contents of this definition.

  • takes_value (bool) – If True, expects ONE tag to have a single # sign in it.

  • source_context (list, None) – List (stack) of dictionaries giving context for reporting errors.

DefinitionEntry.get_definition(replace_tag, placeholder_value=None, return_copy_of_tag=False)[source]

Return a copy of the definition with the tag expanded and the placeholder plugged in.

Returns None if placeholder_value passed when it doesn’t take value, or vice versa.

Parameters:
  • replace_tag (HedTag) – The def hed tag to replace with an expanded version

  • placeholder_value (str or None) – If present and required, will replace any pound signs in the definition contents.

  • return_copy_of_tag (bool) – Set to true for validation

Returns:

The contents of this definition(including the def tag itself)

Return type:

HedGroup

Raises:

ValueError

  • Something internally went wrong with finding the placeholder tag. This should not be possible.