Code Monkey home page Code Monkey logo

poyo's Introduction

Poyo

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: "[email protected]"
    docs: true
    gui: FALSE
    123: 456.789
    someint: 1000000
    foo: "hallo #welt" #Inline comment :)
    trueish: Falseeeeeee
    doc_tools:
        -    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'[email protected]',
        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

poyo's People

Contributors

hackebrot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.