From 1b3f6ef640be415dcafc83b4518ec373ce8a2b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20De=20Keersmaeker?= <francois.dekeersmaeker@uclouvain.be> Date: Fri, 12 Jul 2024 16:01:57 +0200 Subject: [PATCH] Updated README --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index f05fd80..17d6a9c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,47 @@ # pyyaml-loaders + +[PyPI package page](https://pypi.org/project/pyyaml-loaders/). + PyYAML loaders with enhanced functionalities. + + +## Description + +### `IgnoreLoader` + +Ignore all constructors with tag `!`. Load YAML file as is. + + +### `IncludeLoader` + +Tag: `!include` + +Include values from other fields in the same YAML file, or from other file, while potentially replacing a subfield in the included field with a given value. + +Syntax: +```yaml +!include [OTHER_FILE#]FIELD_TO_INCLUDE [SUBFIELD_TO_REPLACE:VALUE_TO_REPLACE_WITH] +``` + + +## Installation + +```bash +pip install pyyaml-loaders +``` + + +## Usage + +In preamble: + +```python +from pyyaml_loaders import IncludeLoader, IgnoreLoader +``` + +When loading YAML file: +```python +with open(yaml_file, "r") as f: + data = yaml.load(f, IncludeLoader) +``` +(or `IgnoreLoader` instead of `IncludeLoader`) -- GitLab