Now, if you run emrichen --output-file a.yaml a.in.yaml, the resulting a.yaml will only contain
b: 3
instead of
a: 1
b: 3
because --output-file a.yaml is opened at application startup with w mode, truncating the file, and !Include a.yaml enriches to {}.
I would like to change this so that !Include a.yaml here would enrich to the original contents of a.yaml, and a.yaml would be opened for writing only after enriching the template.
Absolutely makes sense. To avoid having to buffer the output to memory before writing, maybe the file should be opened with w+, sought to the beginning and then truncated at the start of write?
Consider the following files:
Now, if you run
emrichen --output-file a.yaml a.in.yaml
, the resultinga.yaml
will only containinstead of
because
--output-file a.yaml
is opened at application startup withw
mode, truncating the file, and!Include a.yaml
enriches to{}
.I would like to change this so that
!Include a.yaml
here would enrich to the original contents ofa.yaml
, anda.yaml
would be opened for writing only after enriching the template.