HedSchemaBase

class HedSchemaBase[source]

Baseclass for schema and schema group.

Implementing the abstract functions will allow you to use the schema for validation

Methods

HedSchemaBase.__init__()

HedSchemaBase.check_compliance([...])

Check for HED3 compliance of this schema.

HedSchemaBase.find_tag_entry(tag[, ...])

Find the schema entry for a given source tag.

HedSchemaBase.get_formatted_version()

The HED version string including namespace and library name if any of this schema.

HedSchemaBase.get_schema_versions()

A list of HED version strings including namespace and library name if any of this schema.

HedSchemaBase.get_tag_entry(name[, ...])

Return the schema entry for this tag, if one exists.

HedSchemaBase.get_tags_with_attribute(attribute)

Return tag entries with the given attribute.

HedSchemaBase.schema_for_namespace(namespace)

Return the HedSchema for the library namespace.

Attributes

HedSchemaBase.name

User provided name for this schema, defaults to filename or version if no name provided.

HedSchemaBase.schema_83_props

Returns if this is an 8.3.0 or greater schema.

HedSchemaBase.valid_prefixes

Return a list of all prefixes this group will accept.

HedSchemaBase.__init__()[source]
abstract HedSchemaBase.check_compliance(check_for_warnings=True, name=None, error_handler=None)[source]

Check for HED3 compliance of this schema.

Parameters:
  • check_for_warnings (bool) – If True, checks for formatting issues like invalid characters, capitalization.

  • name (str) – If present, use as the filename for context, rather than using the actual filename. Useful for temp filenames when supporting web services.

  • error_handler (ErrorHandler or None) – Used to report errors. Uses a default one if none passed in.

Returns:

A list of all warnings and errors found in the file. Each issue is a dictionary.

Return type:

list

abstract HedSchemaBase.find_tag_entry(tag, schema_namespace='')[source]

Find the schema entry for a given source tag.

Parameters:
  • tag (str, HedTag) – Any form of tag to look up. Can have an extension, value, etc.

  • schema_namespace (str) – The schema namespace of the tag, if any.

Returns:

The located tag entry for this tag. str: The remainder of the tag that isn’t part of the base tag. list: A list of errors while converting.

Return type:

HedTagEntry

Notes

Works left to right (which is mostly relevant for errors).

abstract HedSchemaBase.get_formatted_version()[source]

The HED version string including namespace and library name if any of this schema.

Returns:

The complete version of this schema including library name and namespace.

Return type:

str

abstract HedSchemaBase.get_schema_versions()[source]

A list of HED version strings including namespace and library name if any of this schema.

Returns:

The complete version of this schema including library name and namespace.

Return type:

list

abstract HedSchemaBase.get_tag_entry(name, key_class=HedSectionKey.Tags, schema_namespace='')[source]

Return the schema entry for this tag, if one exists.

Parameters:
  • name (str) – Any form of basic tag(or other section entry) to look up. This will not handle extensions or similar. If this is a tag, it can have a schema namespace, but it’s not required

  • key_class (HedSectionKey or str) – The type of entry to return.

  • schema_namespace (str) – Only used on Tags. If incorrect, will return None.

Returns:

The schema entry for the given tag.

Return type:

HedSchemaEntry

abstract HedSchemaBase.get_tags_with_attribute(attribute, key_class=HedSectionKey.Tags)[source]

Return tag entries with the given attribute.

Parameters:
  • attribute (str) – A tag attribute. Eg HedKey.ExtensionAllowed

  • key_class (HedSectionKey) – The HedSectionKey for the section to retrieve from.

Returns:

A list of all tags with this attribute.

Return type:

list

Notes

  • The result is cached so will be fast after first call.

abstract HedSchemaBase.schema_for_namespace(namespace)[source]

Return the HedSchema for the library namespace.

Parameters:

namespace (str) – A schema library name namespace.

Returns:

The specific schema for this library name namespace if exists.

Return type:

HedSchema or None

HedSchemaBase.name

User provided name for this schema, defaults to filename or version if no name provided.

HedSchemaBase.schema_83_props

Returns if this is an 8.3.0 or greater schema.

Returns:

True if standard or partnered schema is 8.3.0 or greater.

Return type:

is_83_schema(bool)

HedSchemaBase.valid_prefixes

Return a list of all prefixes this group will accept.

Returns:

A list of strings representing valid prefixes for this group.

Return type:

prefixes(list of str)