View source on GitHub |
PyYAML event handler used to build objects.
Inherits From: EventHandler
, expected_type
google.appengine.api.yaml_builder.BuilderHandler(
builder
)
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.
Args | |
---|---|
builder
|
Instance of Builder class.
|
Raises | |
---|---|
ListenerConfigurationError when builder is not a Builder class.
|
Methods
Alias
Alias(
event, loader
)
Not implemented yet.
Args | |
---|---|
event
|
Ignored. |
DocumentEnd
DocumentEnd(
event, loader
)
End of document.
Args | |
---|---|
event
|
Ignored. |
DocumentStart
DocumentStart(
event, loader
)
Build a new document.
Pushes a new document onto the stack.
Args | |
---|---|
event
|
Ignored. |
GetResults
GetResults()
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
MappingEnd(
event, loader
)
End of mapping.
Args | |
---|---|
event
|
Ignored. |
loader
|
Ignored. |
MappingStart
MappingStart(
event, loader
)
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
Scalar(
event, loader
)
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
SequenceEnd(
event, loader
)
End of the sequence.
Args | |
---|---|
event
|
Ignored. |
loader
|
Ignored. |
SequenceStart
SequenceStart(
event, loader
)
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
StreamEnd(
event, loader
)
Cleans up internal state of handler after parsing.
Args | |
---|---|
event
|
Ignored. |
StreamStart
StreamStart(
event, loader
)
Initializes internal state of handler.
Args | |
---|---|
event
|
Ignored. |