maxludden/max_yaml

This is a wrapper of PyYAML to make it easier to use. It creates functions similar to the stdlib’s ‘json’ module.

Installation

max_yaml can be installed from PyPi with your favorite package manager.

pipx(recommended)

pipx install max_yaml

pip

pip install max_yaml

poetry

poetry add max_yaml

Usage

The helper functions are familiar to any developer familiar with the JSON module from the stdlib:

import max_yaml as yaml

yaml.dump(data, file)

yaml.dumps(data)

yaml.load(file)

yaml.loads(string)

There are also some helper functions mapped to the Safe Loader and Dumper from the PyYAML library:

import max_yaml as yaml

yaml.safe_dump(data, file)

yaml.safe_dumps(data)

yaml.safe_load(file)

yaml.safe_loads(string)

All of the functions are taking advantage of the faster C Loaders and Dumpers if they are available. If not, they will fall back to the slower Python versions.

License

MIT License

Copyright (c) 2022 Maxwell Owen Ludden

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.