Line information for ruamel.yaml.
Project description
ruamel_yaml_line_info
Line information for ruamel.yaml.
Quick Start
Using an Alternative Constructor
Instead of:
with open(yaml_path, encoding="utf-8") as fh:
yaml = ruamel.yaml.YAML(typ="rt").load("".join(fh))
change the import:
with open(yaml_path, encoding="utf-8") as fh:
yaml = ruamel_yaml_line_info.YAML(typ="rt").load("".join(fh))
and voila!
Example
Consider the following YAML:
foo: bar
block: >
this is not
a multiline
block
single_quote: 'single'
double_quote: "double"
then we can get line and column information with
>>> with open(yaml_path, encoding="utf-8") as fh:
yaml = ruamel_yaml_line_info.YAML(typ="rt").load("".join(fh))
>>> print(yaml["foo"].lc)
LineCol(0, 5)
>>> print(yaml["block"].lc)
LineCol(1, 7)
>>> print(yaml["single_quote"].lc)
LineCol(5, 14)
>>> print(yaml["double_quote"].lc)
LineCol(6, 14)
where the first value in LineCol is the 0-based line, and the second value in LineCol is the 0-based column.
See the test for more exapmles.
Patching an existing YAML object
If you already have a ruamel.yaml.YAML instance, you can add line
numbers with:
with open(yaml_path, encoding="utf-8") as fh:
yaml = ruamel.yaml.YAML(typ="rt").load("".join(fh))
yaml = ruamel_yaml_line_info.YAML.with_line_numbers(yaml=yaml)
Recommended Installation
Install the Python package and dependency management tool poetry using official documentation.
You must have Python 3.11 or greater available on your system path, which could be managed by mamba, pyenv, or another package manager.
Finally, install the dependencies of the project with:
poetry install
To check successful installation, run:
python -c "import ruamel_yaml_line_info"
Installing with Conda
Install the environment manager mamba using official documentation.
Create and activate a conda environment with Python 3.11 or greater:
mamba create -c conda-forge -n ruamel_yaml_line_info ruamel-yaml-line-info python=3.11
mamba activate ruamel_yaml_line_info
Alternatively, install into an existing conda environment:
mamba install -n <ENVIRONMENT> -c conda-forge ruamel-yaml-line-info
To check successful installation, run:
python -c "import ruamel_yaml_line_info"
Development and Testing
See the contributing guide for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ruamel_yaml_line_info-0.1.4.tar.gz.
File metadata
- Download URL: ruamel_yaml_line_info-0.1.4.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cb81a11671a341693af713c70d0b58e0cee2b39ece4ffb413a333c91edd21f8
|
|
| MD5 |
79826d67350af5ca51d2268a6753427e
|
|
| BLAKE2b-256 |
85276c0b8435ae920f4c7baeb5d34ff9a64d9306e0baaadf263656fe98876a94
|
Provenance
The following attestation bundles were made for ruamel_yaml_line_info-0.1.4.tar.gz:
Publisher:
publish.yml on nh13/ruamel_yaml_line_info
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruamel_yaml_line_info-0.1.4.tar.gz -
Subject digest:
8cb81a11671a341693af713c70d0b58e0cee2b39ece4ffb413a333c91edd21f8 - Sigstore transparency entry: 206966743
- Sigstore integration time:
-
Permalink:
nh13/ruamel_yaml_line_info@0dce3dfb080b210bc9c0b8a93585d5dfec3af69d -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/nh13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0dce3dfb080b210bc9c0b8a93585d5dfec3af69d -
Trigger Event:
push
-
Statement type:
File details
Details for the file ruamel_yaml_line_info-0.1.4-py3-none-any.whl.
File metadata
- Download URL: ruamel_yaml_line_info-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f168a894f8608edcb2da21feb9cbf207160ea9dbcb40c0e47f5a144faa469f9
|
|
| MD5 |
bece07c2fc2e35100f27db9414097b23
|
|
| BLAKE2b-256 |
5dfcc42dc4d5f01d66ec70126f9d1c61920adf1466c59855b8dd8fcd813a6f4a
|
Provenance
The following attestation bundles were made for ruamel_yaml_line_info-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on nh13/ruamel_yaml_line_info
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ruamel_yaml_line_info-0.1.4-py3-none-any.whl -
Subject digest:
5f168a894f8608edcb2da21feb9cbf207160ea9dbcb40c0e47f5a144faa469f9 - Sigstore transparency entry: 206966745
- Sigstore integration time:
-
Permalink:
nh13/ruamel_yaml_line_info@0dce3dfb080b210bc9c0b8a93585d5dfec3af69d -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/nh13
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0dce3dfb080b210bc9c0b8a93585d5dfec3af69d -
Trigger Event:
push
-
Statement type: