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


Python Course.returnCourseName方法代碼示例

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


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

示例1: parseTranscript

# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import returnCourseName [as 別名]
  def parseTranscript(self, file):
    """
    Parses the student's unofficial transcript and builds a Courses object
    of all the classes in the transcript.
    """

    with open(file) as student_file:
      # Initialize Sentinel - For most classes Credit Hours appear on the
      # next line
      sentinel = 0
      # Initialize Sentinel_2 - Change from classes that are taken
      # to classes that are taking.
      sentinel_2 = False

      for line in student_file:
        line.strip()
        # Skip empty lines.
        if (re.match(r'^\s+$', line)):
          continue

        # We've got the Credits from the 2nd line, so reset sentinel
        if (sentinel > 1):
          sentinel = 0

        if (re.search(r'COURSES IN PROGRESS', line)):
            sentinel_2 = True

        # Only process lines that start with a Course Identifier or 
        #   when the sentinel is tripped.   
        if (re.search(r'[A-Z]{2,3}\s{1,3}(?:\d{3}|ELE)\s', line)
            or sentinel > 0):
          if (sentinel == 0):
            sl = line.split()

            # Some lines have a UG indicating Undergraduate
            #   Why? I don't know, but we need to ignore it.
            if (sl[2] == "UG"):
              course_name = " ".join(map(str, sl[3:-1]))
            else:
              course_name = " ".join(map(str, sl[2:-1]))

            if (sentinel_2):
                course_obj = Course(sl[0] + "-" + sl[1], " ".join(map(str, sl[3:])), 0, 0,
                                      False, 0.0)
            else:
                course_obj = Course(sl[0] + "-" + sl[1], course_name, 0, 0,
                                      True, sl[-1])
          # We're processing the 2nd line, which could, in fact be a
          # continuation of the first line. We need special processing for it.
          elif (sentinel == 1):
            val = line.split()
            if len(val) > 1:
                course_obj.setGradeEarned(val[-1])
                temp_course_title = course_obj.returnCourseName() + " "
                temp_course_title += " ".join(val[:-1])
                course_obj.setCourseName(temp_course_title)
                continue
            else:
                course_obj.setCredits(val[-1])

            self.taken_courses.addCourse(course_obj)
          sentinel += 1
開發者ID:lucentlab,項目名稱:advising-visualizer,代碼行數:64,代碼來源:student.py


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