Skip to main content

A lightweight YAML Parser for Python

Project description

PyPI Package PyPI Python Versions PyPI Package License See Build Status on Travis CI

A lightweight YAML Parser for Python

Please note that Poyo supports only a chosen subset of the YAML format.

It can only read but not write and is not compatible with JSON.

See the examples below to get an idea of what Poyo understands.

Installation

poyo is available for download from PyPI via pip:

$ pip install poyo

Poyo is 100% Python and does not require any additional libs.

Usage

Poyo comes with a parse_string() function, to load utf-8 encoded string data into a Python dict.

import codecs
import logging

from poyo import parse_string, PoyoException

logging.basicConfig(level=logging.DEBUG)

with codecs.open('tests/foobar.yml', encoding='utf-8') as ymlfile:
    ymlstring = ymlfile.read()

try:
    config = parse_string(ymlstring)
except PoyoException as exc:
    logging.error(exc)
else:
    logging.debug(config)

Example

In (YAML):

---
default_context: # foobar
    greeting: こんにちは
    email: "raphael@hackebrot.de"
    docs: true
    gui: FALSE
    123: 456.789
    someint: 1000000
    foo: "hallo #welt" #Inline comment :)
    trueish: Falseeeeeee
    doc_tools:
        # docs or didn't happen
        -    mkdocs
        - 'sphinx'

        - null
zZz: True
NullValue: Null

# Block
# Comment

Hello World:
    null: This is madness   # yo
    gh: https://github.com/{0}.git
"Yay #python": Cool!

Out (Python):

{
    u'default_context': {
        u'greeting': u'こんにちは',
        u'email': u'raphael@hackebrot.de',
        u'docs': True,
        u'gui': False,
        123: 456.789,
        u'someint': 1000000,
        u'foo': u'hallo #welt',
        u'trueish': u'Falseeeeeee',
        u'doc_tools': [u'mkdocs', u'sphinx', None],
    },
    u'zZz': True,
    u'NullValue': None,
    u'Hello World': {
        None: u'This is madness',
        u'gh': u'https://github.com/{0}.git',
    },
    u'Yay #python': u'Cool!'
}

WHY?!

Because a couple of cookiecutter users, including myself, ran into issues when installing well-known YAML parsers for Python on various platforms and Python versions.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Code of Conduct

Everyone interacting in the Poyo project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.

License

Distributed under the terms of the MIT license, poyo is free and open source software.

OSI certified

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poyo-0.3.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

poyo-0.3.0-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file poyo-0.3.0.tar.gz.

File metadata

  • Download URL: poyo-0.3.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for poyo-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a73c014ec074face7f9f320f1cfdc205765ddb19d6076365b1e6a6eca1653d68
MD5 16fd6196e22128262327b402c9312dac
BLAKE2b-256 b9d1f8f50ce8f3cce942c1136ad5c8db4d2462751fd4616dc16535a6c4b7730f

See more details on using hashes here.

File details

Details for the file poyo-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for poyo-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a6e1485deaef080d0769d108b6c78b3c2305ee84cc4b52d39ee3c8d16a40041e
MD5 543e2c73004145dc7dff0a2a18c2e9c3
BLAKE2b-256 28fff3276c42d61992cc6594f1e2201c7f57bc12f518a30f5c2f992fc9668fbd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page