if not teacher in self._db.keys(): self._db[teacher] = 0 self._db[teacher] += 1 def total(self): return len(list(self._db.keys())) if __name__ == '__main__': class Config: verbose = False courses = True teachers = True students = True students = Students(Config()) teachers = Teachers() ns = Smartformatter() for student_key in students.get_student_keys(): student = students.get_student(student_key) for teacher in student.get_teachers_as_list(): teachers.add(teacher) ns.total_load = 0 teacher_tuples = [] for ns.teacher in teachers._db.keys(): ns.total_load += teachers._db[ns.teacher] teacher_tuples.append( (ns.teacher, teachers._db[ns.teacher]) )
from psmdlsyncer.Students import Students, put_in_order from psmdlsyncer.settings import config from psmdlsyncer.utils.DB import DragonNetDBConnection from psmdlsyncer.utils.Formatter import Smartformatter from collections import defaultdict if __name__ == "__main__": students = Students() dnet = DragonNetDBConnection() all_ids = dnet.get_all_students_name_ids() to_delete = [] for this_id, username, first, last in all_ids: if not this_id: continue student = students.get_student(this_id) if not student and not students.get_teacher(last + ', ' + first): to_delete.append( (this_id, username) ) #for this_id, username in to_delete: #print(username + ',deleted') parents = dnet.get_all_parent_name_ids() for idnumber, username in parents: children = students.get_family(idnumber) if not children: print(username + ',deleted')