-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoughnut.py
More file actions
66 lines (59 loc) · 2.88 KB
/
doughnut.py
File metadata and controls
66 lines (59 loc) · 2.88 KB
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
import recipeutil
import math
class RecipeAdjuster(recipeutil.Adjuster):
def __init__(self):
recipeutil.Adjuster.__init__(self,
'Sourdough-Doughnut.template.md',
'Sourdough-Doughnut.input.json',
'Sourdough-Doughnut.out.md')
def compute_values(self):
# Read values from the JSON input file:
numberOfDoughnuts = self.get_input('numberOfDoughnuts')
doughnutWeightGrams = self.get_input('doughnutWeightGrams')
levainHydrationRatio = self.get_input_perc('levainHydrationPercent')
doughHydrationRatio = self.get_input_perc('doughHydrationPercent')
doughSeedRatio = self.get_input_perc('doughSeedPercent')
sugarToFlourRatio = self.get_input_perc('sugarToFlourPercent')
saltToFlourRatio = self.get_input_perc('saltToFlourPercent')
butterToFlourRatio = self.get_input_perc('butterToFlourPercent')
eggToFlourRatio = self.get_input_perc('eggToFlourPercent')
butterWaterContentRatio = self.get_input_perc('butterWaterContentPercent')
milkWaterContentRatio = self.get_input_perc('milkWaterContentPercent')
eggWaterContentRatio = self.get_input_perc('eggWaterContentPercent')
eggWeightGrams = self.get_input('eggWeightGrams')
# Compute the values:
totalDoughGrams = numberOfDoughnuts * doughnutWeightGrams
T = totalDoughGrams
sd = doughSeedRatio
h = levainHydrationRatio
wb = butterWaterContentRatio
rb = butterToFlourRatio
we = eggWaterContentRatio
re = eggToFlourRatio
H = doughHydrationRatio
wm = milkWaterContentRatio
rs = sugarToFlourRatio
rst = saltToFlourRatio
F = T / (sd * (1 + h) + (H - h * sd - wb * rb - we * re) / wm +
rs + rst + re + rb + (1 - sd))
levainGrams = sd * (1 + h) * F
milkGrams = (H - h * sd - wb * rb - we * re) * F / wm
saltGrams = rst * F
sugarGrams = rs * F
butterGrams = rb * F
eggGrams = re * F
numberOfEggs = round(eggGrams / eggWeightGrams, 1)
flourGrams = (1 - sd) * F
# Format and set the template variables
self.set_template_variable('numberOfDoughnuts', numberOfDoughnuts)
self.set_template_var_grams('doughnutWeightAmount', doughnutWeightGrams)
self.set_template_var_percent('levainHydration', levainHydrationRatio)
self.set_template_var_grams('levainAmount', levainGrams)
self.set_template_var_grams('milkAmount', milkGrams)
self.set_template_var_grams('sugarAmount', sugarGrams)
self.set_template_var_grams('saltAmount', saltGrams)
self.set_template_variable('numberOfEggs', numberOfEggs)
self.set_template_var_grams('butterAmount', butterGrams)
self.set_template_var_grams('flourAmount', flourGrams)
adjuster = RecipeAdjuster()
adjuster.generate_recipe()