Skip to content
ASDF Projects Tutorials Community
Back to top
View this page

# ConverterProxy

class asdf.extension.ConverterProxy(delegate, extension)

  Bases: `Converter`

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

  Attributes Summary

  `class_name` | Get the fully qualified class name of this converter.
  `delegate` | Get the wrapped converter instance.
  `extension` | Get the extension that provided this converter.
  `lazy` | Boolean indicating if this Converter supports "lazy" node objects
  `package_name` | Get the name of the Python package of this converter's extension.
  `package_version` | Get the version of the Python package of this converter's extension.
  `tags` | Get the list of tag URIs that this converter is capable of handling.
  `types` | Get the Python types that this converter is capable of handling.

  Methods Summary

  `from_yaml_tree`(node, tag, ctx) | Convert a YAML node into an instance of a custom type.
  `select_tag`(obj, ctx) | Select the tag to use when converting an object to YAML.
  `to_info`(obj) | Convert an object to a container with items further defining information about this node.
  `to_yaml_tree`(obj, tag, ctx) | Convert an object into a node suitable for YAML serialization.

  Attributes Documentation

  class_name

    Get the fully qualified class name of this converter.

    Returns:
      str
  delegate

    Get the wrapped converter instance.

    Returns:
      asdf.extension.Converter
  extension

    Get the extension that provided this converter.

    Returns:
      asdf.extension.ExtensionProxy
  lazy

    Boolean indicating if this Converter supports “lazy” node objects

    Returns:
      bool
  package_name

    Get the name of the Python package of this converter’s extension. This may not be the same package that implements the converter’s class.

    Returns:
      str or None

        Package name, or `None` if the extension was added at runtime.

  package_version

    Get the version of the Python package of this converter’s extension. This may not be the same package that implements the converter’s class.

    Returns:
      str or None

        Package version, or `None` if the extension was added at runtime.

  tags

    Get the list of tag URIs that this converter is capable of handling.

    Returns:
      list of str
  types

    Get the Python types that this converter is capable of handling.

    Returns:
      list of type or str

  Methods Documentation

  from_yaml_tree(node, tag, ctx)

    Convert a YAML node into an instance of a custom type.

    Parameters:
      tree dict or list or str

        The YAML node to convert.

      tag str

        The YAML tag of the object being converted.

      ctx asdf.extension.SerializationContext

        Serialization parameters.

    Returns:
      object
  select_tag(obj, ctx)

    Select the tag to use when converting an object to YAML.

    Parameters:
      obj object

        Instance of the custom type being converted.

      ctx asdf.extension.SerializationContext

        Serialization parameters.

    Returns:
      str or None

        Selected tag or `None` to defer conversion.

  to_info(obj)

    Convert an object to a container with items further defining information about this node. This method is used for “info” and not used for serialization.

    Parameters:
      obj object

        Instance of a custom type to get “info” for.

    Returns:
      object

        Must be a container (list, tuple, dict) with items providing “info” about `obj`.

  to_yaml_tree(obj, tag, ctx)

    Convert an object into a node suitable for YAML serialization.

    Parameters:
      obj object

        Instance of a custom type to be serialized.

      tag str

        The tag identifying the YAML type that `obj` should be converted into.

      ctx asdf.extension.SerializationContext

        Serialization parameters.

    Returns:
      object

        The YAML node representation of the object.