YAML-MAKO
These are the facts:
Let’s have them both!
Installation
$ pip install yaml-mako
Example
Here’s our yaml document, describint a general subscription, say to a newsletter:
---
name: "subscription"
details:
start time: ${start_date}
end time: ${end_date}
comment: dates should appear above after temlating
If you load this as plain YAML
, you will get the equivalent of
{'details': {'comment': 'dates should appear above after temlating',
'end time': '${end_date}',
'start time': '${start_date}'},
'name': 'subscription'}
Using yaml-mako
you can to this:
import yaml_mako
import pprint
import datetime
stream = open('example.yaml')
today = datetime.date.today()
tomorrow = today + datetime.timedelta(1)
pprint.pprint(yaml_mako.load(stream, start_date = today, end_date = tomorrow))
And we get:
{'details': {'comment': 'dates should appear above after temlating',
'end time': datetime.date(2017, 1, 24),
'start time': datetime.date(2017, 1, 23)},
'name': 'subscription'}