-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpale_ale_parser.py
57 lines (48 loc) · 1.43 KB
/
pale_ale_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from brew.parsers import JSONDataLoader
from brew.parsers import parse_recipe
"""
Build a recipe using data parsers.
"""
def main():
recipe = {
u"name": u"Pale Ale",
u"start_volume": 7.0,
u"final_volume": 5.0,
u"grains": [
{
u"name": u"pale malt 2-row us",
u"data": {u"color": 1.8, u"ppg": 37},
u"weight": 13.96,
},
{
u"name": u"caramel crystal malt 20l",
u"data": {u"color": 20.0, u"ppg": 35},
u"weight": 0.78,
},
],
u"hops": [
{
u"name": u"centennial",
u"data": {u"percent_alpha_acids": 0.14},
u"weight": 0.57,
u"boil_time": 60.0,
},
{
u"name": u"cascade us",
u"data": {u"percent_alpha_acids": 0.07},
u"weight": 0.76,
u"boil_time": 5.0,
},
],
u"yeast": {u"name": u"Wyeast 1056", u"data": {u"percent_attenuation": 0.75}},
u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"},
}
data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/"))
loader = JSONDataLoader(data_dir)
beer = parse_recipe(recipe, loader)
print(beer.format())
if __name__ == "__main__":
main()