demo.py 970 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from geocoding import *
  2. import webbrowser
  3. import main
  4. import notification
  5. def open_pos(pos):
  6. print(pos)
  7. if input('Montrer la position + ' + str(pos) + ' ? [Y/n] ') != 'n':
  8. webbrowser.open_new("https://www.google.fr/maps/search/" + str(pos))
  9. def message():
  10. yield("Faisons un essai !\n")
  11. yield("Encore une fois ?\n")
  12. yield("Pas fatigués ?\n")
  13. while True:
  14. yield("")
  15. sourceProviders = [SourceProvider_ratp(),
  16. SourceProvider_jcdecaux_vls(),
  17. SourceProvider_transilien()]
  18. for m in message():
  19. print(m)
  20. location = input("Adresse : ")
  21. position = position_of_location(location)
  22. if not position:
  23. print("Désolé, l'adresse n'est pas reconnue :-(")
  24. else:
  25. open_pos(position)
  26. for source in main.gen_sources(sourceProviders, location):
  27. notification.notify(source.message)
  28. if "full" in source.id:
  29. pos = sourceProviders[1].dic_of_positions()[source.id][0]
  30. open_pos(pos)
  31. # empty line
  32. print()