示例#1
0
def extractInfo(classInfo,year,semester):
    classInfo = classInfo.split('.0 ')[1]
    className = classInfo.split('\\n')[0]
    if str(className).startswith('Credit'):
        className = str(className).split('Credit ')[1]
    classInfo = classInfo.split('\\n')[-1]
    classLocation = classInfo.split(' -')[0]
    if ' -' in str(classInfo):
        classInfo = classInfo.split(' -')[1]
    elif 'M-' in str(classInfo):
        classInfo = 'M-' + str(classInfo.split('M-')[1])
    classTimes = classInfo
    print classTimes
    if '- ' in classTimes:
        classTime = classTimes.split('- ')[1:]
    '''
    for character in str(classTime):
        print character, character.encode('hex')
    '''
    print classTime
    if '-' in str(classTime):
        classTime = str(classTime).split('-')
    print classTime
    classDays = classInfo.split(' ')[0]
    #classTime = str(classTimes.split(':')[0])+':'+str(classTimes.split(':')[1])+':'+str(classTimes.split(':')[2])
    #print "Class " + str(className) + " meets in " + str(classLocation) + " on the days " + str(classDays) + ' from ' + str(classTime)
    classStartHour,classStartMinute,classEndHour,classEndMinute = extractDaysTimes.extractStartStopTimes(classTime)
    daysWithClass = extractDaysTimes.extractDaysOfWeek(classDays)
    firstMonth,firstDay,lastMonth,lastDay = getDates.findBeginEnd(semester,year) #Send this info to getDates to find when this specific semester starts and ends
classesTable = classList.find(
    id="tabSched"
)  # Parse through the HTML table and put information for each class into a list of lists
rows = classesTable.findAll("tr")
for tr in rows:
    cols = tr.findAll("td")
    classInfo = []  # Temporary list of info for each class
    for td in cols:
        for item in td:
            classInfo.append(item.string)
    if classInfo[0] == "Enrolled":  # We only want to add classes we are enrolled in
        classTime = classInfo[5]
        classDayTime = classTime.split(" ")  # classDayTime[0] is the days of the week
        # classDatTime[1] is the start-end time
        classStartHour, classStartMinute, classEndHour, classEndMinute = extractDaysTimes.extractStartStopTimes(
            classDayTime
        )  # Find when the class starts and stops
        classDaysOfWeek = extractDaysTimes.extractDaysOfWeek(
            classDayTime
        )  # Find which days of the week this class is held
        className = classInfo[2]
        classLocation = classInfo[6]
        enrolledClasses.append(
            [
                className,
                classLocation,
                classYear,
                firstMonth,
                lastMonth,
                firstDay,
                lastDay,
enrolledClasses = []

classesTable = classList.find(
    id='tabSched'
)  #Parse through the HTML table and put information for each class into a list of lists
rows = classesTable.findAll('tr')
for tr in rows:
    cols = tr.findAll('td')
    classInfo = []  #Temporary list of info for each class
    for td in cols:
        for item in td:
            classInfo.append(item.string)
    if classInfo[
            0] == 'Enrolled':  #We only want to add classes we are enrolled in
        classTime = classInfo[5]
        classDayTime = classTime.split(
            ' ')  #classDayTime[0] is the days of the week
        #classDatTime[1] is the start-end time
        classStartHour, classStartMinute, classEndHour, classEndMinute = extractDaysTimes.extractStartStopTimes(
            classDayTime)  #Find when the class starts and stops
        classDaysOfWeek = extractDaysTimes.extractDaysOfWeek(
            classDayTime)  #Find which days of the week this class is held
        className = classInfo[2]
        classLocation = classInfo[6]
        enrolledClasses.append([
            className, classLocation, classYear, firstMonth, lastMonth,
            firstDay, lastDay, classStartHour, classStartMinute, classEndHour,
            classEndMinute, classDaysOfWeek
        ])

makeCalendar.write(enrolledClasses)  #Make this info into calendar events