def populate_database(): db.add_bottle_type('Johnnie Walker', 'black label', 'blended scotch') db.add_to_inventory('Johnnie Walker', 'black label', '500 ml') db.add_bottle_type('Uncle Hermans', 'moonshine', 'blended scotch') db.add_to_inventory('Uncle Hermans', 'moonshine', '5 liter') db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka') db.add_to_inventory('Gray Goose', 'vodka', '1 liter') db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth') db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz') derp = dict() r = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'), ('vermouth', '1.5 oz')]) db.add_recipe(r) derp[r.name] = r r = recipes.Recipe('Gin and Tonic', [('gin', '2 oz'), ('tonic water', '5 oz')]) db.add_recipe(r) derp[r.name] = r herp = dict() herp[('Johnnie Walker', 'black label')] = 1000 herp[('Gray Goose', 'vodka')] = 500 party1 = Party("Befall", "Get Drunk Party", "05-03-13", "11:00pm", "123 Balls St.", derp, herp) db.add_party(party1) db.save_db('bin\drinkz.txt')
def songs_add(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) artist = results['artist'][0] song = results['song'][0] db.add_song(artist,song) db.save_db("database.db") headers = list(html_headers) headers.append(('Location', '/songs')) start_response('302 Found', headers) return ["Redirect to /songs.."]
def liquor_types_add(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) mfg = results['mfg'][0] liquor = results['liquor'][0] typ = results['typ'][0] db.add_bottle_type(mfg, liquor, typ) db.save_db("database.db") headers = list(html_headers) headers.append(('Location', '/liquor_types')) start_response('302 Found', headers) return ["Redirect to /liquor_types..."]
def inventory_add(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) mfg = results['mfg'][0] liquor = results['liquor'][0] amount = results['amount'][0] db.add_to_inventory(mfg, liquor, amount) db.save_db("database.db") headers = list(html_headers) headers.append(('Location', '/inventory')) start_response('302 Found', headers) return ["Redirect to /inventory..."]
def recipes_add(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) name = results['name'][0] ingredients = results['ingredients'][0] ingredients = ingredients.splitlines() ingredients = [ x.strip() for x in ingredients ] # clean whitespace ingredients = [ x for x in ingredients if x ] # remove empty ingredients = [ x.split(',') for x in ingredients ] r = recipes.Recipe(name, ingredients) db.add_recipe(r) db.save_db("database.db") headers = list(html_headers) headers.append(('Location', '/recipes')) start_response('302 Found', headers) return ["Redirect to /recipes..."]
def main(args): filename = args[1] save_db(filename) load_db(filename)