def _get_instructors(self, path: str) -> None:
     """read instructors data from file using file_reader into the container
     """
     try:
         instructors_data: Iterator(Tuple[str]) = file_reader(path,
                                                              3,
                                                              sep="\t",
                                                              header=True)
         for cwid, name, department in instructors_data:
             self._instructors_dict[cwid] = Instructor(
                 cwid, name, department)
     except ValueError as v:
         print(v)
 def _get_majors(self, path: str) -> None:
     """read majors data from file using file_reader into the container"""
     try:
         majors_data: Iterator(Tuple[str]) = file_reader(path,
                                                         3,
                                                         sep="\t",
                                                         header=True)
         for major, flag, course in majors_data:
             if major not in self._majors_dict:
                 self._majors_dict[major] = Major(major)
             self._majors_dict[major].add_course(course, flag)
     except ValueError as v:
         print(v)
 def _get_students(self, path: str) -> None:
     """read students data from file into the container"""
     try:
         students_data: Iterator(Tuple[str]) = file_reader(path,
                                                           3,
                                                           sep="\t",
                                                           header=True)
         for cwid, name, major in students_data:
             if major not in self._majors_dict:
                 print(f"Student {cwid} '{name}' has unknown major {major}")
             else:
                 self._students_dict[cwid] = Student(
                     cwid, name, self._majors_dict[major])
     except ValueError as v:
         print(v)
 def _get_grades(self, path: str) -> None:
     """read data of grades from grades file and update student and
        instructor data.
     """
     grades: Iterator(Tuple[str]) = file_reader(path,
                                                4,
                                                sep="\t",
                                                header=True)
     for st_cwid, course, grade, inst_cwid in grades:
         if st_cwid in self._students_dict:
             self._students_dict[st_cwid].add_course(course, grade)
         else:
             print(f"grade for unknown student {st_cwid}")
         if inst_cwid in self._instructors_dict:
             self._instructors_dict[inst_cwid].update_students(course)
         else:
             print(f"grade for unkown instructor {inst_cwid}")
Example #5
0
 def edges(self) -> Iterator(Edge):
     return iter(self.edgelist)
Example #6
0
 def __enter__(self) -> Iterator:
     """Open all transferred files."""
     self.file_open_list = [open(Path(i)) for i in self.lst]
     return Iterator(self.file_open_list)
Example #7
0
 def conflict_points(self) -> Iterator(Tuple[float, ConflictPoint]):
     """Get iterator for sorted conflict points."""
     if not self._sorted:
         self._conflict_points.sort()
         self._sorted = True
     yield from self._conflict_points