Beispiel #1
0
def get_meal_str_a(meals_list, area_str):
    """
        This method searches for the entered area and if found will return
        a string with all the meals in that area. If not found, will return
        a string with an appropriate message.
    """

    found = False
    areas = get_areas()

    # validate categories
    for i in range(len(areas)):
        area = areas[i]
        if area.get_area().lower() == area_str.lower():
            found = True
            break

    if found:
        meals = requests.get_meals_by_area(area_str.title())
        meals_list += area_str.upper() + " MEALS" + "\n\n"
        for i in range(len(meals)):
            meal = meals[i]
            meals_list += meal.get_meal() + "\n"
    else:
        meals_list = "Invalid Area, please try again"

    return meals_list
def get_meals_by_area(area):
    meals = requests.get_meals_by_area(area)

    # print all meals per categories
    if len(meals) >= 1:
        print(area.upper() + " MEALS")
    for i in range(len(meals)):
        meal = meals[i]
        print("  " + meal.get_meal())
def search_meal_by_area(areas):
    """
        This method is used to get a category to search for meals on
        and then make the call to get the list of meals for the category
    """

    lookup_area = input("Enter an area: ")
    found = False

    # Validate areas
    for i in range(len(areas)):
        area = areas[i]
        if area.get_area().lower() == lookup_area.lower():
            found = True
            break

    if found:
        meals = requests.get_meals_by_area(lookup_area)
        list_meals_by_area(lookup_area, meals)
    else:
        print("Invalid area, please try again.\n")
Beispiel #4
0
def search_meals_by_area(entry, recipe_label):
    search = entry
    found = False

    if         search.lower() == "canadian"   or search.lower() == "american"     or search.lower() == "chinese"\
            or search.lower() == "vietnamese" or search.lower() == "british"      or search.lower() == "french"\
            or search.lower() == "jamaican"   or search.lower() == "dutch"        or search.lower() == "egyptian"\
            or search.lower() == "greek"      or search.lower() == "indian"       or search.lower() == "japanese" \
            or search.lower() == "irish"      or search.lower() == "italian"      or search.lower() == "kenyan"\
            or search.lower() == "malaysian"  or search.lower() == "mexican"      or search.lower() == "moroccan"\
            or search.lower() == "croatian"   or search.lower() == "Norwegian"    or search.lower() == "portuguese"\
            or search.lower() == "russian"    or search.lower() == "aregentinian" or search.lower() == "spanish"\
            or search.lower() == "slovakian"  or search.lower() == "thai"         or search.lower() == "arabic":
        found = True

    if found:
        areas = requests.get_meals_by_area(search)
        list_meal_by_area(search, areas, recipe_label)
    else:
        print("Invalid Area, Please try again.")
    print()