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:
dict
A 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 (
str
ortuple
orlist
) – Version number of the namespacedate (
datetime
orstr
) – Date last modified or released. Formatting is %Y-%m-%d %H:%M:%S, e.g, 2017-04-25 17:14:13contact (
str
orlist
) – 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
- abstract read_spec()
- abstract 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'>)
Bases:
object
Create 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
- 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
- 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 objectsreader (
SpecReader
) – the class to user for reading specifications
- Returns:
a dictionary describing the dependencies of loaded namespaces
- Return type: