예제 #1
0
	def make_with_conversion(cls, idnumber, name, *args, **kwargs):
		short, name = convert_short_long(idnumber, name)
		ret = cls.make(short, name, *args, **kwargs)
		if cls.exclude(idnumber, name) and not ret.exclude:
			ret.exclude = True
		return ret
예제 #2
0
	def get_with_conversion(cls, idnumber):
		short, _ = convert_short_long(idnumber, "")
		return cls.get_key(short)
        self.db[id_str].append(course)

    def __iter__(self):
        return self.db

if __name__ == "__main__":

    # courses = TextFileReader('../powerschool/ssis_dist_courseinfo_v4.0',
    #                          interface_class=Course)
    all_courses = All()

    with open('../../powerschool/ssis_dist_courseinfo_v4.0') as _file: 
        for line in _file.readlines():
            course = Course()
            course.course_number, course.course_name = line.strip('\n').split('\t')
            course.short_after, course.long_after = convert_short_long(course.course_number, course.course_name)
            all_courses.add(course)

    # for course in all_courses:
    #     after_conversion = convert_short_long(course.course_number, course.course_name)
    #     course.short_after, course.long_after = after_conversion
    #     all_courses.add(course)

    with open('../output/course_output.txt', 'w') as f:
        f.write('ps\t' + 'dn_idnumber\t' + 'summary\n')
        for key in all_courses.items():
            course_list = all_courses.get(key)
            summary = ",".join([c.course_number for c in course_list])
            after = ([c.short_after for c in course_list])
            assert len(after) == 1
            after = after[0]