Poyo, a Lightweight YAML Parser

0.5.0 · active · verified Thu Apr 16

Poyo is a lightweight YAML parser for Python (current version 0.5.0). It focuses on parsing a chosen subset of the YAML format, primarily designed for configuration files like those used by cookiecutter. It explicitly does not support deserialization of arbitrary Python objects, YAML serialization, or JSON compatibility. The project is in maintenance mode with infrequent updates, with the last release in July 2019, but it remains functional for its intended scope.

Common errors

Warnings

Install

Imports

Quickstart

Parses a simple YAML string using `parse_string` and demonstrates basic type conversion and multiline string handling, with error handling for parsing issues.

from poyo import parse_string, PoyoException

yaml_string = """
default_context:
    greeting: Hello
    is_enabled: true
    count: 123
    items:
        - apple
        - banana
        - null
long_description: >
    This is a multiline string.
    It demonstrates how to handle
    text blocks introduced in 0.5.0.
"""

try:
    config = parse_string(yaml_string)
    print(config)
    # Expected output similar to:
    # {
    #     'default_context': {
    #         'greeting': 'Hello',
    #         'is_enabled': True,
    #         'count': 123,
    #         'items': ['apple', 'banana', None]
    #     },
    #     'long_description': 'This is a multiline string. It demonstrates how to handle text blocks introduced in 0.5.0.'
    # }
except PoyoException as e:
    print(f"Error parsing YAML: {e}")

view raw JSON →