class repository: def __init__(self, validatior_class): self._entities = Vector() self.__validator_class = validatior_class def save(self, entity): self.__validator_class.validate(entity) lst = self._entities[:] lst.append(entity) self._entities.load_list(lst) def find_all(self): return self._entities #return list(self._entities.values()) def find_by_id(self, id): return self._entities[id] def update(self, new_entity): self.save(new_entity) def delete_by_id(self, id): del self._entities[id] def current_id(self): return len(self._entities)
def busiest_days(self): days_dto = self.__act_service.get_days_dto() v = Vector() v.load_list(days_dto) print(len(v)) list = MySort(v, lambda x, y: x.no_of_act >= y.no_of_act) return list
def act_for_day(self, day): days_dto = self.__act_service.get_days_dto() v = Vector() v.load_list(days_dto) list = Filter(v, lambda x: x.day == day) if list == []: return [] return list[0].act
def test_Vector(self): lst = [1, 2, 3, 4] v = Vector() v.load_list(lst) del (v[0]) self.assertEqual(v[0], 2) v.__setitem__(2, 5) self.assertEqual(v[2], 5) self.assertEqual(len(v), 3)
def __init__(self, validatior_class): self._entities = Vector() self.__validator_class = validatior_class
def list_ppl(self): people_dto = self.__prs_service.get_all_people_dto() v = Vector() v.load_list(people_dto) list = MySort(v, lambda x, y: x.no_of_act >= y.no_of_act) return list
def act_for_prs(self, id): people_dto = self.__prs_service.get_all_people_dto() v = Vector() v.load_list(people_dto) list = Filter(v, lambda x: x.person.id == id) return list[0].act