本文整理汇总了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))