hdmf.spec.namespace module
- class hdmf.spec.namespace.SpecNamespace(doc, name, schema, full_name=None, version=None, date=None, author=None, contact=None, catalog=None)
Bases:
dictA namespace for specifications
- Parameters:
doc (
str) – a description about what this namespace representsname (
str) – the name of this namespaceschema (
list) – location of schema specification files or other Namespacesfull_name (
str) – extended full name of this namespaceversion (
strortupleorlist) – Version number of the namespacedate (
datetimeorstr) – Date last modified or released. Formatting is %Y-%m-%d %H:%M:%S, e.g, 2017-04-25 17:14:13contact (
strorlist) – List of emails. Ordering should be the same as for authorcatalog (
SpecCatalog) – The SpecCatalog object for this SpecNamespace
- UNVERSIONED = None
- classmethod types_key()
Get the key used for specifying types to include from a file or namespace
Override this method to use a different name for ‘data_types’
- property full_name
String with full name or None
- property contact
String or list of strings with the contacts or None
- property author
String or list of strings with the authors or None
- property version
String, list, or tuple with the version or SpecNamespace.UNVERSIONED if the version is missing or empty
- property date
Date last modified or released.
- Returns:
datetime object, string, or None
- property name
String with short name or None
- property doc
- property schema
- get_source_files()
Get the list of names of the source files included the schema of the namespace
- get_source_description(sourcefile)
Get the description of a source file as described in the namespace. The result is a dict which contains the ‘source’ and optionally ‘title’, ‘doc’ and ‘data_types’ imported from the source file
- property catalog
The SpecCatalog containing all the Specs
- get_spec(data_type)
Get the Spec object for the given data type
- get_registered_types()
Get the available types in this namespace
- Returns:
the a tuple of the available data types
- Return type:
- get_hierarchy(data_type)
Get the extension hierarchy for the given data_type in this namespace
- classmethod build_namespace(**spec_dict)
- class hdmf.spec.namespace.SpecReader(source)
Bases:
object- Parameters:
source (
str) – the source from which this reader reads from
- property source
- abstractmethod read_spec()
- abstractmethod read_namespace()
- class hdmf.spec.namespace.YAMLSpecReader(indir='.')
Bases:
SpecReader- Parameters:
indir (
str) – the path spec files are relative to
- read_namespace(namespace_path)
- read_spec(spec_path)
- class hdmf.spec.namespace.NamespaceCatalog(group_spec_cls=<class 'hdmf.spec.spec.GroupSpec'>, dataset_spec_cls=<class 'hdmf.spec.spec.DatasetSpec'>, spec_namespace_cls=<class 'hdmf.spec.namespace.SpecNamespace'>, core_namespaces=[])
Bases:
objectCreate a catalog for storing multiple Namespaces
- Parameters:
- merge(ns_catalog)
- property namespaces
The namespaces in this NamespaceCatalog
- Returns:
a tuple of the available namespaces
- Return type:
- property dataset_spec_cls
The DatasetSpec class used in this NamespaceCatalog
- property group_spec_cls
The GroupSpec class used in this NamespaceCatalog
- property spec_namespace_cls
The SpecNamespace class used in this NamespaceCatalog
- property core_namespaces
The core namespaces used in this NamespaceCatalog
- get_source_types(ns_name)
Get the source types for a namespace.
Returns a tuple of data type names that were loaded from source files for the given namespace.
- add_namespace(name, namespace)
Add a namespace to this catalog
- Parameters:
name (
str) – the name of this namespacenamespace (
SpecNamespace) – the SpecNamespace object
- get_namespace(name)
Get the a SpecNamespace
- Parameters:
name (
str) – the name of this namespace- Returns:
the SpecNamespace with the given name
- Return type:
- get_spec(namespace, data_type)
Get the Spec object for the given type from the given Namespace
- get_hierarchy(namespace, data_type)
Get the type hierarchy for a given data_type in a given namespace
- is_sub_data_type(namespace, data_type, parent_data_type)
Return whether or not data_type is a sub data_type of parent_data_type
- get_sources()
Get all the source specification files that were loaded in this catalog
- get_namespace_sources(namespace)
Get all the source specifications that were loaded for a given namespace
- Parameters:
namespace (
str) – the name of the namespace
- get_types(source)
Get the types that were loaded from a given source
- Parameters:
source (
str) – the name of the source
- get_spec_source_dict(source)
Get the unresolved specs for a given source file. Returns a dict with ‘datasets’ and ‘groups’ keys containing lists of unresolved Spec objects (before resolution of inherited fields). Returns None if the source is not found.
- Parameters:
source (
str) – the name of the source file
- resolve_all_specs() None
Resolve all specs in all namespaces in the catalog.
This method resolves all type-level includes (merging parent type fields into child types) and subspec-level includes (merging included type fields into subspecs). It uses a recursive depth-first approach with cycle detection to handle containment cycles (e.g., DynamicTable contains MeaningsTable, MeaningsTable extends DynamicTable).
- load_namespaces(namespace_path, resolve=True, reader=None)
Load the namespaces in the given file
- Parameters:
namespace_path (
str) – the path to the file containing the namespaces(s) to loadresolve (
bool) – whether or not to include objects from included/parent spec objects. In practice, this is False when generating documentation where it is useful to show the unresolved specsreader (
SpecReaderordict) – the SpecReader or dict of SpecReader classes to use for reading specifications
- Returns:
a dictionary describing the dependencies of loaded namespaces
- Return type: