- A few
- Cool
- Things
Get the newest development version via:
pip install git+https://github.com/childmindresearch/yamerge
usage: main.py [-h] [-o OUTPUT] [-p PATHS] [-d] input
Preprocessor for YAML files. Merge data from other YAML files via tags:
`MERGE: file/path.yml` (absolute / same YAML structure) `MERGE-SNIPPET:
path/to/snippet.yml` (relative / merge full YAML).
positional arguments:
input YAML input filepath
optional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
YAML output filepath (If this is not specified result
will be printed to console)
-p PATHS, --paths PATHS
Source directories for yaml files. Default: Working
directory (Seperate multiple with `|`. E.g.:
`/some/folder|../another/one`)
-d, --debug Print debug information
Merge specific branch from other completely defined YAML file into input YAML.
- Both files have to have the same structure
- Will only merge all child-nodes from where the
MERGE
tag is nested - Caveat: Does not work nested within lists (as there is no stable key/index in lists)
→ Relative merge is a list-compatible alternative
# file_1.yml
foo:
MERGE: file_2.yml
a: 1
b: 7
x:
y: baz
# file_2.yml
foo:
b: 999
c: 42
x:
z: bar
this_will_not_be_merged: because MERGE was nested under 'foo'
# yamerge file_1.yml
foo:
a: 1
b: 7 # <- this was already defined in 'file_1.yml'
c: 42 # <- this was merged from 'file_2.yml'
x:
y: baz
z: bar
Merge specific branch from a config ‘snippet’ file into input YAML.
- Merge complete YAML file at the location of the
MERGE-SNIPPET
tag. - Works within lists.
# some_file.yml
steps:
- step-1:
a: 1
b: 1
- step-2:
MERGE-SNIPPET: some_snippet.yml
a: 0
- step-3:
a: hello
b: hi
# some_snippet.yml
a: 1.61803398875
b: 3.14159265359
# yamerge some_file.yml
steps:
- step-1:
a: 1
b: 1
- step-2:
a: 0
b: 3.14159265359 # <- this got merged
- step-3:
a: hello
b: hi