當前位置: 首頁>>代碼示例>>Python>>正文


Python Course.campus方法代碼示例

本文整理匯總了Python中course.Course.campus方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.campus方法的具體用法?Python Course.campus怎麽用?Python Course.campus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在course.Course的用法示例。


在下文中一共展示了Course.campus方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse

# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import campus [as 別名]
    def parse(self):
        """Return a list of all courses formatted from the html file."""
        tree = make_tree(self.url)
        is_summer = (self.semester == 'summer')
        tree = clean_html(tree, is_summer)

        tables = tree.xpath('//table')
        courses = []
        for t in tables:
            td = t.xpath("td[contains(@class, 'cusistabledata')]")
            # Since it is not possible to find the tr elements using
            # lxml we find all the td elements and make a 2 dimensional
            # array representing the table.
            rows = [td[i:i + 8] for i in xrange(0, len(td), 8)]

            course_term = []
            seen_course = {}
            # result = None
            for row in rows:
                course = Course()
                # Course name ex: COMP + 352 / 1
                course_name = '{} {}'.format(row[2].text, row[3].text)

                # Group same course together.
                # result, seen_course = self.same_course(
                #     course_name, seen_course)

                ((course.colorid, course.summary),
                    seen_course) = self.same_course(course_name, seen_course)

                course.datetime_day = row[0].text
                course.time = row[1].text
                course.room = row[5].text
                course.campus = row[6].text
                course.professor = row[7].text

                course.section = row[4].text
                course.semester = self.semester
                # Append the summer section to the semester.
                if is_summer:
                    course.semester += get_summer_section(
                        course.section.split(' ')[1][0])
                # Append the buildings address of a specific course and format
                # the data.
                course.format_data(self.buildings)
                course_term.append(course)
            # Make sure to not to have 2 instances of the same course.
            course_term = recurent_event_factor(course_term)
            courses.append(course_term)
        return courses
開發者ID:samuelmasuy,項目名稱:Concordia-Schedule-to-Gcal,代碼行數:52,代碼來源:scraper.py


注:本文中的course.Course.campus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。