Skip to main content

hifiyaml

A high-fidelity WYSIWYG YAML parser and emitter that preserves exact formatting, including comments, anchors, aliases, blank lines, and indentation.
Check the more detailed User Guide
Check wiki at https://github.com/hifiyaml/hifiyaml/wiki

Installation

pip install hifiyaml

Quick demo

1. Get an example YAML file

Use jedivar.yaml from the RRFSv2 system as an example.

wget https://raw.githubusercontent.com/NOAA-EMC/rrfs-workflow/refs/heads/rrfs-mpas-jedi/parm/jedivar.yaml

2. Load the YAML data and dump a YAML block using a querystr

Write the following statments into test.py:

import hifiyaml as hy
data = hy.load("jedivar.yaml")
querystr = "cost function/background error/components/1"
hy.dump(data, querystr)   # dump to stdout
hy.dump(data, querystr, 'ensbec.yaml')   # dump to the file 'ensbec.yaml'

run cd tests; ./test.sh and then check the output yaml files

NOTE: A querystr is a string describing the path from a unique higher level key (or index if a list) to the destination level key (or index), separated with /.
For the following simple YAML file,

demo:
  configuration:
    suite: YAML
    detail:
      - meaning:
          - Y: Yelling
          - A: At
          - M: My
          - L: Laptop

A query string demo/configuration/detail/0/meaning will return one dictionary item with "meaning" as the key and a list of 4 items as the value, i.e:

- meaning:
    - Y: Yelling
    - A: At
    - M: My
    - L: Laptop

3. Availabe functions.

hifiyaml currently provides the following functions:

load, get, dump, drop, modify, next_pos, get_start_pos, dedent, text_to_yblock, strip_indentations, strip_leading_empty_lines

Testing

pip install pytest
python3 -m pytest tests/test_hifiyaml.py -v

and use the shell-based diff tests:

cd tests; ./test.sh

Metadata

Release files for hifiyaml 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hifiyaml 0.2.2
File Size Uploaded Provenance Actions
hifiyaml-0.2.2.tar.gz 15.6 kB Without provenance Details for hifiyaml-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hifiyaml 0.2.2
File Interpreter ABI Platform Actions
hifiyaml-0.2.2-py3-none-any.whl Python 3 none any Details for hifiyaml-0.2.2-py3-none-any.whl

Total release size: 25.7 kB

Release files / hifiyaml-0.2.2.tar.gz

Download URL hifiyaml-0.2.2.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f632aee6b8cd3a142393bccdbc588c1cc2b25f208bf64f1f7fc0ebc1d6dbb87b
BLAKE2b-256 checksum
How to use checksums
4bb019a5658ed9a80c621696bf0191faa9bb0cf724db495b184d9b231f4c5db8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / hifiyaml-0.2.2-py3-none-any.whl

Download URL hifiyaml-0.2.2-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc88f29a05ca31f7fc8389c9bfa81a6389772c72cf52f992d3fbf3c2a1dc2a54
BLAKE2b-256 checksum
How to use checksums
c87dd3e213a838ebb61d0fa0f8f06347cd25842cb8efe439793969f1a325ca19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Security for hifiyaml 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page