def parseCourse(self, course, dow): course = re.compile( '</a.*\n.*br.*">').sub(', ', course) course = re.compile( '<t.*">|<.*.*>').sub('', course) course = re.split('(\n|\t|\r)*' , course) times = ParserUtil.parseTime(course[2], ":") startDate = ParserUtil.parseStartDate(course[8], "/") originalLevel = self.parseOriginalLevel(course[4]) level = self.parseLevel(course[4]) genre = ParserUtil.parseGenre(course[4]) type = ParserUtil.parseType(course[4]) if not type: type = "partnerwork" instructors = re.split(',', course[6]) #name, description, school, level, days, genre, classCount, instructors, type, startDate, startTime, endTime courseLine = self.toJSONFormatCourse(course[4], course[8], self.SCHOOL_NAME, level, originalLevel, [dow], genre, type, self.DEFAULT_COURSE_DAYS_NUM, instructors, startDate, times[0], times[1], ParserUtil.getDuration(times[1], times[0])) return courseLine
def parseCourse(self, course, week): courseSplit = re.split("<br />", course) timeLine = courseSplit[0] if timeLine[0].isdigit(): dow=int(timeLine[0])-1 if not week: dow = dow + 5 else: return name = courseSplit[1].strip() times = ParserUtil.parseTime(timeLine[3:].strip(), '.') startDate = ParserUtil.parseStartDate(courseSplit[2].strip(), ".") if len(courseSplit) > 3: if startDate == '': startDate = ParserUtil.parseStartDate(courseSplit[3], ".") instructors = self.getInstructors(courseSplit) type = ParserUtil.parseType(courseSplit[1]) if not type: type = ParserUtil.parseType(courseSplit[2]) if not type: type = "partnerwork" level = self.parseLevel(courseSplit[1]) if level == "": level = self.parseLevel(courseSplit[2]) if level == "" and type == TYPE_PARTNER : if ParserUtil.getDiffInDaysFromNow(startDate) > 84: level = LEVEL_INTERMEDIATE else: level = LEVEL_BASIC if level == "" and type == TYPE_SOLO : level = LEVEL_OPEN genre = ParserUtil.parseGenre(courseSplit[1]) description = '' courseCount = self.DEFAULT_COURSE_DAYS_NUM if genre and genre[0] == GENRE_ZOUK: courseCount = 2 description = courseSplit[3].strip() + " " + courseSplit[4].strip() dates = re.findall("\d{1,2}.\d{2}", description) pastEvent = True; currentDate = date.today() for dateString in dates: month = int(dateString[3:5]) if month > currentDate.month: pastEvent = False if month == currentDate.month: day = int(dateString[0:2]) if day >= currentDate.day: pastEvent = False if pastEvent: return originalLevel = level #name, description, school, level, days, genre, classCount, instructors, type, startDate, startTime, endTime courseLine = self.toJSONFormatCourse(name, description, self.SCHOOL_NAME, level, originalLevel, [dow], genre, type, courseCount, instructors, startDate, times[0], times[1], ParserUtil.getDuration(times[1], times[0])) return courseLine