A mirror of dcurooms found at https://github.com/theycallmemac/dcurooms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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