YAML 1.2 Support for PyYAML
Project description
pyyaml-core - YAML 1.2 Core Schema Support for PyYAML
This module can be used on top of PyYAML to load YAML 1.2 files. It depends on PyYAML and inherits from it, it's not a fork.
Currently it supports enabling all YAML 1.2 Core Schema tags on top
of the PyYAML BaseLoader.
It does not (yet) support other tags like the <<
merge key.
You can add custom constructors, though.
For more information see the comparison of 1.1 and 1.2 schemas.
Examples
import yaml
from yamlcore import CoreLoader
from yamlcore import CoreDumper
y = """
---
1.1: # strings
- yes
- no # norway problem anymore
- 1__0
- 10:20
- +0b100
- 0x4_2
core:
- true
- 0o10
- 0x42
- ~
- .inf
"""
d = yaml.load(y, Loader=CoreLoader)
out = yaml.dump(d, Dumper=CoreDumper)
You can also use CCoreLoader
and CCoreDumper
for using the
libyaml based parser and emitter.
Why?
At the time of this writing, there is a pending pull request that adds YAML 1.2 Core Schema Support for PyYAML.
It's blocked because there is a plan to redesign the API, and no new things shall be added using the old API at this point.
So as long as PyYAML doesn't merge this, you can use this module as an alternative.
MIT License
Copyright (c) 2024 Tina Müller (tinita)
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:
The above copyright notice and this permission notice shall be included in all 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.
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
Built Distribution
File details
Details for the file yamlcore-0.0.2.tar.gz
.
File metadata
- Download URL: yamlcore-0.0.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b2eb9541cbe16af97b12cbdc36fab92a8c6f58fc898bd68651e959e7d8e926f |
|
MD5 | 9e054b827fa0137d9695595a6501d77b |
|
BLAKE2b-256 | 79fb158e86aecd3c2f8de4b6489fc9cf92c1b5683d3abdf00751e063a803767e |
File details
Details for the file yamlcore-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: yamlcore-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 497006b7e7fccfaae564a40754eaf07969532321e21c8b77774dfd24492a6611 |
|
MD5 | 64c1a3cb901ea977cf153b2589a0aebe |
|
BLAKE2b-256 | 0867ab44218f690b02f5e85cf7db82e3048567d040fecae04c316fb908e1042a |