Skip to main content

High-fidelity YAML parser that preserves formatting

Project description

hifiyaml

High-fidelity YAML parser that preserves formatting.
Original YAML structure and formatting are preserved, including comments, anchors, aliases, etc.

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 a file

run python test.py, check the stdout and the ensbec.yaml file.

NOTE: A querystr is a string describing the path from the top 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. More is coming soon.

hifiyaml currently provides the following functions:

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

More information will be added soon.

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

hifiyaml-0.1.2.tar.gz (14.4 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.1.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hifiyaml-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5282619e7b7894be95aaf15e56348832f8af6cd4fc8c340b62badaa54cc7c34a
MD5 ea6d02e5561a4449898fc33550eb6312
BLAKE2b-256 132228bc134c06973b8967397f1e4702570d85e7d27c8bc6025d1cb5f111efbc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hifiyaml-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63f1014ec350ff0f872a8bcb0711d149a275bd2ace6e45111ed693f45e6be2d8
MD5 6612f6151c5e909bac00f67369ac5262
BLAKE2b-256 88f0f00e1219341462caa19448aca511d3ab75cf6d5478f4f3d020fbdd88a774

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page