本文整理匯總了Python中course.Course.get_all_by_crn方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.get_all_by_crn方法的具體用法?Python Course.get_all_by_crn怎麽用?Python Course.get_all_by_crn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類course.Course
的用法示例。
在下文中一共展示了Course.get_all_by_crn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __make_schedule
# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import get_all_by_crn [as 別名]
def __make_schedule(requirements, current_schedule):
if len(requirements) == 0:
return current_schedule
requirement = requirements[0]
requirements = requirements[1:]
for course in requirement.valid_courses:
if len(Course.get_all_by_crn(course)) == 0:
raise Exception("No class in catalog; %s" % course)
for c in Course.get_all_by_crn(course):
# Check to see if this course conflicts with anything
conflicts = False
for c2 in current_schedule:
if c.timeslot.conflicts(c2.timeslot):
conflicts = True
break
if not conflicts:
# Make sure we can take it, then recurse
schedule = []
if not c.can_take(current_schedule, credit_hour_limit=max_credits):
schedule = __make_schedule(requirements, current_schedule)
if schedule == False:
continue
# If we still can't take it, continue
if not c.can_take(schedule, credit_hour_limit=max_credits):
continue
schedule += [c]
else:
schedule = __make_schedule(requirements, current_schedule + [c])
if schedule != False:
return schedule
return False
示例2: test_get_courses_by_crn
# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import get_all_by_crn [as 別名]
def test_get_courses_by_crn(self):
# Timeslot can be empty for this
c1 = Course("CSCI2121", None)
c2 = Course("CSCI2121", None)
c3 = Course("CSCI2121", None)
c4 = Course("CSCI2122", None)
self.assertEquals(3, len(Course.get_all_by_crn("CSCI2121")))
示例3: get_worst_crn
# 需要導入模塊: from course import Course [as 別名]
# 或者: from course.Course import get_all_by_crn [as 別名]
def get_worst_crn(self):
lowest = self.valid_courses[0]
for c in self.valid_courses[1:]:
if len(Course.get_all_by_crn(c)) < len(Course.get_all_by_crn(lowest)):
lowest = c
return len(Course.get_all_by_crn(lowest))