hdmf.spec.write module

class hdmf.spec.write.SpecWriter

Bases: object

write_spec(spec_file_dict, path)
write_namespace(namespace, path)
class hdmf.spec.write.YAMLSpecWriter(outdir='.')

Bases: hdmf.spec.write.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: object

A class for building namespace and spec files

Parameters:
  • doc (str) – Description about what the namespace represents
  • name (str) – Name of the namespace
  • full_name (str) – Extended full name of the namespace
  • version (str or tuple or list) – Version number of the namespace
  • author (str or list) – Author or list of authors.
  • contact (str or list) – List of emails. Ordering should be the same as for author
  • date (datetime or str) – Date last modified or released. Formatting is %Y-%m-%d %H:%M:%S, e.g, 2017-04-25 17:14:13
  • namespace_cls (type) – the SpecNamespace type
add_spec(source, spec)

Add a Spec to the namespace

Parameters:
add_source(source, doc=None, title=None)

Add a source file to the namespace

Parameters:
  • source (str) – the path to write the spec to
  • doc (str) – additional documentation for the source file
  • title (str) – optional heading to be used for the source
include_type(data_type, source=None, namespace=None)

Include a data type from an existing namespace or source

Parameters:
  • data_type (str) – the data type to include
  • source (str) – the source file to include the type from
  • namespace (str) – the namespace from which to include the data type
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 to
  • outdir (str) – the path to write the directory to output the namespace and specs too
  • writer (SpecWriter) – the SpecWriter to use to write the namespace
name
class hdmf.spec.write.SpecFileBuilder

Bases: dict

add_spec(spec)
Parameters:spec (GroupSpec or DatasetSpec) – 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:
  • - NamespaceBuilder instance used to build the (ns_builder) – namespace and extension
  • - Iterable of specs that represent new data types (new_data_types) – to be added