hdmf.spec.write module¶
- class hdmf.spec.write.SpecWriter¶
Bases:
object- abstract write_spec(spec_file_dict, path)¶
- abstract write_namespace(namespace, path)¶
- class hdmf.spec.write.YAMLSpecWriter(outdir='.')¶
Bases:
SpecWriter- Parameters
outdir (
str) – the path to write the directory to output the namespace and specs too
- write_spec(spec_file_dict, path)¶
- write_namespace(namespace, path)¶
Write the given namespace key-value pairs as YAML to the given path.
- Parameters
namespace – SpecNamespace holding the key-value pairs that define the namespace
path – File path to write the namespace to as YAML under the key ‘namespaces’
- reorder_yaml(path)¶
Open a YAML file, load it as python data, sort the data alphabetically, and write it back out to the same path.
- sort_keys(obj)¶
- class hdmf.spec.write.NamespaceBuilder(doc, name, full_name=None, version=None, author=None, contact=None, date=None, namespace_cls=<class 'hdmf.spec.namespace.SpecNamespace'>)¶
Bases:
objectA class for building namespace and spec files
- Parameters
doc (
str) – Description about what the namespace representsname (
str) – Name of the namespacefull_name (
str) – Extended full name of the namespaceversion (
strortupleorlist) – Version number of the namespacecontact (
strorlist) – List of emails. Ordering should be the same as for authordate (
datetimeorstr) – Date last modified or released. Formatting is %Y-%m-%d %H:%M:%S, e.g, 2017-04-25 17:14:13namespace_cls (
type) – the SpecNamespace type
- add_spec(source, spec)¶
Add a Spec to the namespace
- Parameters
source (
str) – the path to write the spec tospec (
GroupSpecorDatasetSpec) – the Spec to add
- add_source(source, doc=None, title=None)¶
Add a source file to the namespace
- include_type(data_type, source=None, namespace=None)¶
Include a data type from an existing namespace or source
- include_namespace(namespace)¶
Include an entire namespace
- Parameters
namespace (
str) – the namespace to include
- export(path, outdir='.', writer=None)¶
Export the namespace to the given path.
All new specification source files will be written in the same directory as the given path.
- Parameters
path (
str) – the path to write the spec tooutdir (
str) – the path to write the directory to output the namespace and specs toowriter (
SpecWriter) – the SpecWriter to use to write the namespace
- property name¶
- class hdmf.spec.write.SpecFileBuilder¶
Bases:
dict- add_spec(spec)¶
- Parameters
spec (
GroupSpecorDatasetSpec) – the Spec to add
- hdmf.spec.write.export_spec(ns_builder, new_data_types, output_dir)¶
Create YAML specification files for a new namespace and extensions with the given data type specs.
- Parameters
the (ns_builder - NamespaceBuilder instance used to build) – namespace and extension
types (new_data_types - Iterable of specs that represent new data) – to be added