forked from ctb/cse491-drinkz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-html.py
94 lines (67 loc) · 1.56 KB
/
make-html.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
import os
import drinkz.db, drinkz.recipes
drinkz.db.load_db('db.txt')
try:
os.mkdir('html')
except OSError:
# already exists
pass
###
fp = open('html/index.html', 'w')
print >>fp, """
<p><a href='recipes.html'>Recipes</a>
<a href='inventory.html'>Inventory</a>
<a href='liquor_types.html'>Liquor Types</a>
"""
fp.close()
###
fp = open('html/recipes.html', 'w')
print >>fp, "<ol>"
for r in drinkz.db.get_all_recipes():
print >>fp, "<li>",str(r.Name),"</li>"
print >>fp, "</ol>"
print >>fp, """
<p><a href='recipes.html'>Recipes</a>
<a href='inventory.html'>Inventory</a>
<a href='liquor_types.html'>Liquor Types</a>
"""
fp.close()
###
fp = open('html/inventory.html', 'w')
print >>fp, """
<table>
<thead>
<tr>
<th>MFG</th>
<th>Type</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
"""
for key, val in drinkz.db._inventory_db.items():
print >>fp, "<tr>\n"
print >>fp, "<td>", key[0],"</td>"
print >>fp, "<td>", key[1],"</td>"
print >>fp, "<td>", val,"</td>"
print >>fp, "</tr>"
print >>fp, """</tbody>
</table>"""
print >>fp, """
<p><a href='recipes.html'>Recipes</a>
<a href='inventory.html'>Inventory</a>
<a href='liquor_types.html'>Liquor Types</a>
"""
fp.close()
###
fp = open('html/liquor_types.html', 'w')
print >>fp, "<ol>"
for i in drinkz.db.get_liquor_inventory():
print >>fp, "<li>",i,"</li>"
print >>fp, "</ol>"
print >>fp, """
<p><a href='recipes.html'>Recipes</a>
<a href='inventory.html'>Inventory</a>
<a href='liquor_types.html'>Liquor Types</a>
"""
fp.close()