hdmf.spec.catalog module
- class hdmf.spec.catalog.SpecCatalog
Bases:
object
Create a new catalog for storing specifications
** Private Instance Variables **
- Variables:
__specs – Dict with the specification of each registered type
__parent_types – Dict with parent types for each registered type
__spec_source_files – Dict with the path to the source files (if available) for each registered type
__hierarchy – Dict describing the hierarchy for each registered type. NOTE: Always use SpecCatalog.get_hierarchy(…) to retrieve the hierarchy as this dictionary is used like a cache, i.e., to avoid repeated calculation of the hierarchy but the contents are computed on first request by SpecCatalog.get_hierarchy(…)
- register_spec(spec, source_file=None)
Associate a specified object type with a specification
- Parameters:
spec (
BaseStorageSpec
) – a Spec objectsource_file (
str
) – path to the source file from which the spec was loaded
- get_spec(data_type)
Get the Spec object for the given type
- Parameters:
data_type (
str
) – the data_type to get the Spec for- Returns:
the specification for writing the given object type to HDF5
- Return type:
Spec
- get_registered_types()
Return all registered specifications
- get_spec_source_file(data_type)
- Return the path to the source file from which the spec for the given
type was loaded from. None is returned if no file path is available for the spec. Note: The spec in the file may not be identical to the object in case the spec is modified after load.
- Parameters:
data_type (
str
) – the data_type of the spec to get the source file for- Returns:
the path to source specification file from which the spec was originally loaded or None
- Return type:
str
- auto_register(spec, source_file=None)
Register this specification and all sub-specification using data_type as object type name
- Parameters:
spec (
BaseStorageSpec
) – the Spec object to registersource_file (
str
) – path to the source file from which the spec was loaded
- Returns:
the types that were registered with this spec
- Return type:
- get_hierarchy(data_type)
For a given type get the type inheritance hierarchy for that type.
E.g., if we have a type MyContainer that inherits from BaseContainer then the result will be a tuple with the strings (‘MyContainer’, ‘BaseContainer’)
- get_full_hierarchy()
- Get the complete hierarchy of all types. The function attempts to sort types by name using
standard Python sorted.
- Returns:
Hierarchically nested OrderedDict with the hierarchy of all the types
- Return type:
- get_subtypes(data_type, recursive=True)
For a given data type recursively find all the subtypes that inherit from it.
E.g., assume we have the following inheritance hierarchy:
-BaseContainer--+-->AContainer--->ADContainer | +-->BContainer
In this case, the subtypes of BaseContainer would be (AContainer, ADContainer, BContainer), the subtypes of AContainer would be (ADContainer), and the subtypes of BContainer would be empty ().