All Projects → ethanhs → ryaml

ethanhs / ryaml

Licence: MIT license
Python yaml library using Rust

Programming Languages

python
139335 projects - #7 most used programming language
rust
11053 projects

Projects that are alternatives of or similar to ryaml

bucky-core
System testing framework for web application.
Stars: ✭ 32 (+128.57%)
Mutual labels:  yaml
Prinder
Free Pull Request reminder for Github. Has configurations to post reminders to Slack and email along with jinja templating
Stars: ✭ 21 (+50%)
Mutual labels:  yaml
go-config
Configuration file loader for Go
Stars: ✭ 27 (+92.86%)
Mutual labels:  yaml
gitlabform
🏗 Specialized "configuration as a code" tool for GitLab
Stars: ✭ 332 (+2271.43%)
Mutual labels:  yaml
gen-cisco
🧨 Generates Cisco scripts based on YAML files
Stars: ✭ 29 (+107.14%)
Mutual labels:  yaml
paerser
No description or website provided.
Stars: ✭ 38 (+171.43%)
Mutual labels:  yaml
pytickersymbols
Fundamental stock data and yahoo/google ticker symbols for several indices.
Stars: ✭ 69 (+392.86%)
Mutual labels:  yaml
AUCR
Analyst Unknown Cyber Range - a micro web service framework
Stars: ✭ 24 (+71.43%)
Mutual labels:  yaml
remark-frontmatter
remark plugin to support frontmatter (YAML, TOML, and more)
Stars: ✭ 167 (+1092.86%)
Mutual labels:  yaml
icingaweb2-module-fileshipper
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Stars: ✭ 25 (+78.57%)
Mutual labels:  yaml
zf-dependency-injection
Advanced dependency injection for laminas framework
Stars: ✭ 17 (+21.43%)
Mutual labels:  yaml
eslint-plugin-yml
This ESLint plugin provides linting rules for YAML.
Stars: ✭ 40 (+185.71%)
Mutual labels:  yaml
obp-apis
OpenBankingProject.ch Community APIs
Stars: ✭ 18 (+28.57%)
Mutual labels:  yaml
representable
Maps representation documents from and to Ruby objects. Includes JSON, XML and YAML support, plain properties and compositions.
Stars: ✭ 689 (+4821.43%)
Mutual labels:  yaml
consulator
Import and synchronize your Consul KV data from JSON and YAML
Stars: ✭ 27 (+92.86%)
Mutual labels:  yaml
hikaru
Move smoothly between Kubernetes YAML and Python for creating/updating/componentizing configurations.
Stars: ✭ 60 (+328.57%)
Mutual labels:  yaml
coqpit
Simple but maybe too simple config management through python data classes. We use it for machine learning.
Stars: ✭ 67 (+378.57%)
Mutual labels:  yaml
elk
🦌 Minimalist yaml based task runner
Stars: ✭ 43 (+207.14%)
Mutual labels:  yaml
HsYAML
YAML 1.2 implementation in pure Haskell
Stars: ✭ 50 (+257.14%)
Mutual labels:  yaml
kahoy
Simple Kubernetes raw manifests deployment tool
Stars: ✭ 33 (+135.71%)
Mutual labels:  yaml

ryaml

Quickly and safely parse yaml

What is ryaml?

ryaml is a Python library that wraps a Rust yaml parser, serde-yaml, to quickly and safely parse and dump yaml to and from Python objects.

It is not compatible with PyYAML, but has a similar design to the json module.

The hope is this will be used as a safe and fast yaml parser in lieu of PyYAML.

Installation

We ship binary wheels for Windows, Linux, and macOS, so as long as you are using Python 3.7+, you can run:

$ python -m pip install ryaml

Otherwise, you will need to build from source. To do so, first install Rust 1.41 stable.

Then you should be able to just

$ git clone https://github.com/ethanhs/ryaml
$ cd ryaml
$ python -m pip install .

Or if you want to build a wheel:

$ git clone https://github.com/ethanhs/ryaml
$ cd ryaml
$ python -m pip install maturin
$ maturin build --release --no-sdist
# OR if you want an abi3 wheel (compatible with Python 3.7+)
$ maturin build --release --no-sdist --cargo-extra-args="--features=abi3"

And a wheel will be created in target/wheels which you can install.

Usage

The API of ryaml is very similar to that of json in the standard library:

You can use ryaml.loads to read from a str:

import ryaml
obj = ryaml.loads('key: [10, "hi"]')
assert isinstance(obj, dict) # True
assert obj['key'][1] == "hi" # True

And ryaml.dumps to dump an object into a yaml file:

import ryaml
s = ryaml.dumps({ 'key' : None })
print(s)
# prints:
# ---
# key: ~

There are also ryaml.load and ryaml.load_all to read yaml document(s) from files:

import ryaml
obj = {'a': [{'b': 1}]}
with open('test.yaml', 'w') as w:
    ryaml.dump(w, obj)
with open('test.yaml', 'r') as r:
    assert ryaml.load(r) == obj
with open('multidoc.yaml', 'w') as multi:
    multi.write('''
---
a:
  key:
...
---
b:
  key:
    ''')
with open('multidoc.yaml', 'r') as multi:
    docs = ryaml.load_all(multi)
assert len(docs) == 2
assert docs[0]['a']['key'] is None

ryaml.load_all will, as seen above, load multiple documents from a single file.

Thanks

This project is standing on the shoulders of giants, and would not be possible without:

pyo3

serde-yaml

yaml-rust

pyo3-file

pythonize

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].