A mirror of dcurooms found at https://github.com/theycallmemac/dcurooms
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

82 líneas
2.9 KiB

  1. import datetime
  2. import sys
  3. from requests import get
  4. from bs4 import BeautifulSoup
  5. import getpass
  6. __author__ = "theycallmemac"
  7. __version__ = '2.0.0'
  8. __copyright__ = 'Copyright (c) 2018 theycallmemac'
  9. __license__ = 'GPL-3.0'
  10. def confirm():
  11. if int(sys.version[0]) < 3:
  12. conf = raw_input("\033[1;93m{0}\033[00m".format("\nIs this information correct? (y/n): "))
  13. else:
  14. conf = input("\033[1;93m{0}\033[00m".format("\nIs this information correct? (y/n): "))
  15. if conf == "y":
  16. return conf
  17. else:
  18. return "n"
  19. def check_args(week, day):
  20. if int(week) not in range(1, 53) or int(day) not in range(1, 7):
  21. print("\033[1;91m{0}\033[00m".format("Incorrect parameters passed."))
  22. sys.exit()
  23. else:
  24. pass
  25. def check_room(timetable_url):
  26. html = get(timetable_url)
  27. soup = BeautifulSoup(html.text, "lxml")
  28. tr = soup.select('tr')
  29. return str(tr[12].getText().strip()) + " -> " + str(tr[14].getText().strip())
  30. def get_lst(c, g, options):
  31. if options.computing == True: lst = c
  32. elif options.grattan == True: lst = g
  33. return lst
  34. def get_current_time(date):
  35. day = date.weekday()
  36. hour = date.hour
  37. minute = date.minute
  38. year, week_no, weekday = date.isocalendar()
  39. start = 36
  40. if week_no >= start:
  41. offset = -start
  42. else:
  43. offset = 52 - start
  44. week = week_no + offset - 1
  45. return str(week), str(day + 1), str(hour - 2), str(minute)
  46. def get_version_email():
  47. if int(sys.version[0]) < 3:
  48. email = raw_input("\033[1;97m{0}\033[00m".format("Your gmail: "))
  49. password = getpass.getpass("\033[1;97m{0}\033[00m".format("Your gmail password: "))
  50. your_name = raw_input("\033[1;97m{0}\033[00m".format("Your name: "))
  51. society = raw_input("\033[1;97m{0}\033[00m".format("Society name: "))
  52. return email, password, your_name, society
  53. else:
  54. email = input("\033[1;97m{0}\033[00m".format("Your gmail: "))
  55. password = getpass.getpass("\033[1;97m{0}\033[00m".format("Your gmail password: "))
  56. your_name = input("\033[1;97m{0}\033[00m".format("Your name: "))
  57. society = input("\033[1;97m{0}\033[00m".format("Society name: "))
  58. return email, password, your_name, society
  59. def get_version_form():
  60. if int(sys.version[0]) < 3:
  61. name = raw_input("\033[1;97m{0}\033[00m".format("Your name: "))
  62. email = raw_input("\033[1;97m{0}\033[00m".format("Your email: "))
  63. number = raw_input("\033[1;97m{0}\033[00m".format("Your number: "))
  64. society = raw_input("\033[1;97m{0}\033[00m".format("Society name: "))
  65. return email, number, name, society
  66. else:
  67. name = input("\033[1;97m{0}\033[00m".format("Your name: "))
  68. email = input("\033[1;97m{0}\033[00m".format("Your email: "))
  69. number = input("\033[1;97m{0}\033[00m".format("Your number: "))
  70. society = input("\033[1;97m{0}\033[00m".format("Society name: "))
  71. return email, number, name, society