Exemple #1
0
 def removeObject(self, entityID):
     found = False
     for entity in self.__objects:
         if entity.getID() == entityID:
             found = True
     if not found:
         raise RepoError("Entity not in list")
     self.__objects[:] = [entity for entity in self.__objects if entity.getID() != entityID]
Exemple #2
0
 def removeGradeByDisciplineID(self, entityID):
     found = False
     for entity in self.__objects:
         if entity.getDisciplineID() == entityID:
             found = True
     if not found:
         raise RepoError("Entity not in list")
     self.__deletedObjects = [entity for entity in self.__objects if entity.getDisciplineID() == entityID]
     self.__objects = [entity for entity in self.__objects if entity.getDisciplineID() != entityID]
Exemple #3
0
 def get_all_items(self):
     if len(self._items) == 0:
         raise RepoError("The list is empty!")
     return self._items[:]
Exemple #4
0
 def remove(self, item):
     item = self.search(item)
     if item not in self._items:
         raise RepoError("The item you are trying to delete doesn't exist!")
     self._items.remove(item)
Exemple #5
0
 def search(self, item):
     if item not in self._items:
         raise RepoError("The item you are searching doesn't exist!")
     for item_required in self._items:
         if item_required == item:
             return item_required
Exemple #6
0
 def add(self, item):
     if item in self._items:
         raise RepoError("The item you are trying to add already exists!")
     self._items.append(item)
Exemple #7
0
 def searchEntityByName(self, entityName):
     foundEntities = [entity for entity in self.__objects if entityName.lower() in entity.getName().lower()]
     if len(foundEntities) == 0:
         raise RepoError("No matches found")
     return foundEntities
Exemple #8
0
 def searchEntityByID(self, entityID):
     for entity in self.__objects:
         if entity.getID() == entityID:
             return entity
     raise RepoError("Entity not in list")
Exemple #9
0
 def addUniqueObject(self, entity):
     if entity in self.__objects:
         raise RepoError("Entity already in list")
     self.__objects.append(entity)