https://github.com/aboutcode-org/saneyaml
Cleaner, simpler, safer and saner YAML parsing/serialization in Python, for YAML meant to be readable first, on top of PyYAML
https://github.com/aboutcode-org/saneyaml
Last synced: 6 months ago
JSON representation
Cleaner, simpler, safer and saner YAML parsing/serialization in Python, for YAML meant to be readable first, on top of PyYAML
- Host: GitHub
- URL: https://github.com/aboutcode-org/saneyaml
- Owner: aboutcode-org
- Created: 2017-12-04T15:03:07.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-30T14:48:06.000Z (9 months ago)
- Last Synced: 2025-06-17T03:26:13.997Z (7 months ago)
- Language: Python
- Size: 501 KB
- Stars: 9
- Watchers: 10
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.rst
- Code of conduct: CODE_OF_CONDUCT.rst
- Authors: AUTHORS.rst
Awesome Lists containing this project
README
========
saneyaml
========
This micro library is a PyYaml wrapper with sane behaviour to read and
write readable YAML safely, typically when used with configuration files.
With saneyaml you can dump readable and clean YAML and load safely any YAML
preserving ordering and avoiding surprises of type conversions by loading
everything except booleans as strings.
Optionally you can check for duplicated map keys when loading YAML.
Works with Python 3. Requires PyYAML 5.x or higher.
license: apache-2.0
homepage_url: https://github.com/aboutcode-org/saneyaml
Usage::
pip install saneyaml
>>> from saneyaml import load
>>> from saneyaml import dump
>>> a=load('''version: 3.0.0.dev6
...
... description: |
... AboutCode Toolkit is a tool to process ABOUT files. An ABOUT file
... provides a way to document a software component.
... ''')
>>> a
dict([
(u'version', u'3.0.0.dev6'),
(u'description', u'AboutCode Toolkit is a tool to process ABOUT files. '
'An ABOUT file\nprovides a way to document a software component.\n')])
>>> pprint(a.items())
[(u'version', u'3.0.0.dev6'),
(u'description',
u'AboutCode Toolkit is a tool to process ABOUT files. An ABOUT file\nprovides a way to document a software component.\n')]
>>> print(dump(a))
version: 3.0.0.dev6
description: |
AboutCode Toolkit is a tool to process ABOUT files. An ABOUT file
provides a way to document a software component.