YAML Where?
yaml_where calculates source maps for YAML files, allowing you to correlate file locations with elements in
YAML documents.
Installation
$ pip install yaml-where
Examples
Mappings
Find the range containg the key and value of a map entry:
source_map = YAMLWhere.from_string("a: 1\nb: 42")
assert source_map.get_range(Item("b")) == Range(Position(1, 0), Position(1, 5))
Or get the range of just the key:
source_map = YAMLWhere.from_string("a: 1\nb: 42")
assert source_map.get_range(Key("a")) == Range(Position(0, 0), Position(0, 1))
Or just the value:
source_map = YAMLWhere.from_string("a: 1\nb: 42")
assert source_map.get_range(Value("b")) == Range(Position(1, 3), Position(1, 5))
You can also look up nested locations:
yaml = """a:
b: 42
c:
doo: hola
"""
source_map = YAMLWhere.from_string(yaml)
assert source_map.get_range(Value("a"), Key("b")) == Range(Position(1, 4), Position(1, 5))
assert source_map.get_range(Value("a"), Key("c")) == Range(Position(2, 4), Position(2, 5))
assert source_map.get_range(Value("a"), Value("c"), Key("doo")) == Range(Position(3, 8), Position(3, 11))
Sequences
You can also find ranges for sequence elements:
yaml = """[1,
a, foo,
indented]
"""
source_map = YAMLWhere.from_string(yaml)
assert source_map.get_range(Index(0)) == Range(Position(0, 1), Position(0, 2))
assert source_map.get_range(Index(1)) == Range(Position(1, 1), Position(1, 2))
assert source_map.get_range(Index(2)) == Range(Position(1, 4), Position(1, 7))
assert source_map.get_range(Index(3)) == Range(Position(3, 5), Position(3, 13))
CI/CD
Tests will be run on every push to Github.
Use the "bump-and-publish" job in Github Actions to make new releases.
Metadata
Release files for yaml-where 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yaml_where-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for yaml_where-2.0.0-py3-none-any.whl |
Release files / yaml_where-2.0.0-py3-none-any.whl
| Download URL | yaml_where-2.0.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba3bc49a2e70badf4e98f73908d70f82824fde87e9a0a93eaf7269c62878ead3
|
|
BLAKE2b-256 checksum How to use checksums |
7d2cd74c5423d6501dc8b951444dcf33b83095b5cc4bb837fc96bbfafb45fab9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for yaml-where 2.0.0
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.