本文整理匯總了Python中course.Course.setCredits方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.setCredits方法的具體用法?Python Course.setCredits怎麽用?Python Course.setCredits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類course.Course
的用法示例。
在下文中一共展示了Course.setCredits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parseTranscript
# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import setCredits [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