Python 3.9 is now generally available.

google.appengine.api.yaml_builder.BuilderHandler

PyYAML event handler used to build objects.

Inherits From: EventHandler, expected_type

Maintains state information as it receives parse events so that object nesting is maintained. Uses the provided builder object to construct and assemble objects as it goes.

As it receives events from the YAML parser, it builds a stack of data representing structural tokens. As the scope of documents, mappings, and sequences end, those token and value pairs are popped from the top of the stack so that the original scope can resume processing.

A special case is made for the _KEY token. It represents a temporary value which only occurs inside mappings. It is immediately popped off the stack when it's associated value is encountered in the parse stream. It is necessary to do this because the YAML parser does not combine key and value information into a single event.

builder Instance of Builder class.

ListenerConfigurationError when builder is not a Builder class.

Methods

Alias

View source

Not implemented yet.

Args
event Ignored.

DocumentEnd

View source

End of document.

Args
event Ignored.

DocumentStart

View source

Build a new document.

Pushes a new document onto the stack.

Args
event Ignored.

GetResults

View source

Get results of document stream processing.

This method can be invoked after fully parsing the entire YAML file to retrieve constructed contents of YAML file. Called after EndStream.

Returns
A tuple of all document objects that were parsed from YAML stream.

Raises
InternalError if the builder stack is not empty by the end of parsing.

MappingEnd

View source

End of mapping.

Args
event Ignored.
loader Ignored.

MappingStart

View source

Start of the mapping scope.

Create a mapping from builder and then handle in the context of its parent.

Args
event MappingStartEvent generated by loader.
loader Loader that generated the event.

Scalar

View source

Handles the scalar value.

Since scalars are simple values that are passed in directly by the parser, this handles the scalar value like any other value with no additional processing.

However, key values will be handled differently. A key value is recognized when the top token is _TOKEN_MAPPING.

Args
event Event containing scalar value.

SequenceEnd

View source

End of the sequence.

Args
event Ignored.
loader Ignored.

SequenceStart

View source

Start of the sequence scope.

Create a new sequence from the builder and then handle in the context of its parent.

Args
event SequenceStartEvent generated by loader.
loader Loader that generated event.

StreamEnd

View source

Cleans up internal state of handler after parsing.

Args
event Ignored.

StreamStart

View source

Initializes internal state of handler.

Args
event Ignored.