Developer API

The classes and functions documented here will be of use to developers who wish to create their own custom ASDF types and extensions.

asdf.types Module

Functions

format_tag(organization, standard, version, ...)

Format a YAML tag.

Classes

CustomType()

Base class for all user-defined types.

Class Inheritance Diagram

digraph inheritance0c97bba666 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CustomType" [URL="../../api/asdf.types.CustomType.html#asdf.types.CustomType",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all user-defined types."]; "ExtensionType" -> "CustomType" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ExtensionType" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="The base class of all custom types in the tree."]; }

asdf.extension Package

Support for plugins that extend asdf to serialize additional custom types.

Functions

get_cached_extension_manager(extensions)

Get a previously created ExtensionManager for the specified extensions, or create and cache one if necessary.

get_default_resolver()

Get the resolver that includes mappings from all installed extensions.

get_cached_asdf_extension_list(extensions)

Get a previously created AsdfExtensionList for the specified extensions, or create and cache one if necessary.

Classes

Extension()

Abstract base class defining an extension to ASDF.

ExtensionProxy(delegate[, package_name, ...])

Proxy that wraps an extension, provides default implementations of optional methods, and carries additional information on the package that provided the extension.

ManifestExtension(manifest, *[, ...])

Extension implementation that reads the extension URI, ASDF Standard requirement, and tag list from a manifest document.

ExtensionManager(extensions)

Wraps a list of extensions and indexes their converters by tag and by Python type.

TagDefinition(tag_uri, *[, schema_uris, ...])

Container for properties of a custom YAML tag.

Converter()

Abstract base class for plugins that convert nodes from the parsed YAML tree into custom objects, and vice versa.

ConverterProxy(delegate, extension)

Proxy that wraps a Converter and provides default implementations of optional methods.

Compressor()

Abstract base class for plugins that compress binary data.

AsdfExtension()

Abstract base class defining a (legacy) extension to ASDF.

AsdfExtensionList(extensions)

Manage a set of extensions that are in effect.

BuiltinExtension()

This is the "extension" to ASDF that includes all the built-in tags.

Class Inheritance Diagram

