def rpc_get_liquor_inventory(self): inventory = [] pairing = () for (mfg, liquor) in db.get_liquor_inventory(): pairing = (mfg, liquor) inventory.append(pairing) return inventory
def inventory(self, environ, start_response): start_response('200 OK', list(html_headers)) title = "inventory" inventory = [(m, l, db.get_liquor_amount(m, l)) \ for (m, l) in db.get_liquor_inventory()] template = env.get_template("inventory.html") return str(template.render(locals()))
def inventory(self, environ, start_response): data = """\ <head><title>Inventory</title> <style type="text/css"> h1 {color:red;} </style> </head> <body> <h1>Inventory</h1> Visit: <a href='content'>a file</a>, <a href='error'>an error</a>, <a href='helmet'>an image</a>, <a href='somethingelse'>something else</a>, or <a href='form'>a form...</a> <a href='inventory'>Inventory</a> <a href='recipes'>Recipes</a> <a href='index'>Index</a> <p> <img src='/helmet'> </body> """ for m, l in db.get_liquor_inventory(): data += "<li>" data += m data += ", " data += str(db.get_liquor_amount(m, l)) data += " ml" data += "</li>\n" data += "</ul>" start_response("200 OK", list(html_headers)) return [data]
fp = open('html/inventory.html', 'w') print >>fp, header % 'Inventory' print >>fp, navbar print >>fp, """ <h2>Inventory</h2> <table> <tr> <th>Manufacturer</th> <th>Liquor</th> <th>Amount</th> </tr> """ for manufacturer, liquor in db.get_liquor_inventory(): amount = db.get_liquor_amount(manufacturer, liquor) print >>fp, """ <tr> <td>%s</td> <td>%s</td> <td style="text-align: right">%.2f ml</td> </tr> """ % (manufacturer, liquor, amount) print >>fp, "</table>" print >>fp, footer fp.close() # recipes.html fp = open('html/recipes.html', 'w')
fp.close() ### fp = open('html/inventory.html', 'w') print >>fp, """ <p><a href='index.html'>this is a relative link to index!</a></p> <p><a href='recipes.html'>this is a relative link to recipes!</a></p> <p><a href='inventory.html'>this is a relative link to inventory!</a></p> <p><a href='liquor_types.html'>this is a relative link to liquor types!</a></p> <h1>Inventory</h1> <ul> """ for m,l in db.get_liquor_inventory(): print >>fp, "<li>" print >>fp, m print >>fp, ", " print >>fp, db.get_liquor_amount(m, l) print >>fp, " ml" print >>fp, "</li>" print >>fp, "</ul>" fp.close() ### fp = open('html/liquor_types.html', 'w')
recipe_str += "</ol>" links = index_html + liquor_types_html + inventory_html recipe_str += links print >> fp, recipe_str fp.close() #liquor-types.html fp = open('html/liquor-types.html', w) liquors_str = "Liquor Types\n<ol>" for mfg, liquor in db.get_liquor_inventory(): liquors += "<li>" + mfg + ", " + liquor + "</li>" liquors += "</ol>" links = index_html + recipes_html + inventory_html liquors_str += links print >> fp, recipe_str fp.close() #Inventory.html fp = open('html/inventory.html', w)
if(r.need_ingredients() == []): lack = "Yes" else: lack = "No" recipes += "<li>" + r.name + ": " + lack + "</li>\n" recipes = recipes + "</ol>"+ addr print >> fp, recipes fp.close() # for inventory page fp = open('html/inventory.html', 'w') inventory = " <ol>" for liquor in db.get_liquor_inventory(): mfg = liquor[0] l = liquor[1] amount = db.get_liquor_amount(mfg, l) inventory += "<li>" + mfg + ", " + l + ": " + str(amount) + " ml</li>\n" inventory = addr + inventory +"</ol>" print >> fp, inventory fp.close() #for liquor_types page fp = open('html/liquor_types.html', 'w')
#PAGE INV fp = open('html/inventory.html', 'w') print >>fp, "<b>Inventory</b><p></p>" list = set() print >> fp, "<p>Manufacturer Liquor Amount(ml)</p>" print >> fp, "-------------------|-------------------|------------------" sendtopage = "<ol>" for mfg, liquor in db.get_liquor_inventory(): #for every item returned if (mfg,liquor) in list: #check if in posted list or go on continue else: list.add((mfg,liquor)) #add to posted list quant = db.get_liquor_amount(mfg,liquor) #get quaniity newquant=str(quant) sendtopage +="<li>" + mfg + " " + liquor + " " + newquant +"<li>\n" sendtopage = sendtopage + "</ol>" print >>fp, sendtopage print >>fp, """ OTHER PAGES: <p><a href='index.html'>Back to Index</a></p> <p><a href='inventory.html'>Inventory</a></p> <p><a href='liquor_types.html'>Liquor Types</a></p> """
def rpc_get_liqour_inventory(self): liqourInvList = list() for (m,l) in db.get_liquor_inventory(): liqourInvList.append((m,l)) return liqourInvList