demo.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from geocoding import *
  2. import webbrowser
  3. import main
  4. import notification
  5. def open_pos(pos):
  6. pos_str = '(' + str(pos[0]) + ', ' + str(pos[1]) + ')'
  7. if input('Montrer la position ' + pos_str + ' ? [Y/n] ') != 'n':
  8. webbrowser.open_new("https://www.google.fr/maps/search/" + pos_str)
  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. if source.problem():
  28. print("Problème : ", end='')
  29. else:
  30. print("Pas de problème : ", end='')
  31. notification.notify(source.message)
  32. if "full" in source.id:
  33. pos = sourceProviders[1].dic_of_positions()[source.id][0]
  34. open_pos(pos)
  35. # empty line
  36. print()