示例#1
0
def main(semester, year):
    data = parse_scg_file(semester, year, 'XL')
    for row in data:
        cid = row['cid']
        try:
            course = Course.objects.get(pk=cid)
        except:
            print "Weird, no object found with key " + cid

        course.dep = row['dep']
        course.num = row['num']
        #course.save()

        crosslists = row['cross_list']
        crosslists = map(lambda x: x.split(' '), crosslists.split('/'))
        for (dep, num) in crosslists:
            cl = CrossList.objects.get_or_create(course=course,dep=dep,num=num)
示例#2
0
def main(semester, year):
    data = parse_scg_file(semester, year, 'XL')
    for row in data:
        cid = row['cid']
        try:
            course = Course.objects.get(pk=cid)
        except:
            print "Weird, no object found with key " + cid

        course.dep = row['dep']
        course.num = row['num']
        #course.save()

        crosslists = row['cross_list']
        crosslists = map(lambda x: x.split(' '), crosslists.split('/'))
        for (dep, num) in crosslists:
            cl = CrossList.objects.get_or_create(course=course,
                                                 dep=dep,
                                                 num=num)
示例#3
0
def main(semester, year):
    data = parse_scg_file(semester, year, 'ST')
    for row in data:
        cid = row['cid']
        sid = row['sid']

        days ='-'.join([row['day1'],row['day2'],row['day3'],row['day4'],row['day5']])
        row['days'] = days

        import datetime, time
        from datetime import datetime
        format = '%I:%M %p'
        if row['begins'] != 'TBA' and row['begins'] != '':
            length = datetime(*(time.strptime(row['ends'], format)[0:6])) - datetime(*(time.strptime(row['begins'], format)[0:6]))
            length = int(length.seconds / 60)
        else:
            length = 0
        row['length'] = length

        del(row['dep'])
        del(row['num'])
        del(row['term'])
        del(row['blank'])
        del(row['sid'])
        del(row['cid'])

        try:
            course = Course.objects.get(pk=cid)

            offering = Offering.objects.get_or_create(course=course, year=year, semester=semester)[0]

            row.update({'offering':offering})

            s, created = Section.objects.get_or_create(sid=sid,defaults=row)
            if not created:
                s.__dict__.update(row)
                s.save()

        except Exception, e:
            print 'course %s does not exist' % cid
            print e
示例#4
0
def main(semester, year):
    data = parse_scg_file(semester, year, 'CT')

    for row in data:
        cid = row['cid']

        authors = []
        for i in range(1,7):
            author = row['author'+str(i)]
            if author != '':
                authors.append(author)

        row.update({'authors':', '.join(authors)})
        row.update({'dep':row['dep1']})
        row.update({'num':row['num1']})
        row.update({'semester':semester})
        row.update({'year':year})

        del(row['dep1'])
        del(row['num1'])
        del(row['blank'])
        del(row['author1'])
        del(row['author2'])
        del(row['author3'])
        del(row['author4'])
        del(row['author5'])
        del(row['author6'])
        del(row['dep2'])
        del(row['num2'])
        del(row['cross_lists'])
        del(row['cid'])

        course = Course.objects.get_or_create(cid=cid)[0]
        offering = Offering.objects.get_or_create(course=course, year=year, semester=semester)

        course.__dict__.update(row)
        course.save()
示例#5
0
def main(semester, year):
    data = parse_scg_file(semester, year, 'SCG')
    P = Professor.objects

    for row in data:
        # Add *or update* professors given the new information.
        for i in (1, 2, 3):
            pid = 'pid' + str(i)
            if not row[pid]: continue

            data = professor_data(row, i)
            p, created = P.get_or_create(pid=row[pid], defaults=data)
            if not created:
                p.__dict__.update(data)
                p.save()

        course_dict = {'dep': row['dep1'],
                       'num': row['num1'],
                       'dr': row['dr'],
                       'cross_list': row['dep2'] + u' ' + row['num2'],
                       'title': row['title'],
                       'is_cancelled': row['is_cancelled'],
                       'is_closed': row['is_closed'],
                       }

        course = Course.objects.get_or_create(cid=row['cid'],
                                              defaults=course_dict)[0]

        for i in (1, 2, 3):
            pid = 'pid' + str(i)
            if row[pid] != '':
                p = P.get(pid=row[pid])
                offering = Offering.objects.get_or_create(course=course,
                                                          year=year,
                                                          semester=semester)[0]
                offering.professors.add(p)