def get_liquor_amount_withMix(liquor): "Retrieve the total amount of any given liquor currently in inventory." amounts = [] totalVolume = 0.0 for key in _inventory_db: if key[1].lower()==liquor.lower(): amounts.append(_inventory_db[key]) #add amount for s in amounts: for bottle in s: totalVolume += unit_conversion.convert_to_ml(bottle) #Now calls the function convert_to_ml #to make sure the function works return totalVolume;
def need_ingredients(self): ingredients = self.Ingredient #get the recipe ingredients missing = [] for i in ingredients: #for each ingredient #get the type and the amount type = i[0] amount = i[1] need_amount = unit_conversion.convert_to_ml(amount) current_amount = db.get_liquor_amount_noMix(type) diff = need_amount - current_amount if diff >0: new_amount = diff #str(diff) + ' ml' #to show ml missing.append((type, new_amount)) #print missing return missing
def recv_convert(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) Amount = "0" if ('amount' in results): #Get the amount Amount = results['amount'][0] #Get the type (oz, ml, liter, gallon) Type = results['type'][0] #Concatenate amount and type amount_given = Amount + " " + Type #Compute the conversion new_Amount = unit_conversion.convert_to_ml(amount_given) #Generate results in html format content_type = 'text/html' data= """ <html> <head> <title>Conversion Results</title> <style type='text/css'> h1 {color:red;} body{ font-size:14px; } </style> </head> <body> <h1>Result from conversion</h1> """ data = data + "<p>" + amount_given + " = "+ str(new_Amount)+" ml</p>" data = data + "<p><a href='./'>return to index</a></p>" data = data + """ </body> <html> """ start_response('200 OK', list(html_headers)) return [data]
def get_liquor_amount(mfg, liquor): "Retrieve the total amount of any given liquor currently in inventory." amounts = [] totalVolume = 0.0 #Previous if((mfg,liquor)) in _inventory_db: for bottle_amount in _inventory_db[mfg,liquor]: amounts.append(bottle_amount) #add amount #Current #for item in _inventory_db: #if is on inventory # print item[0] + "kuriboh" + item[1] # if((mfg.lower() ==item[0].lower()) and (liquor.lower()==item[1].lower())): # for bottle_amount in (_inventory_db[item[0],item[1]]): # print bottle_amount # amounts.append(bottle_amount) #add amount for bottle in amounts: totalVolume += unit_conversion.convert_to_ml(bottle) #Now calls the function convert_to_ml #to make sure the function works return totalVolume
def rpc_convert_units_to_ml(self, amount): return unit_conversion.convert_to_ml(amount)