def changeToIndian(recipe): cuisine = "indian" ingredients = recipe.ingredients cuisineMeats = cuisines[cuisine]["meats"] cuisineCheese = cuisines[cuisine]['cheese'] cuisineSpiceHerb = cuisines[cuisine]['spicesAndHerbs'] cuisineSauces = cuisines[cuisine]['sauces'] cuisineVegGarn = cuisines[cuisine]['veggiesAndGarnish'] modifiedIngredients = [] addSpices = False vegIndex = 0 for ing in ingredients: category = ing.category #check the meats used in recipe if category in meatsCategories or ing.name in meats: if fitsCuisineForCategory(ing, cuisineMeats): (meat, meatInDescriptor) = findIngNames(ing, cuisineMeats) if meat in (poultryAndGame + seafood) or meatInDescriptor in ( poultryAndGame + seafood): # chicken modifiedIngredients.append( updateIngredient(ing, cuisineMeats[0], "boneless", "")) else: # lamb/mutton modifiedIngredients.append( updateIngredient(ing, cuisineMeats[1], "", "")) #replace cheese with indian cheese elif category in cheeseCategory: pat = re.search("cheese*", ing.name.lower()) pat2 = re.search("cheese*", ing.descriptor.lower()) if pat or pat2: if fitsCuisineForCategory(ing, cuisineCheese): (cheese, cheeseInDescriptor) = findIngNames(ing, cuisineCheese) modifiedIngredients.append( updateIngredient(ing, cuisineCheese[0], "", "")) #replace spices and herbs elif category in spiceHerbsCategory: if fitsCuisineForCategory(ing, cuisineSpiceHerb): if not addSpices: addSpices = True modifiedIngredients.append({ ing.name + "$" + ing.descriptor: ', '.join(cuisineSpiceHerb[0:3]) }) modifiedIngredients.append( updateIngredient(ing, "", "", "")) else: modifiedIngredients.append( updateIngredient(ing, "", "", "")) #replace sauces.... elif category in sauce or ing.name in stocks: if fitsCuisineForCategory(ing, cuisineSauces): modifiedIngredients.append( updateIngredient(ing, cuisineSauces[0], "tomato puree based", "")) elif category in veggiesGarnish: veggieGarName = ing.name veggieDescriptor = ing.descriptor isVeggie = findVeggies(veggieGarName, veggieDescriptor, cuisine) if not isVeggie: if vegIndex < len(cuisineVegGarn): modifiedIngredients.append( updateIngredient(ing, cuisineVegGarn[vegIndex], "", "")) vegIndex += 1 else: modifiedIngredients.append( updateIngredient(ing, "", "", "")) if addSpices: for spiceHerb in cuisineSpiceHerb[0:3]: newIng = parsing.findIngredient(spiceHerb) if not newIng.name: newIng = objects.Ingredient(name=spiceHerb) ingredients.append(newIng) recipe.ingredients = sanitizeIngredients(ingredients) recipe.steps = replaceDirections(modifiedIngredients, recipe.steps) recipe.name = "Indian Version of -" + recipe.name print recipe.unicode()
def changeToChinese(recipe): cuisine = "chinese" ingredients = recipe.ingredients cuisineMeats = cuisines[cuisine]["meats"] cuisineSpiceHerb = cuisines[cuisine]['spicesAndHerbs'] cuisineSauces = cuisines[cuisine]['sauces'] cuisineVegGarn = cuisines[cuisine]['veggiesAndGarnish'] cuisineAlcohol = cuisines[cuisine]['alcohol'] modifiedIngredients = [] addSpices = False vegIndex = 0 for ing in ingredients: category = ing.category if category in meatsCategories or ing.name in meats: if fitsCuisineForCategory(ing, cuisineMeats): (meat, meatInDescriptor) = findIngNames(ing, cuisineMeats) if meat in (poultryAndGame + seafood) or meatInDescriptor in ( poultryAndGame + seafood): modifiedIngredients.append( updateIngredient(ing, cuisineMeats[0], "boneless", "")) else: modifiedIngredients.append( updateIngredient(ing, cuisineMeats[1], "tenderloin", "cubed")) elif category in spiceHerbsCategory: if fitsCuisineForCategory(ing, cuisineSpiceHerb): if not addSpices: addSpices = True modifiedIngredients.append({ ing.name + "$" + ing.descriptor: ', '.join(cuisineSpiceHerb) }) modifiedIngredients.append( updateIngredient(ing, "", "", "")) # Add in garlic, chili pepper, basil combo at end else: modifiedIngredients.append( updateIngredient(ing, "", "", "")) elif category in sauce: if fitsCuisineForCategory(ing, cuisineSauces): modifiedIngredients.append( updateIngredient(ing, cuisineSauces[0], "", "")) elif category in veggiesGarnish: veggieGarName = ing.name veggieDescriptor = ing.descriptor isVeggie = findVeggies(veggieGarName, veggieDescriptor, cuisine) if not isVeggie: if vegIndex < len(cuisineVegGarn): modifiedIngredients.append( updateIngredient(ing, cuisineVegGarn[vegIndex], "", "")) vegIndex += 1 else: modifiedIngredients.append( updateIngredient(ing, "", "", "")) elif ing.name == "wine": newIng = parsing.findIngredient(cuisineAlcohol[0]) modifiedIngredients.append( updateIngredient(ing, newIng.name, newIng.descriptor, "")) if addSpices: for spiceHerb in cuisineSpiceHerb: newIng = parsing.findIngredient(spiceHerb) if not newIng.name: newIng = objects.Ingredient(name=spiceHerb) ingredients.append(newIng) recipe.ingredients = sanitizeIngredients(ingredients) recipe.steps = replaceDirections(modifiedIngredients, recipe.steps) recipe.name = "Chinese Version of -" + recipe.name print recipe.unicode() return recipe