ocebuild.parsers.yaml
#
Parser for converting annotated YAML to a Python dictionary.
Module Contents#
Functions#
|
Parse YAML types to Python types. |
|
Parse Python types to YAML types. |
|
Parses YAML (optionally type annotated) into a Python dictionary. |
|
Writes a Python dictionary to YAML. |
- ocebuild.parsers.yaml.parse_yaml_types(stype: str, value: str, schema: Literal[annotated, yaml] = 'yaml') Tuple[str, any] | None [source]#
Parse YAML types to Python types.
- Parameters:
stype – YAML type (literal).
value – YAML value.
schema – Flag to control input schema.
- Returns:
Tuple of parsed type (literal) and value.
- ocebuild.parsers.yaml.write_yaml_types(value: Tuple[str, any] | any, schema: Literal[annotated, yaml] = 'yaml') Tuple[str, any] [source]#
Parse Python types to YAML types.
- Parameters:
value – Tuple of type (literal) and value.
schema – Flag to control output schema.
- Returns:
Tuple of parsed type (literal) and value.
- ocebuild.parsers.yaml.parse_yaml(lines: List[str], config: dict | None = None, flags: List[str] | None = None, frontmatter: bool = False) dict | Tuple[dict, dict] [source]#
Parses YAML (optionally type annotated) into a Python dictionary.
- Parameters:
lines – YAML lines.
config – Dictionary to be populated.
flags – List of preprocessor flags.
frontmatter – Flag to control frontmatter parsing.
- Raises:
ValueError – If YAML parser reaches an invalid line.
- Returns:
Dictionary populated from YAML entries.
- ocebuild.parsers.yaml.write_yaml(config: dict, lines: List[str] | None = None, schema: Literal[annotated, yaml] = 'yaml') List[str] [source]#
Writes a Python dictionary to YAML.
- Parameters:
lines – YAML lines.
config – Dictionary to be written.
schema – Flag to control output schema.
- Returns:
YAML lines populated from dictionary entries.