tanbro / pyyaml-include

yaml include other yaml
https://pypi.org/project/pyyaml-include/
GNU General Public License v3.0
77 stars 20 forks source link

include specific components from other yamls? #21

Closed havok2063 closed 3 years ago

havok2063 commented 3 years ago

Does this package let me include specific components from other yamls? For cases where I don't want to include the entire content of the yaml file. E.g something like

a.yaml

param:
  - name: A
    type: A1
  - name: B
    type: B1

stuff: 123

b.yaml

other:
   - param: !include a.yaml/param[0]

stuff: !include a.yaml/stuff

such that reading in b.yaml would result in

{
 "other": [{"param": {"name": 'A', "type": 'A1'}}]
 "stuff": 123 
}
tanbro commented 3 years ago

Unfortunately it cant.

What you want seems like XML path, perhaps there is a YAML path implementation could do it

havok2063 commented 3 years ago

Ok, thanks! For posterity, I did some googling and found this package https://pypi.org/project/yamlpath/. It uses the ruamel yaml implementation rather than pyyaml. But perhaps it's an option.