dynamic values in yaml

Laurent Pointal laurent.pointal at laposte.net
Tue Aug 19 13:01:03 EDT 2014


raphinou at gmail.com wrote:

> Hi,
> 
> I'm using pyyaml, and need some values in a yaml files to be dynamic, 
for
> example somethin like:
> 
>   filename: /tmp/backup_{% time.strftime('%Y-%m-%d') }.tgz
> 
> Is there a simple way to achieve this? (Eg with a templating system 
that
> would first handle the template parts from the yaml file)
> 
> Thanks

I used jinja2 templating system to build (render) the yaml string 
representation before processing it with yaml.

But for a simple use, maybe a direct keyword replacement is easier (but 
gives less control in the template, more in the code).




More information about the Python-list mailing list