Пример #1
0
 def instructors_info(self, path: str) -> None:
     """This function reperents each line from file instructors.txt and create instance of class instructor"""
     try:
         for cwid, name, department in file_reader(
                 os.path.join(self._path, 'instructors.txt'), 3, "|", True):
             self._instructors[cwid] = Instructors(cwid, name, department)
     except (FileNotFoundError, ValueError) as e:
         print(e)
Пример #2
0
 def major_info(self, path: str) -> None:
     """This function reperents each line from file majors.txt and create instance of class Major"""
     try:
         for major, flag, course in file_reader(
                 os.path.join(self._path, 'majors.txt'), 3, "\t", True):
             if major not in self._majors.keys():
                 self._majors[major] = Majors(major)
             self._majors[major].add_course(major, flag, course)
     except (FileNotFoundError, ValueError) as e:
         print(e)
Пример #3
0
 def _instructor_data(self) -> None:
     """ This finction  creates examples of instructors and updates it in the container """
     try:
         for cwid, name, department in file_reader(os.path.join(self._path, "instructors.txt"), 3, "\t", True):
             if cwid in self._instructors:
                 print(f"{cwid} is duplicate")
             else:
                 self._instructors[cwid] = Instructor(cwid, name, department)
     except (FileNotFoundError, ValueError) as e:
         print(e)
Пример #4
0
 def _student_data(self) -> None:
     """ This finction creates examples of students and updates it in the container"""
     try:
         for cwid, name, major in file_reader(os.path.join(self._path, "students.txt"), 3, "\t", True):
             if cwid in self._students:
                 print(f"{cwid} is duplicate")
             else:
                 self._students[cwid] = Student(cwid, name, major, self._majors[major]._required, self._majors[major]._elective)
     except (FileNotFoundError, ValueError) as e:
         print(e)
Пример #5
0
 def _majors_data(self) -> None:
     """ This finction defines the majors and requried courses for each major """
     try:
         for major, flag, course in file_reader(os.path.join(self._path, "majors.txt"), 3, "\t", True):
             if major in self._majors:
                 self._majors[major].add_course(flag, course)
             else:
                 self._majors[major] = Major(major)
                 self._majors[major].add_course(flag, course)
     except (FileNotFoundError, ValueError) as e:
         print(e)
Пример #6
0
 def students_info(self, path: str) -> None:
     """This function reperents each line from students.txt and create instance of class student"""
     try:
         for cwid, name, major in file_reader(
                 os.path.join(self._path, 'students.txt'), 3, ";", True):
             if major in self._majors[major]._major:
                 required = self._majors[major].req_course()
                 elective = self._majors[major].elec_course()
                 self._students[cwid] = Students(cwid, name, major,
                                                 required, elective)
     except (FileNotFoundError, ValueError) as e:
         print(e)
Пример #7
0
    def _grades_data(self) -> None:
        """ This finction defines the grades file and updates the student and instructor """
        try:
            for cwid, course, grade, instructor_cwid in file_reader(os.path.join(self._path, "grades.txt"), 4, "\t", True):
                if cwid in self._students:
                    s: Student = self._students[cwid]
                    s.course_grade(course, grade)
                else:
                    print(f"Student with id: {cwid} doesn't exist in the student repository")
                
                if instructor_cwid in self._instructors:
                    inst: Instructor = self._instructors[instructor_cwid]
                    inst.store_course_student(course)
                else:
                    print(f"Instructor with id: {cwid} doesn't exist in the instructor repository")

        except (FileNotFoundError, ValueError) as e:
            print(e)
Пример #8
0
 def grades_info(self, path: str) -> None:
     """ This function reperents student_cwid, course, grade, instructor"""
     try:
         for student_cwid, course, grades, instructor_cwid in file_reader(
                 os.path.join(self._path, 'grades.txt'), 4, "|", True):
             if student_cwid in self._students.keys():
                 stu: Students = self._students[student_cwid]
                 stu.store_course_grade(course, grades)
             else:
                 print(
                     f"The Student with CWID : {student_cwid} is unknown.")
             if instructor_cwid in self._instructors.keys():
                 inst: Instructors = self._instructors[instructor_cwid]
                 inst.store_course_student(course)
             else:
                 print(
                     f"The Instructor with CWID : {instructor_cwid} is unknown."
                 )
     except (FileNotFoundError, ValueError) as e:
         if FileNotFoundError:
             print(e)