Skip to content

Commit

Permalink
Linked main with other 2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylchen2 committed Feb 16, 2020
1 parent 7d36a4e commit 6c0269d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 14 deletions.
12 changes: 8 additions & 4 deletions PlacesAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,27 @@ 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

#These if statements check if the key is actually in the JSON object, AKA they check if the place actually
# 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


Expand Down Expand Up @@ -80,7 +83,7 @@ def radar_events():
return result.json()



'''
if __name__ == "__main__":
#Main program loop
Expand All @@ -107,3 +110,4 @@ def radar_events():
except KeyboardInterrupt:
print("Exiting program")
exit(0)
'''
58 changes: 53 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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()
15 changes: 10 additions & 5 deletions userpref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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



0 comments on commit 6c0269d

Please sign in to comment.