-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyzza2.py
More file actions
40 lines (35 loc) · 1.16 KB
/
pyzza2.py
File metadata and controls
40 lines (35 loc) · 1.16 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
#!/usr/bin/python3
import json
from cli import Cli, printTable
from bakerMath import *
try:
with open('./recipes.json', 'r') as f:
recipes = json.load(f)
except IOError:
print("There should be a `recipes.json` file in the same folder\nthis ", \
"script was executed from.")
cli = Cli(recipes)
def main():
choice = ""
choice = cli.makeChoice(cli.printRecipes(), [lambda choice: choice.isdigit(),
lambda choice: choice in recipes])
if choice.isdigit():
flour = choice
choice = "dopny"
elif choice in recipes:
flour = ''
flour = cli.makeChoice(cli.getFlour(), [lambda flour: flour.isdigit()])
print("\n================================================")
print("#### %s\n"% choice.upper())
if "starter" in recipes[choice]:
print("##### Starter")
printTable(bakerCalc(flour, recipes[choice]["starter"]))
print("##### Final Dough")
recipe = bakerCalc(flour, recipes[choice])
total = totalWeight(recipe)
printTable(recipe)
cli.printPies(total)
print("================================================\n")
main()
if __name__ == "__main__":
main()