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


Python Scheduler.populateCourseData方法代码示例

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


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

示例1: test5

# 需要导入模块: from Scheduler import Scheduler [as 别名]
# 或者: from Scheduler.Scheduler import populateCourseData [as 别名]
	def test5(self):
		self.initScheduler()
		stu = Student("patrick.txt")
		maj = Major("CS.req")
		
		sched = Scheduler()
		sched.populateCourseData()
		Scheduler.student = stu
		Scheduler.major = maj
		
		taken = [Scheduler.getCourse(data) for data in stu.classesTaken]
		
		try:
			sched.syncMajorWithStudent() ## this is being tested
		except:
			assert False, "Failed test 6: exception"
		
		for req in Scheduler.major.getRequirements():
			for course in req.getCourses():
				if course in taken:
					print course.name, "not removed from major"
					assert False, "Failed test 6: sync error"
开发者ID:nightwolf55la,项目名称:CS206,代码行数:24,代码来源:TestFile.py

示例2: __init__

# 需要导入模块: from Scheduler import Scheduler [as 别名]
# 或者: from Scheduler.Scheduler import populateCourseData [as 别名]
class TestFile:
	def __init__(self):
		self.sc = Scheduler()

	def initScheduler(self):
		Scheduler.courseSchedule = []
		Scheduler.coursePool = {"Mon08:00":"None", "Mon09:00":"None", "Mon10:00":"None", "Mon11:00":"None", "Mon12:00":"None", "Mon01:00":"None", "Mon02:00":"None", "Mon03:00":"None", "Mon04:00":"None", "Mon05:00":"None", "Mon06:00":"None", "Mon07:00":"None",
		"Tue08:00":"None", "Tue09:30":"None", "Tue11:00":"None", "Tue12:30":"None", "Tue02:00":"None", "Tue03:30":"None", "Tue05:00":"None", "Tue06:30":"None",
		"Wed08:00":"None", "Wed09:00":"None", "Wed10:00":"None", "Wed11:00":"None", "Wed12:00":"None", "Wed01:00":"None", "Wed02:00":"None", "Wed03:00":"None", "Wed04:00":"None", "Wed05:00":"None", "Wed06:00":"None", "Wed07:00":"None",
		"Thu08:00":"None", "Thu09:30":"None", "Thu11:00":"None", "Thu12:30":"None", "Thu02:00":"None", "Thu03:30":"None", "Thu05:00":"None", "Thu06:30":"None",
		"Fri08:00":"None", "Fri09:00":"None", "Fri10:00":"None", "Fri11:00":"None", "Fri12:00":"None", "Fri01:00":"None", "Fri02:00":"None", "Fri03:00":"None", "Fri04:00":"None", "Fri05:00":"None", "Fri06:00":"None", "Fri07:00":"None",}
		Scheduler.major = None
		Scheduler.student = None
		Scheduler.maxHoursPerSemester = 18
		Scheduler.startingSemester = 0
		
		Scheduler.allCourses = []
		
	def genDummyCourse(self):
		line = "CS,53,Introduction to Programming,STD,3,2,NONE,09:00|M-W-F"
		keys = "major","ID","name","type","hours","semesterAvail","prerequisites","timesAvailable"
		courseArgs = {}
		for key, val in zip(keys, line.split(',')):
			if key == "prerequisites":
				val = []
			if key == "timesAvailable":
				val = [val]
			courseArgs[key] = val
		return Course(courseArgs)
		
	def printCourseData(self):
		self.initScheduler()
		self.sc.populateCourseData()

		for course in self.sc.allCourses:
			print course.getMajor() + " " + str(course.getID()) + " " + course.getName() + " " + course.getType() + " " + str(course.getHours()) + " " + str(course.getSemesterAvailable())
			print "Prerequisites: "
			trees = course.getPrerequisites()
			for i in range(0, len(trees)): #Iterate over trees
				if i > 0:
					print "\tOR"
				for prereq in trees[i]:
					print "\t" + prereq.getMajor() + " " + str(prereq.getID())
			print "Times available: "
			for time in course.getTimes():
				print "\t" + str(time)
	
	def printRequirements(self):
		self.initScheduler()
		Scheduler.major = Major("CS.req")
		print "", "Major: %s" % Scheduler.major.name, "Hours: %s" % Scheduler.major.totalHours, "Requirements:"
		for req in Scheduler.major.requirements:
			print req.inclusion
			
		Scheduler.major = Major("Chem.req")
		print "", "Major: %s" % Scheduler.major.name, "Hours: %s" % Scheduler.major.totalHours, "Requirements:"
		for req in Scheduler.major.requirements:
			print req.inclusion	

	''' Test #5 
		Desc: make sure student's classes are synchronized with the course list
		Class: Scheduler Method: syncMajorWithStudent(self)
		Input: valid student, major, and course files '''
	def test5(self):
		self.initScheduler()
		stu = Student("patrick.txt")
		maj = Major("CS.req")
		
		sched = Scheduler()
		sched.populateCourseData()
		Scheduler.student = stu
		Scheduler.major = maj
		
		taken = [Scheduler.getCourse(data) for data in stu.classesTaken]
		
		try:
			sched.syncMajorWithStudent() ## this is being tested
		except:
			assert False, "Failed test 6: exception"
		
		for req in Scheduler.major.getRequirements():
			for course in req.getCourses():
				if course in taken:
					print course.name, "not removed from major"
					assert False, "Failed test 6: sync error"
		
	''' Test #6
	Desc: Tests to see if a course is found in a given course list
	Class: Scheduler	 Method: getCourse(self)
	Input: valid course list'''
	def test6(self):
		self.initScheduler()
		dummyCourse = self.genDummyCourse()
		data = "CS", "53"
		
		oldAllCourses = Scheduler.allCourses
		Scheduler.allCourses = [dummyCourse]
		try:
			found = Scheduler.getCourse(data, [dummyCourse])
		except:
#.........这里部分代码省略.........
开发者ID:nightwolf55la,项目名称:CS206,代码行数:103,代码来源:TestFile.py


注:本文中的Scheduler.Scheduler.populateCourseData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。