Parse Yaml
hexa.parse_yaml
Summary
Parse a hexa YAML spec into a :class:PortNode tree.
The YAML grammar uses a nested mapping format built from three member kinds:
- attribute: a
name: typescalar (e.g.source_type: str) - nested struct: a
name:mapping of sub-attributes (e.g.source:) - port: a
name:mapping whose single key is a class whose value is a body, or a class key with a...body. A port carries a class shape.
Disambiguation of a mapping value
A mapping with exactly one key whose value is a non-scalar body (a mapping,
..., or a list) is a port. Any other mapping (multiple keys, or all
scalar-typed values) is a nested struct of attributes.
Examples
Parse a spec into a port tree:
1 2 3 4 5 6 | |
The YAML grammar:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Notes
- See
samples/minimal/sample.yamlandsamples/extraction_pipeline/extraction_pipeline.yamlfor worked examples.
Classes
Functions
parse_yaml
Parse a hexa YAML spec file into a :class:PortNode tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str | Path
|
Path to the |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PortNode |
PortNode
|
The root node of the parsed tree. |
Raises:
| Type | Description |
|---|---|
ValueError
|
On structural errors in the YAML. |