コード例 #1
0
def add_new_restaurant():
    name = request.forms.get('name')
    cuisine = request.forms.get('type')
    cost = request.forms.get('cost')
    fave = request.forms.get('fave')
    dist = request.forms.get('dist')
    restaurants[name] = shared.Restaurant(name, cuisine, cost, fave, dist)
    shared.save_changes(filename, restaurants)
    return generate_response(name)
コード例 #2
0
 def POST(self):
     # Add some code in here to add the input to the internal restaurants data
     # Then save it out (call the function to save the changes)
     # Then send the HTML for the new restaurant back, like for TripDevisor above
     input_data = web.input()
     name = input_data.name
     type = input_data.type
     cost = input_data.cost
     fave = input_data.fave
     dist = input_data.dist
     restaurants[name] = shared.Restaurant(name, type, cost, fave, dist)
     shared.save_changes(filename, restaurants)
     return generate_response(name)
コード例 #3
0
            print restaurant_name + " is a " + str(restaurants[restaurant_name].fave) + "/5 rated place " + \
                  str(restaurants[restaurant_name].dist) + " minutes from here"


def add_restaurant():
    name = raw_input("Enter Restaurant Name: ")
    cuisine = raw_input("Enter Restaurant type: ")
    cost = raw_input("Enter Restaurant cost (out of 5): ")
    fave = raw_input("Enter star rating (out of 5): ")
    dist = raw_input("Enter distance (minutes' walk): ")
    restaurants[name] = shared.Restaurant(name, cuisine, cost, fave, dist)


restaurants = shared.read_csvfile(filename)

while not finished:
    show_menu()
    choice = raw_input("Please enter choice: ")
    if choice == "1":
        search_on_distance(raw_input("Please enter max distance: "))
    elif choice == "2":
        search_on_rating(raw_input("Please enter minimum rating: "))
    elif choice == "3":
        add_restaurant()
    elif choice == "4":
        shared.save_changes(filename, restaurants)
    elif choice == "5":
        finished = True
    else:
        print "That's not a valid choice - try again!"
コード例 #4
0
def add_restaurant():
    name = input("Enter Restaurant Name: ")
    cuisine = input("Enter Restaurant type: ")
    cost = input("Enter Restaurant cost (out of 5): ")
    fave = input("Enter star rating (out of 5): ")
    dist = input("Enter distance (minutes' walk): ")
    restaurants[name] = shared.Restaurant(name, cuisine, cost, fave, dist)


shared.read_csvfile(restaurants, filename)

print(restaurants)
while not finished:
    show_menu()
    choice = input("Please enter choice: ")
    if choice == "1":
        search_on_distance(input("Please enter max distance: "))
    elif choice == "2":
        search_on_rating(input("Please enter minimum rating: "))
    elif choice == "3":
        add_restaurant()
    elif choice == "4":
        shared.save_changes(restaurants, filename)
    elif choice == "5":
        finished = True
    else:
        print("That's not a valid choice - try again!")


コード例 #5
0
    name = input("Enter Restaurant Name: ")
    cuisine = input("Enter Restaurant type: ")
    cost = input("Enter Restaurant cost (out of 5): ")
    fave = input("Enter cost (out of 5): ")
    dist = input("Enter distance (minutes' walk): ")
    restaurants[name] = {
        "type": cuisine,
        "cost": cost,
        "fave": fave,
        "dist": dist
    }


shared.read_csvfile(restaurants)

while not finished:
    show_menu()
    choice = input("Please enter choice: ")
    if choice == "1":
        search_on_distance(input("Please enter max distance: "))
    elif choice == "2":
        search_on_rating(input("Please enter minimum rating: "))
    elif choice == "3":
        add_restaurant()
    elif choice == "4":
        shared.save_changes(restaurants)
    elif choice == "5":
        finished = True
    else:
        print("That's not a valid choice - try again!")
コード例 #6
0
ファイル: Lesson3.py プロジェクト: wilkotom/python_examples

def add_restaurant():
    name = input("Enter Restaurant Name: ")
    cuisine = input("Enter Restaurant type: ")
    cost = input("Enter Restaurant cost (out of 5): ")
    fave = input("Enter star rating (out of 5): ")
    dist = input("Enter distance (minutes' walk): ")
    # Change this to use a Restaurant instead of a dictionary as well.
    restaurants[name] = {"type": cuisine, "cost": cost,
                         "fave": fave, "dist": dist}


shared.read_csvfile(restaurants)

while not finished:
    show_menu()
    choice = input("Please enter choice: ")
    if choice == "1":
        search_on_distance(input("Please enter max distance: "))
    elif choice == "2":
        search_on_rating(input("Please enter minimum rating: "))
    elif choice == "3":
        add_restaurant()
    elif choice == "4":
        shared.save_changes(restaurants)
    elif choice == "5":
        finished = True
    else:
        print("That's not a valid choice - try again!")