#!/usr/bin/python2.5 '''Generate a class calendar using duration of semester, the days of the week a class meets, and holidays. Also indicates tenative due-dates for assignments.''' from dateutil.rrule import * from dateutil.parser import * sem_start = '20080902' sem_end = '20081211' holidays = [parse(hday) for hday in ('081013', '081014', '081127', '081128')] assgn_d = {} class_num = 1 # class number and the assignment due cm_assignments = '''4 = Conflict, its definition, and types 8 = Socio-psycho dynamics (film analysis) 10 = Conflict process and behaviors 18 = Apology and reconciliation 25 = Cross-cultural, intra-cultural or gender 28 = Take-home final''' mts_assignments = '''11 = Midterm: Failed Predictions 24 = Final''' #assgns = cm_assignments.split('\n') #days = MO,WE assgns = mts_assignments.split('\n') days = TU,TH for assgn in assgns: assgn_class,assgn_title = assgn.split(' = ') assgn_d[assgn_class] = assgn_title meetings = list(rrule(WEEKLY, wkst=SU, byweekday=(days), dtstart=parse(sem_start), until=parse(sem_end))) for meeting in meetings: if meeting not in holidays: print str(class_num) + ' ' + meeting.strftime("%b %d %a"), if str(class_num) in assgn_d.keys(): print "Due: %s" % assgn_d[str(class_num)], class_num += 1 else: print meeting.strftime("%b %d %a") + " NO CLASS", print