def setup(self): toAddQtr = input('Enter the quarter (Eg. FALL 2015): ') toAddQtr = re.compile('\w+').findall(toAddQtr) term = toAddQtr[0].upper() year = toAddQtr[1] qtr = Quarter.quarter(term, year) while True: toAddCourse = input('Enter the course (Eg. CSE 30): ') if toAddCourse == "": break toAddCourse = re.compile('\w+').findall(toAddCourse) dpt = toAddCourse[0].upper() num = toAddCourse[1].upper() units = input('Enter the units: ') units = float(units) course = Course.course(dpt,num,units) qtr.addCourse(course) return qtr
def setup(self): toAddQtr = input('Enter the quarter (Eg. FALL 2015): ') toAddQtr = re.compile('\w+').findall(toAddQtr) term = toAddQtr[0].upper() year = toAddQtr[1] qtr = Quarter.quarter(term, year) while True: toAddCourse = input('Enter the course (Eg. CSE 30): ') if toAddCourse == "": break toAddCourse = re.compile('\w+').findall(toAddCourse) dpt = toAddCourse[0].upper() num = toAddCourse[1].upper() units = input('Enter the units: ') units = float(units) course = Course.course(dpt, num, units) qtr.addCourse(course) return qtr
course = None numQuarters = 0 print("\t>\tReading from " + file) for line in fid: line = re.compile('[a-zA-Z+-]+|[0-9A-Z.]+|[\t]+').findall(line) be = None if line.__len__() > 0: be = line[0] if be == 'FALL' or be == 'WINTER' or be == 'SPRING' or be == 'SUMMER': term = line[0].upper() year = line[1] qtr = Quarter.quarter(term,year) elif be == '\t': dept = line[1].upper() num = line[2].upper() units = float(line[3]) grade = line[4].upper() course = Course.course(dept,num,units) course.setGrade(grade) qtr.addCourse(course) elif be == "Total": addQuarter(qtr) numQuarters += 1 qtr = None