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.

  • 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’

Open a YAML file, load it as python data, sort the data alphabetically, and write it back out to the same path.

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

  • 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

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

Add a source file to the namespace

  • 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

  • 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 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.
  • 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
class hdmf.spec.write.SpecFileBuilder

Bases: dict

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.

  • - 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