-
Notifications
You must be signed in to change notification settings - Fork 0
/
breadplan.py
executable file
·105 lines (90 loc) · 3.82 KB
/
breadplan.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3.4
from docopt import docopt
from tabulate import tabulate
doc = """BreadPlan
Usage:
breadplan.py basic [-sh] [-y=PERCENT] [-l=LOAVES]
breadplan.py baguette [-sh] [-y=PERCENT] [-l=LOAVES]
breadplan.py rye [-sh] [-y=PERCENT] [-l=LOAVES]
breadplan.py wholewheat [-sh] [-y=PERCENT] [-l=LOAVES]
Options:
-y PERCENT --hydration=PERCENT Specifies the hydration percentage [default: 75]
-l LOAVES --loaves LOAVES Specifies the number of loaves you'd like to bake [default: 2]
-h --help Displays this help message.
-s --sugar Whether or not to add sugar for the crust.
"""
WATER = 240 # Assume water has a density of 1 gram
SALT = 273
TBSP_PER_CUP = 16
# See http://nbviewer.ipython.org/github/hawkw/breadplan/blob/master/Breadplan%20Science.ipynb
# for the math behind these density values.
BREAD_FLOUR = 127.33333333333333
ALL_PURPOSE = 125.0
WHOLE_WHEAT = 122.0
RYE = 103.66666666666667
FIFTY_FIFTY = (BREAD_FLOUR + WHOLE_WHEAT)/2
water_grams_to_cup = lambda grams: round(grams / WATER, 1)
flour_grams_to_cup = lambda grams, flour: round(grams/flour, 1)
leaven_grams_to_cup = lambda grams: round((((grams/2) / FIFTY_FIFTY) +
((grams/2) / WATER))/2, 1)
salt_grams_to_tbsp = lambda grams: round((grams / SALT) / TBSP_PER_CUP, 1)
def basic_country(loaves=2, hydration=75, sugar=True):
water = water_grams_to_cup(375*loaves)
leaven = leaven_grams_to_cup(100*loaves)
white = flour_grams_to_cup(450*loaves, BREAD_FLOUR)
wheat = flour_grams_to_cup(50*loaves, WHOLE_WHEAT)
salt = salt_grams_to_tbsp(loaves * 10)
table = [
["Water (80F)",
"{} cups".format(water), "{:.0F}%".format(hydration)],
["Leaven",
"{} cups".format(leaven), "20%"],
["White Flour",
"{} cups".format(white), "90%"],
["Whole Wheat Flour",
"{} cups".format(wheat), "10%"],
["Salt",
"{} Tbsp".format(salt), "2%"]
]
if sugar:
table.append(["Sugar", "{} Tbsp".format(.5*loaves)])
print ("Recipe for {l:.0F} loaves of Basic Country Bread:\n"
.format(l=loaves))
print (tabulate(table, headers=["Ingredient", "Quantity", "%"]))
def whole_wheat(loaves=2, hydration=80, sugar=True):
water = water_grams_to_cup(400*loaves)
leaven = leaven_grams_to_cup(100*loaves)
wheat = flour_grams_to_cup(450*loaves, WHOLE_WHEAT)
all_purp = flour_grams_to_cup(50*loaves, ALL_PURPOSE)
salt = salt_grams_to_tbsp(loaves * 10)
table = [
["Water (80F)",
"{} cups".format(water), "{:.0F}%".format(hydration)],
["Leaven",
"{} cups".format(leaven), "20%"],
["Whole Wheat Flour",
"{} cups".format(wheat), "70%"],
["All Purpose Flour",
"{} cups".format(all_purp), "30%"],
["Salt", "{} Tbsp".format(salt), "2%"]
]
if sugar:
table.append(["Sugar", "{} Tbsp".format(.5*loaves)])
print ("Recipe for {l:.0F} loaves of Whole Wheat Bread:\n"
.format(l=loaves))
print (tabulate(table, headers=["Ingredient", "Quantity", "%"]))
if __name__ == "__main__":
opts = docopt(doc, help=True, version="0.1")
if opts["basic"]:
basic_country(
float(opts["--loaves"]),
float(opts["--hydration"]),
opts["--sugar"])
elif opts["wholewheat"]:
whole_wheat(
float(opts["--loaves"]),
float(opts["--hydration"]),
opts["--sugar"])
else:
print ("Sorry, breads other than the Basic Country Bread" +
"are not currently supported")