AsdfType

class asdf.AsdfType[source]

Bases: object

The base class of all custom types in the tree.

Besides the attributes defined below, most subclasses will also override to_tree and from_tree.

To customize how the type’s schema is located, override get_schema_path.

Attributes

name (str) The name of the type.
organization (str) The organization responsible for the type.
standard (str) The standard the type is defined in. For built-in ASDF types, this is "asdf".
version (3-tuple of int) The version of the standard the type is defined in.
yaml_tag (str) The YAML tag to use for the type. If not provided, it will be automatically generated from name, organization, standard and version.
types (list of Python types) Custom Python types that, when found in the tree, will be converted into basic types for YAML output.
validators (dict) Mapping JSON Schema keywords to validation functions for jsonschema. Useful if the type defines extra types of validation that can be performed.
requires (list of str) A list of Python packages that are required to instantiate the object.

Attributes Summary

handle_dynamic_subclasses
has_required_modules
name
organization
requires
standard
types
validators
version
yaml_tag

Methods Summary

from_tree(tree, ctx) Converts from basic types to a custom type.
from_tree_tagged(tree, ctx) Converts from basic types to a custom type.
make_yaml_tag(name)
to_tree(node, ctx) Converts from a custom type to any of the basic types (dict, list, str, number) supported by YAML.
to_tree_tagged(node, ctx) Converts from a custom type to any of the basic types (dict, list, str, number) supported by YAML.

Attributes Documentation

handle_dynamic_subclasses = False
has_required_modules = True
name = None
organization = u'stsci.edu'
requires = []
standard = u'asdf'
types = []
validators = {}
version = (1, 0, 0)
yaml_tag = None

Methods Documentation

classmethod from_tree(tree, ctx)[source]

Converts from basic types to a custom type.

classmethod from_tree_tagged(tree, ctx)[source]

Converts from basic types to a custom type. Overriding this, rather than the more common from_tree, allows types to deal with the tag directly.

classmethod make_yaml_tag(name)[source]
classmethod to_tree(node, ctx)[source]

Converts from a custom type to any of the basic types (dict, list, str, number) supported by YAML. In most cases, must be overridden by subclasses.

classmethod to_tree_tagged(node, ctx)[source]

Converts from a custom type to any of the basic types (dict, list, str, number) supported by YAML. The result should be a tagged object. Overriding this, rather than the more common to_tree, allows types to customize how the result is tagged.