digraph inheritanceeb404f2579 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "AsdfExtension" [URL="../../api/asdf.extension.AsdfExtension.html#asdf.extension.AsdfExtension",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class defining a (legacy) extension to ASDF."]; "AsdfExtensionList" [URL="../../api/asdf.extension.AsdfExtensionList.html#asdf.extension.AsdfExtensionList",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Manage a set of extensions that are in effect."]; "BuiltinExtension" [URL="../../api/asdf.extension.BuiltinExtension.html#asdf.extension.BuiltinExtension",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="This is the \"extension\" to ASDF that includes all the built-in"]; "Compressor" [URL="../../api/asdf.extension.Compressor.html#asdf.extension.Compressor",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for plugins that compress binary data."]; "ABC" -> "Compressor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Converter" [URL="../../api/asdf.extension.Converter.html#asdf.extension.Converter",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for plugins that convert nodes from the"]; "ABC" -> "Converter" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ConverterProxy" [URL="../../api/asdf.extension.ConverterProxy.html#asdf.extension.ConverterProxy",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Proxy that wraps a `Converter` and provides default"]; "Converter" -> "ConverterProxy" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Extension" [URL="../../api/asdf.extension.Extension.html#asdf.extension.Extension",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class defining an extension to ASDF."]; "ABC" -> "Extension" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ExtensionManager" [URL="../../api/asdf.extension.ExtensionManager.html#asdf.extension.ExtensionManager",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Wraps a list of extensions and indexes their converters"]; "ExtensionProxy" [URL="../../api/asdf.extension.ExtensionProxy.html#asdf.extension.ExtensionProxy",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Proxy that wraps an extension, provides default implementations"]; "Extension" -> "ExtensionProxy" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AsdfExtension" -> "ExtensionProxy" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ManifestExtension" [URL="../../api/asdf.extension.ManifestExtension.html#asdf.extension.ManifestExtension",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Extension implementation that reads the extension URI, ASDF"]; "Extension" -> "ManifestExtension" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TagDefinition" [URL="../../api/asdf.extension.TagDefinition.html#asdf.extension.TagDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Container for properties of a custom YAML tag."]; }

asdf.resource Module

Support for plugins that provide access to resources such as schemas.

Functions

get_json_schema_resource_mappings()

Classes

ResourceMappingProxy(delegate[, ...])

Wrapper around a resource mapping that carries additional information on the package that provided the mapping.

DirectoryResourceMapping(root, uri_prefix[, ...])

Resource mapping that reads resource content from a directory or directory tree. Parameters ---------- root : str or importlib.abc.Traversable Root directory (or directory-like Traversable) of the resource files. str will be interpreted as a filesystem path. uri_prefix : str Prefix used to construct URIs from file paths. The prefix will be prepended to paths relative to the root directory. recursive : bool, optional If True, recurse into subdirectories. Defaults to False. filename_pattern : str, optional Glob pattern that identifies relevant filenames. Defaults to "*.yaml". stem_filename : bool, optional If True, remove the filename's extension when constructing its URI.

ResourceManager(resource_mappings)

Wraps multiple resource mappings into a single interface with some friendlier error handling.

JsonschemaResourceMapping()

Resource mapping that fetches metaschemas from the jsonschema package.

Class Inheritance Diagram

digraph inheritance43b00fdd6e { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Collection" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "Sized" -> "Collection" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Iterable" -> "Collection" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Container" -> "Collection" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Container" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "Iterable" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "JsonschemaResourceMapping" [URL="../../api/asdf.resource.JsonschemaResourceMapping.html#asdf.resource.JsonschemaResourceMapping",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Resource mapping that fetches metaschemas from"]; "Mapping" -> "JsonschemaResourceMapping" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Mapping" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "Collection" -> "Mapping" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ResourceManager" [URL="../../api/asdf.resource.ResourceManager.html#asdf.resource.ResourceManager",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Wraps multiple resource mappings into a single interface"]; "Mapping" -> "ResourceManager" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ResourceMappingProxy" [URL="../../api/asdf.resource.ResourceMappingProxy.html#asdf.resource.ResourceMappingProxy",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Wrapper around a resource mapping that carries"]; "Mapping" -> "ResourceMappingProxy" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Sized" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; }

asdf.yamlutil Module

Functions

custom_tree_to_tagged_tree(tree, ctx[, ...])

Convert a tree, possibly containing custom data types that aren't directly representable in YAML, to a tree of basic data types, annotated with tags.

tagged_tree_to_custom_tree(tree, ctx[, ...])

Convert a tree containing only basic data types, annotated with tags, to a tree containing custom data types.

asdf.util Module

Functions

human_list(l[, separator])

Formats a list for human readability.

get_array_base(arr)

For a given Numpy array, finds the base array that "owns" the actual data.

get_base_uri(uri)

For a given URI, return the part without any fragment.

filepath_to_url(path)

For a given local file path, return a file:// url.

iter_subclasses(cls)

Returns all subclasses of a class.

calculate_padding(content_size, pad_blocks, ...)

Calculates the amount of extra space to add to a block given the user's request for the amount of extra space.

resolve_name(name)

Resolve a name like module.object to an object and return it.

is_primitive(value)

Determine if a value is an instance of a "primitive" type.

uri_match(pattern, uri)

Determine if a URI matches a URI pattern with possible wildcards.

get_class_name(obj[, instance])

Given a class or instance of a class, returns a string representing the fully specified path of the class.

asdf.versioning Module

This module deals with things that change between different versions of the ASDF spec.

Functions

split_tag_version(tag)

Split a tag into its base and version.

join_tag_version(name, version)

Join the root and version of a tag back together.

Classes

AsdfVersion(version)

This class adds features to the existing Version class from the semantic_version module.

AsdfSpec(*args, **kwargs)

Class Inheritance Diagram

digraph inheritance15fe5152ac { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AsdfSpec" [URL="../../api/asdf.versioning.AsdfSpec.html#asdf.versioning.AsdfSpec",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "SimpleSpec" -> "AsdfSpec" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AsdfVersion" [URL="../../api/asdf.versioning.AsdfVersion.html#asdf.versioning.AsdfVersion",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="This class adds features to the existing ``Version`` class from the"]; "AsdfVersionMixin" -> "AsdfVersion" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Version" -> "AsdfVersion" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AsdfVersionMixin" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="This mix-in is required in order to impose the total ordering that we"]; "BaseSpec" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="A specification of compatible versions."]; "SimpleSpec" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "BaseSpec" -> "SimpleSpec" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Version" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; }

asdf.tests.helpers Module

Functions

get_test_data_path(name[, module])

assert_tree_match(old_tree, new_tree[, ctx, ...])

Assert that two ASDF trees match.

assert_roundtrip_tree(*args, **kwargs)

Assert that a given tree saves to ASDF and, when loaded back, the tree matches the original tree.

yaml_to_asdf(yaml_content[, yaml_headers, ...])

Given a string of YAML content, adds the extra pre- and post-amble to make it an ASDF file.

get_file_sizes(dirname)

Get the file sizes in a directory.

display_warnings(_warnings)

Return a string that displays a list of unexpected warnings