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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hifiyaml-0.2.2.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hifiyaml-0.2.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file hifiyaml-0.2.2.tar.gz.

File metadata

  • Download URL: hifiyaml-0.2.2.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for hifiyaml-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f632aee6b8cd3a142393bccdbc588c1cc2b25f208bf64f1f7fc0ebc1d6dbb87b
MD5 11ac60c461a7e1c79134f4ebb563eeca
BLAKE2b-256 4bb019a5658ed9a80c621696bf0191faa9bb0cf724db495b184d9b231f4c5db8

See more details on using hashes here.

File details

Details for the file hifiyaml-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: hifiyaml-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for hifiyaml-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc88f29a05ca31f7fc8389c9bfa81a6389772c72cf52f992d3fbf3c2a1dc2a54
MD5 f8c82a9987f431e0785f44e561ee51ee
BLAKE2b-256 c87dd3e213a838ebb61d0fa0f8f06347cd25842cb8efe439793969f1a325ca19

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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