{"id":13501971,"url":"https://github.com/hackebrot/poyo","last_synced_at":"2025-04-04T11:10:07.410Z","repository":{"id":47057277,"uuid":"48649622","full_name":"hackebrot/poyo","owner":"hackebrot","description":"A lightweight YAML Parser for Python. 🐓","archived":false,"fork":false,"pushed_at":"2021-09-15T12:44:11.000Z","size":105,"stargazers_count":138,"open_issues_count":8,"forks_count":25,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-14T18:33:40.984Z","etag":null,"topics":["config","cookiecutter","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackebrot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-27T15:18:14.000Z","updated_at":"2024-07-20T21:25:19.000Z","dependencies_parsed_at":"2022-09-13T08:12:12.503Z","dependency_job_id":null,"html_url":"https://github.com/hackebrot/poyo","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackebrot%2Fpoyo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackebrot%2Fpoyo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackebrot%2Fpoyo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackebrot%2Fpoyo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackebrot","download_url":"https://codeload.github.com/hackebrot/poyo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166145,"owners_count":20894652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","cookiecutter","python"],"created_at":"2024-07-31T22:01:56.964Z","updated_at":"2025-04-04T11:10:07.390Z","avatar_url":"https://github.com/hackebrot.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# poyo\n\nA lightweight YAML Parser for Python. 🐓\n\n**poyo** does not allow deserialization of arbitrary Python objects. Supported\ntypes are `str`, `bool`, `int`, `float`, `NoneType` as well as `dict` and\n`list` values.\n\n⚠️ Please note that poyo supports only a chosen subset of the YAML format\nthat is required to parse [cookiecutter user configuration\nfiles][cookiecutterrc]. poyo does not have support for serializing into YAML\nand is not compatible with JSON.\n\n[cookiecutterrc]: https://cookiecutter.readthedocs.io/en/latest/advanced/user_config.html\n\n## Installation\n\npoyo is available on [PyPI][PyPI] for Python versions 2.7 and newer and can\nbe installed with [pip][pip]:\n\n```text\npip install poyo\n```\n\n[PyPI]: https://pypi.org/project/poyo/\n[pip]: https://pypi.org/project/pip/\n\nThis package does not have any additional requirements. 📦\n\n## Usage\n\npoyo comes with a ``parse_string()`` function, to load utf-8 encoded string\ndata into a Python dict.\n\n```python\nimport codecs\nimport logging\n\nfrom poyo import parse_string, PoyoException\n\nlogging.basicConfig(level=logging.DEBUG)\n\nwith codecs.open(\"tests/foobar.yml\", encoding=\"utf-8\") as ymlfile:\n    ymlstring = ymlfile.read()\n\ntry:\n    config = parse_string(ymlstring)\nexcept PoyoException as exc:\n    logging.error(exc)\nelse:\n    logging.debug(config)\n```\n\n## Example\n\n### Input YAML string\n\n```yaml\n---\ndefault_context: # foobar\n    greeting: こんにちは\n    email: \"raphael@hackebrot.de\"\n    docs: true\n\n    gui: FALSE\n    123: 456.789\n    # comment\n    # allthethings\n    'some:int': 1000000\n    foo: \"hallo #welt\" #Inline comment :)\n    longtext: \u003e\n        This is a multiline string.\n        It can contain all manners of characters.\n\n        Single line breaks are ignored,\n        but blank linkes cause line breaks.\n    trueish: Falseeeeeee\n    blog   : raphael.codes\n    relative-root: /          # web app root path (default: '')\n    lektor: 0.0.0.0:5000      # local build\n    doc_tools:\n        # docs or didn't happen\n        -    mkdocs\n        - 'sphinx'\n\n        - null\n    # 今日は\nzZz: True\nNullValue: Null\n\n# Block\n# Comment\n\nHello World:\n    # See you at EuroPython\n    null: This is madness   # yo\n    gh: https://github.com/{0}.git\n\"Yay #python\": Cool!\n```\n\n### Output Python dict\n\n```python\n{\n    u\"default_context\": {\n        u\"greeting\": u\"こんにちは\",\n        u\"email\": u\"raphael@hackebrot.de\",\n        u\"docs\": True,\n        u\"gui\": False,\n        u\"lektor\": \"0.0.0.0:5000\",\n        u\"relative-root\": \"/\",\n        123: 456.789,\n        u\"some:int\": 1000000,\n        u\"foo\": u\"hallo #welt\",\n        u\"longtext\": (\n            u\"This is a multiline string. It can contain all \"\n            u\"manners of characters.\\nSingle line breaks are \"\n            u\"ignored, but blank linkes cause line breaks.\\n\"\n        ),\n        u\"trueish\": u\"Falseeeeeee\",\n        u\"blog\": u\"raphael.codes\",\n        u\"doc_tools\": [u\"mkdocs\", u\"sphinx\", None],\n    },\n    u\"zZz\": True,\n    u\"NullValue\": None,\n    u\"Hello World\": {\n        None: u\"This is madness\",\n        u\"gh\": u\"https://github.com/{0}.git\",\n    },\n    u\"Yay #python\": u\"Cool!\",\n}\n```\n\n## Logging\n\npoyo follows the recommendations for [logging in a library][logging], which\nmeans it does not configure logging itself. Its root logger is named ``poyo``\nand the names of all its children loggers track the package/module hierarchy.\npoyo logs to a ``NullHandler`` and solely on ``DEBUG`` level.\n\nIf your application configures logging and allows debug messages to be shown,\nyou will see logging when using poyo. The log messages indicate which parser\nmethod is used for a given string as the parser deseralizes the config. You\ncan remove all logging from poyo in your application by setting the log level\nof the ``poyo`` logger to a value higher than ``DEBUG``.\n\n[logging]: https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library\n\n### Disable Logging\n\n```python\nimport logging\n\nlogging.getLogger(\"poyo\").setLevel(logging.WARNING)\n```\n\n### Example Debug Logging Config\n\n```python\nimport logging\nfrom poyo import parse_string\n\nlogging.basicConfig(level=logging.DEBUG)\n\nCONFIG = \"\"\"\n---\ndefault_context: # foobar\n    greeting: こんにちは\n    gui: FALSE\n    doc_tools:\n        # docs or didn't happen\n        -    mkdocs\n        - 'sphinx'\n    123: 456.789\n\"\"\"\n\nparse_string(CONFIG)\n```\n\n### Example Debug Logging Messages\n\n```text\nDEBUG:poyo.parser:parse_blankline \u003c- \\n\nDEBUG:poyo.parser:parse_blankline -\u003e IGNORED\nDEBUG:poyo.parser:parse_dashes \u003c- ---\\n\nDEBUG:poyo.parser:parse_dashes -\u003e IGNORED\nDEBUG:poyo.parser:parse_section \u003c- default_context: # foobar\\n\nDEBUG:poyo.parser:parse_str \u003c- default_context\nDEBUG:poyo.parser:parse_str -\u003e default_context\nDEBUG:poyo.parser:parse_section -\u003e \u003cSection name: default_context\u003e\nDEBUG:poyo.parser:parse_simple \u003c-     greeting: \\u3053\\u3093\\u306b\\u3061\\u306f\\n\nDEBUG:poyo.parser:parse_str \u003c- greeting\nDEBUG:poyo.parser:parse_str -\u003e greeting\nDEBUG:poyo.parser:parse_str \u003c- \\u3053\\u3093\\u306b\\u3061\\u306f\nDEBUG:poyo.parser:parse_str -\u003e \\u3053\\u3093\\u306b\\u3061\\u306f\nDEBUG:poyo.parser:parse_simple -\u003e \u003cSimple name: greeting, value: \\u3053\\u3093\\u306b\\u3061\\u306f\u003e\nDEBUG:poyo.parser:parse_simple \u003c-     gui: FALSE\\n\nDEBUG:poyo.parser:parse_str \u003c- gui\nDEBUG:poyo.parser:parse_str -\u003e gui\nDEBUG:poyo.parser:parse_false \u003c- FALSE\nDEBUG:poyo.parser:parse_false -\u003e False\nDEBUG:poyo.parser:parse_simple -\u003e \u003cSimple name: gui, value: False\u003e\nDEBUG:poyo.parser:parse_list \u003c-     doc_tools:\\n        # docs or didn't happen\\n        -    mkdocs\\n        - 'sphinx'\\n\nDEBUG:poyo.parser:parse_str \u003c- mkdocs\nDEBUG:poyo.parser:parse_str -\u003e mkdocs\nDEBUG:poyo.parser:parse_str \u003c- 'sphinx'\nDEBUG:poyo.parser:parse_str -\u003e sphinx\nDEBUG:poyo.parser:parse_str \u003c- doc_tools\nDEBUG:poyo.parser:parse_str -\u003e doc_tools\nDEBUG:poyo.parser:parse_list -\u003e \u003cSimple name: doc_tools, value: ['mkdocs', 'sphinx']\u003e\nDEBUG:poyo.parser:parse_simple \u003c-     123: 456.789\\n\nDEBUG:poyo.parser:parse_int \u003c- 123\nDEBUG:poyo.parser:parse_int -\u003e 123\nDEBUG:poyo.parser:parse_float \u003c- 456.789\nDEBUG:poyo.parser:parse_float -\u003e 456.789\nDEBUG:poyo.parser:parse_simple -\u003e \u003cSimple name: 123, value: 456.789\u003e\nDEBUG:poyo.parser:parse_simple \u003c-     docs: true\\n\nDEBUG:poyo.parser:parse_str \u003c- docs\nDEBUG:poyo.parser:parse_str -\u003e docs\nDEBUG:poyo.parser:parse_true \u003c- true\nDEBUG:poyo.parser:parse_true -\u003e True\nDEBUG:poyo.parser:parse_simple -\u003e \u003cSimple name: docs, value: True\u003e\n```\n\n## About this project\n\nWe created this project to work around installation issues with a\n[cookiecutter][cookiecutter] version that depended on existing YAML parsers\nfor Python. For more information please check out this [GitHub issue][issue].\n\n[issue]: https://github.com/cookiecutter/cookiecutter/pull/621\n\n## Community\n\nWould you like to contribute to **poyo**? You're awesome! 😃\n\nPlease check out the [good first issue][good first issue] label for tasks,\nthat are good candidates for your first contribution to poyo. Your\ncontributions are greatly appreciated! Every little bit helps and credit will\nalways be given.\n\nEveryone interacting in the poyo project's codebases, issue trackers, chat\nrooms, and mailing lists is expected to follow the [PyPI Code of\nConduct][code of conduct].\n\nJoin the poyo [community][community]! 🌍🌏🌎\n\n[code of conduct]: https://www.pypa.io/en/latest/code-of-conduct/\n[community]: https://github.com/hackebrot/poyo/blob/master/COMMUNITY.md\n[good first issue]: https://github.com/hackebrot/poyo/labels/good%20first%20issue\n\n## License\n\nDistributed under the terms of the [MIT][MIT] license, poyo is free and open source\nsoftware.\n\n[MIT]: https://github.com/hackebrot/poyo/blob/master/LICENSE\n\n[cookiecutter]: https://github.com/cookiecutter/cookiecutter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackebrot%2Fpoyo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackebrot%2Fpoyo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackebrot%2Fpoyo/lists"}