def index(): username = None password = None email = None form = loginForm() if form.validate_on_submit(): try: course_info = GetHTML.htmlHandle(form.username.data,form.password.data) timesold = course_info[2] names = course_info[1] course_info[2] = Formatter.formatTimes(course_info[2]) sdates = {'M':'26','T':'20','W':'21','R':'22','F':'23'} snames = {} for i in range(len(timesold)): snames[names[i]] = len(timesold[i]) dnames = {} k = 0 for j in range(7): for i in range(snames[names[j]]): dnames[k] = names[j] k += 1 filename = 'OliniCalendar.ics' iCalCreation.iCalWrite(course_info[2],"201501","20150430T000000",sdates,dnames,filename) ical = open('OliniCalendar.ics','r') email = form.email.data Emailer.iCalCreator(email,ical) os.remove('OliniCalendar.ics') # return render_template(html_sched) form.username.data = '' form.password.data = '' form.email.data = '' except: "Oops" return render_template('index.html', form=form)
times = htmlResults[2] locs = htmlResults[3] timesold = times times = Formatter.formatTimes(times) sdates = {'M':'26','T':'20','W':'21','R':'22','F':'23'} # The following code correlates the classes to each timeslot created from formatTimes. # Essentially, I screwed up somewhere and both times for the classes are not kept together and "time slots" are made instead. This just maps each class to it's respective slots. snames = {} for i in range(len(timesold)): snames[names[i]] = len(timesold[i]) dnames = {} k = 0 for j in range(7): for i in range(snames[names[j]]): dnames[k] = names[j] k += 1 #Back to normal code iCalCreation.iCalWrite(times, yearmonth, endyearmonthdaytime, sdates, dnames, filename) ical = open('OliniCalendar.ics','r') Emailer.iCalCreator(email,ical) os.remove('OliniCalendar.ics')