def addABook(commandInPieces): # adds a book to the repository # input - details about the book as a list bookId = commandInPieces[1] repoCaller = Repo() bookTitle = commandInPieces[2] bookAuthor = commandInPieces[3] newBook = Book(bookId, bookTitle, bookAuthor) undoFunction = Undo("removeB", ["undo", bookId, bookTitle, bookAuthor]) if commandInPieces[0] != "undo": repoCaller.addToListOfOperations(undoFunction) repoCaller.setRedoFalse() try: validateABook(newBook) repoCaller.addTheBookToTheRepo(newBook) repoCaller.loadIntoFiles() repoCaller.loadIntoPickle() except BookAlreadyExistsError: print(str(BookAlreadyExistsError())) return False