diff --git a/PlacesAPI.py b/PlacesAPI.py index 8dc6721..f75f653 100644 --- a/PlacesAPI.py +++ b/PlacesAPI.py @@ -35,14 +35,16 @@ def api_search(text): def pull_data(input_text): + print("Called pulldata") data = {} for result in api_search(input_text)['results']: + print("Called apisearch") name = result['name'] data[name] = result data[name]["descr"] = "" details = api_details(result['place_id']) - # print("BHours: ") + print("BHours: ") if 'result' not in details: continue @@ -50,9 +52,10 @@ def pull_data(input_text): # has opening hours, or has reviews before trying to access them! This is a safe practice if 'opening_hours' in details['result'] and 'weekday_text' in details['result']['opening_hours']: for open_day in details['result']['opening_hours']['weekday_text']: - # print(" "+open_day) + print(" "+open_day) data[name]["descr"] += open_day + "|| " - # print(data) + print(data) + print("pull_data done") return data @@ -80,7 +83,7 @@ def radar_events(): return result.json() - +''' if __name__ == "__main__": #Main program loop @@ -107,3 +110,4 @@ def radar_events(): except KeyboardInterrupt: print("Exiting program") exit(0) +''' \ No newline at end of file diff --git a/main.py b/main.py index 510be21..7c3709a 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,10 @@ #import places as places +import PlacesAPI as placesApi +import userpref as userpref -def main(): +if __name__ == "__main__": #Get user input + user = userpref.User({"Chinese":3,"Korean": 4, "Quiet": 1, "Mediterranean": 3},{"Fine arts":3,"Theatre":2},{"Movie":8,"KTV":2},{"Althetic":3,"Formal":2}) i = 0 listCategory = {"Restaurant":0,"Arts & Culture":0,"Entertainment":0,"Shopping":0} while i == 0: @@ -15,16 +18,61 @@ def main(): listCategory["Entertainment"] = 1 if (userInput == 3): listCategory["Shopping"] = 1 - print("Do you want to add additional preferences\n0:No\n1:Yes") + print("Do you want to add additional categories\n0:No\n1:Yes") print(listCategory) userInput = int(input()) if (userInput == 0): i = 1 + input = "" + for c in listCategory: + if c == 1: + if c == "Restaurant": + if len(user.food) > 5: + for f in user.food: + input = input + f + else: + for f in user.food: + input = input + f + if c == "Arts & Culture": + if len(user.arts) > 5: + for a in user.arts: + input = input + a + else: + for a in user.arts: + input = input + a + if c == "Entertainment": + if len(user.entertainment) > 5: + for f in user.entertainment: + input = input + f + else: + for f in user.entertainment: + input = input + f + else: + if len(user.shopping) > 5: + for f in user.shopping: + input = input + f + else: + for f in user.shopping: + input = input + f + places = placesApi.pull_data(input) + print(places) + for i in range(len(places)): + print("{0}: {1}".format(i, places[i])) + input_text = input("Would you like to remove any of these items?") + try: + places.pop(int(input_text), None) + except: + print("Please input a number") + if input_text == "": + break + if len(places) != 0: + print(placesApi.find_route([place['place_id'] for place in places.values()])) + print("Done") + + + #Call api functions #coordinates = "2.230225,48.817716" #x = places.findPlaces(coordinates) #printall(x) - -if __name__ == "__main__": - main() diff --git a/userpref.py b/userpref.py index f06ff88..9da64a9 100644 --- a/userpref.py +++ b/userpref.py @@ -11,12 +11,17 @@ class User: data: {category(food): [specific(middle eastern), Time]} """ - preferences: List - data: Dict + food: Dict + arts: Dict + entertainment: Dict + shopping: Dict in_home_country: bool - def __init__(self, preferences): - self.preferences = preferences - self.data = {} + def __init__(self, food, arts, entertainment, shopping): + self.food = food + self.arts = arts + self.entertainment = entertainment + self.shopping = shopping +