form.spec.write module

class form.spec.write.NamespaceBuilder(doc, name, full_name=None, version=None, author=None, contact=None, namespace_cls=<class 'form.spec.namespace.SpecNamespace'>)

Bases: object

A class for building namespace and spec files

Parameters:
  • doc (str) – a description about what name namespace represents
  • name (str) – the name of namespace
  • full_name (str) – extended full name of name 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
  • namespace_cls (type) – the SpecNamespace type
add_source(source)

Add a source file to the namespace

Parameters:source (str) – the path to write the spec to
add_spec(source, spec)

Add a Spec to the namespace

Parameters:
export(path, outdir=.)

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
include_namespace(namespace)

Include an entire namespace

Parameters:namespace (str) – the namespace to include
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