Skip to content

Commit

Permalink
Can Now generate ICS within script 😄
Browse files Browse the repository at this point in the history
  • Loading branch information
xypnox committed Mar 11, 2018
1 parent 20f3cbb commit ccb204f
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions gyft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
from bs4 import BeautifulSoup as bs
import json
import generate_ics

import sys


def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is True for "yes" or False for "no".
"""
valid = {"yes": True, "y": True, "ye": True,
"no": False, "n": False}
if default is None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
else:
raise ValueError("invalid default answer: '%s'" % default)

while True:
sys.stdout.write(question + prompt)
choice = input().lower()
if default is not None and choice == '':
return valid[default]
elif choice in valid:
return valid[choice]
else:
sys.stdout.write("Please respond with 'yes' or 'no' "
"(or 'y' or 'n').\n")


with open('view_stud_time_table.html', 'r') as myfile:
r = myfile.read()
Expand Down Expand Up @@ -104,7 +141,10 @@ def merge_slots(in_dict):
'''
Timetable saved to data.txt file. Be sure to edit this file,
to have desired names of subjects rather than subject codes.
Also, run generate_ics.py to generate the ics file
'''
)

if query_yes_no("Do you want to generate ICS file too?"):
generate_ics.main()
else:
print("You can Generate ICS later using generate_ics.py")

0 comments on commit ccb204f

Please sign in to comment.