TaggedObjectNodeConverter

class roman_datamodels.stnode.TaggedObjectNodeConverter[source]

Bases: _RomanConverter

Converter for all subclasses of TaggedObjectNode.

Attributes Summary

tags

Get the YAML tags that this converter is capable of handling.

types

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

Methods Summary

to_yaml_tree(obj, tag, ctx)

Convert an object into a node suitable for YAML serialization.

Attributes Documentation

tags
types

Methods Documentation

to_yaml_tree(obj, tag, ctx)[source]

Convert an object into a node suitable for YAML serialization. This method is not responsible for writing actual YAML; rather, it converts an instance of a custom type to a built-in Python object type (such as dict, list, str, or number), which can then be automatically serialized to YAML as needed.

For container types returned by this method (dict or list), the children of the container need not themselves be converted. Any list elements or dict values will be converted by subsequent calls to to_yaml_tree implementations.

The returned node must be an instance of dict, list, or str. Children may be any type supported by an available Converter.

Parameters:
  • obj (object) – Instance of a custom type to be serialized. Guaranteed to be an instance of one of the types listed in the types property.

  • tag (str) – The tag identifying the YAML type that obj should be converted into. Selected by a call to this converter’s select_tag method.

  • ctx (asdf.extension.SerializationContext) – The context of the current serialization request.

Returns:

The YAML node representation of the object.

Return type:

dict or list or str