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

Load multiple documents #11

Closed shaunc closed 4 years ago

shaunc commented 4 years ago

If I have one document such as (foo.yaml):

!include ./baz.yaml
!include ./baz.yaml

and baz.yaml looks like:

baz1: x
---
baz2: y

I would like this to be interpreted as:

baz1: x
---
baz2: y
---
baz1: x
---
baz2: y

Is there any way to achieve this? Currently, even if I use load_all() my current setup fails with error.

tanbro commented 4 years ago

I think it's not possible for the library.

Since :

  1. the library load including files by a pyYAML Constructor, what loaded can be only inside a document.

  2. Till now, the library loads an including YAML file with yaml.load(). Of course we can change it to full_load(), but still it can not make a "Multi-Docs", it will return an iterable(convert to list?)

shaunc commented 4 years ago

Yes ... would seem to need a change in pyyaml so that the Constructor could return document(s), not document fragments. I guess I'll close. Thanks for looking into it.