当前位置: 首页>>代码示例>>Python>>正文


Python Course.setCourseName方法代码示例

本文整理汇总了Python中course.Course.setCourseName方法的典型用法代码示例。如果您正苦于以下问题:Python Course.setCourseName方法的具体用法?Python Course.setCourseName怎么用?Python Course.setCourseName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在course.Course的用法示例。


在下文中一共展示了Course.setCourseName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parseTranscript

# 需要导入模块: from course import Course [as 别名]
# 或者: from course.Course import setCourseName [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.setCourseName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。