示例#1
0
def EditCurrentRecipesMenu():
    global current_recipes
    DisplayEditCurrentRecipesMenu()
    while True:
        selection = raw_input('> ')
        if selection.lower() == 'e':
            break
        elif selection == '1':
            Common.log("Current recipes before: " +
                       '\n'.join([r.name for r in current_recipes]))
            current_recipes = Common.AddItem(current_recipes, 'a recipe',
                                             'recipes', Recipe.ListRecipes,
                                             Common.global_state.all_recipes,
                                             Recipe.RecipeByName)
            Common.log("Current recipes after: " +
                       '\n'.join([r.name for r in current_recipes]))
        elif selection == '2':
            Common.RemoveItem(current_recipes, 'a recipe', 'recipes',
                              Recipe.ListRecipes,
                              DisplayEditCurrentRecipesMenu, False, False)
        elif selection == '3':
            print '\n'.join([r.name for r in current_recipes])
        elif selection == '4':
            current_recipes = []
    return
示例#2
0
def AddRecipeToCurrentRecipes():
    '''
    Set a recipe manually
    '''

    global current_recipes
    Common.AddItem(current_recipes, "a recipe", "recipes", Recipe.ListRecipes,
                   Common.global_state.all_recipes, Recipe.RecipeByName)
    DisplayOptionsMenu()
    return
示例#3
0
def IngredientsToUseMenu():
    '''
    Declare ingredients that need to be used up
    '''
    global ingredients_to_use
    Common.AddItem(ingredients_to_use, 'an ingredient to use up',
                   'ingredients', Ingredients.ListIngredients,
                   Common.global_state.all_ingredients,
                   Ingredients.IngredientByName)
    DisplayOptionsMenu()
    return
示例#4
0
def BanRecipeMenu(profile=None):
    '''
    Declare recipes that will be banned under a restriction profile
    '''
    try:
        new_profile = copy.copy(profile)
    except Exception as e:
        new_profile = None
    if profile == None:
        return None
    ban_list = new_profile.banned_recipes
    Common.AddItem(ban_list, 'a recipe to ban', 'recipes', Recipe.ListRecipes,
                   Common.global_state.all_recipes, RecipeByName)
    DisplayDietaryRestrictionsMenu()  # TODO display correct menu
    return profile
示例#5
0
def BanIngredientMenu(
        profile=None
):  #TODO fix so that this works with global banned ingredients
    '''
    Declare ingredients that should be banned under a restriction profile
    '''
    try:
        new_profile = copy.copy(profile)
    except Exception as e:
        new_profile = None
    global banned_ingredients
    ban_list = banned_ingredients
    if profile:
        ban_list = new_profile.banned_ingredients
    Common.AddItem(ban_list, 'an ingredient to ban', 'ingredients',
                   Ingredients.ListIngredients,
                   Common.global_state.all_ingredients, IngredientByName)
    DisplayDietaryRestrictionsMenu()  # TODO display correct menu
    return profile
示例#6
0
def AddIngredientToGroceryListMenu(global_state, grocery_list):
    grocery_list = Common.AddItem(grocery_list, 'an ingredient', 'ingredients',
                                  Ingredients.ListIngredients,
                                  global_state.all_ingredients,
                                  Ingredients.IngredientByName)
    return grocery_list  #TODO consider whether to add quantity as an option
示例#7
0
def ChooseRestrictionProfile(global_state, current_restrictions):
    Common.AddItem(current_restrictions, 'a restriction', 'restrictions',
                   Restrictions.ListRestrictions,
                   global_state.restriction_profiles, RestrictionByName)
    return