GithubHelp home page GithubHelp logo

yamerge's Introduction

yamerge: YAML file preprocessor

Usage

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

Absolute merge (MERGE)

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

Relative merge (MERGE-SNIPPET)

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

yamerge's People

Contributors

clane9 avatar nx10 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.