-
Notifications
You must be signed in to change notification settings - Fork 1
/
display_veggie.py
107 lines (93 loc) · 3.61 KB
/
display_veggie.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
106
107
import script
import helper
import vegetarian
def display_veggie_recipe(url):
ingredients, raw_ingredients, directions, methods, tools = vegetarian.parse_new_veggie_recipe(url)
print('-------Ingredients-----')
for index, ri in enumerate(raw_ingredients):
print(ingredients[index])
print('..........')
print('ingredient name:', ri['ingredient_name'].rstrip(','))
print('quantity:', ri['quantity'])
print('measurement:', ri['measurement'])
print('preparation:', ri['preparation'])
print()
print('\n-------Tools-----')
for tool in tools:
print(tool)
print('\n-------Methods-----')
for method in methods:
print(method)
print('\n-------Steps------')
cnt = 1
for step in directions:
print("step", cnt)
print(step[0].strip())
print('..........')
if len(step[1]['ingredient']) != 0:
print('ingredients: ', end = '')
for ing in step[1]['ingredient'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['ingredient'][-1])
if len(step[1]['cooking tools']) != 0:
print('cooking tools: ', end = '')
for ing in step[1]['cooking tools'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['cooking tools'][-1])
if len(step[1]['cooking methods']) != 0:
print('cooking methods: ', end = '')
for ing in step[1]['cooking methods'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['cooking methods'][-1])
if len(step[1]['time']) != 0:
print('cooking time: ', end = '')
for ing in step[1]['time'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['time'][-1])
print()
cnt+=1
def display_non_veggie_recipe(url):
ingredients, raw_ingredients, directions, methods, tools = vegetarian.parse_new_non_veggie_recipe(url)
print('-------Ingredients-----')
for index, ri in enumerate(raw_ingredients):
print(ingredients[index])
print('..........')
print('ingredient name:', ri['ingredient_name'].rstrip(','))
print('quantity:', ri['quantity'])
print('measurement:', ri['measurement'])
print('preparation:', ri['preparation'])
print()
print('\n-------Tools-----')
for tool in tools:
print(tool)
print('\n-------Methods-----')
for method in methods:
print(method)
print('\n-------Steps------')
cnt = 1
for step in directions:
print("step", cnt)
print(step[0].strip())
print('..........')
if len(step[1]['ingredient']) != 0:
print('ingredients: ', end = '')
for ing in step[1]['ingredient'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['ingredient'][-1])
if len(step[1]['cooking tools']) != 0:
print('cooking tools: ', end = '')
for ing in step[1]['cooking tools'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['cooking tools'][-1])
if len(step[1]['cooking methods']) != 0:
print('cooking methods: ', end = '')
for ing in step[1]['cooking methods'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['cooking methods'][-1])
if len(step[1]['time']) != 0:
print('cooking time: ', end = '')
for ing in step[1]['time'][:-1]:
print(ing.strip(), end = ', ')
print(step[1]['time'][-1])
print()
cnt+=1