def performUndo(null): repoCaller = Repo() indexOfOperations = repoCaller.getIndexOfOperations() listOfOperations = repoCaller.getListOfOperations() commands = { "removeB": removeABook, "removeC": removeAClient, "addB": addABook, "addC": addAClient, "updateB": updateABook, "updateC": updateAClient } if indexOfOperations >= 0: commands[Undo.getFuntion(listOfOperations[indexOfOperations])]( Undo.getParameters(listOfOperations[indexOfOperations])) repoCaller.decrementIndex() repoCaller.setRedoTrue() else: return "Cannot undo anymore" return False
def performRedo(null): repoCaller = Repo() listOfOperations = repoCaller.getListOfOperations() canRedo = repoCaller.getRedoState() if canRedo == True: repoCaller.incrementIndex() index = repoCaller.getIndexOfOperations() commands = { "removeB": addABook, "removeC": addAClient, "addB": removeABook, "addC": removeAClient, "updateB": updateABook, "updateC": updateAClient } if "update" in Undo.getFuntion(listOfOperations[index]): commands[Undo.getFuntion(listOfOperations[index])]( Undo.getParametersUpdate(listOfOperations[index])) else: commands[Undo.getFuntion(listOfOperations[index])]( Undo.getParameters(listOfOperations[index])) return False