コード例 #1
0
 def addMovieAtIndex(self, movie, index):
     '''
     Function will add a movie in the list at a specific index
     :param movie: the movie which should be inserted
     :param index: the index where it should be inserted
     '''
     MovieRepository.insert(self, movie, index)
     self.storeToFile()
コード例 #2
0
 def __loadFromFile(self):
     file = open(self.__fileName, "r")
     try:
         line = file.readline().strip()
         while line != "":
             attributes = line.split(";")
             movie = Movie(int(attributes[0]), attributes[1], attributes[2],
                           attributes[3])
             MovieRepository.add(self, movie)
             line = file.readline().strip()
     except IOError:
         raise FileRepositoryException("Movie File error")
     finally:
         file.close()
コード例 #3
0
 def getBiggestMovieId(self):
     '''
     Function returns the maximum movie id in a list
     :param movieList: the given list
     :return: the maximum id
     '''
     return MovieRepository.getBiggestMovieId(self)
コード例 #4
0
    def storeToFile(self):
        file = open(self.__fileName, "w")
        movieList = MovieRepository.getAllMovies(self)
        for movie in movieList:
            stringToStore = str(movie.getMovieId()) + ";" + movie.getMovieTitle() + ";" + \
            movie.getMovieDescription() + ";" + movie.getMovieGenre()

            stringToStore = stringToStore + "\n"
            file.write(stringToStore)

        file.close()
コード例 #5
0
 def moviesDescendingByRentingDays(self, rentalList):
     return MovieRepository.moviesDescendingByRentingDays(self, rentalList)
コード例 #6
0
 def __init__(self, fileName="movies.txt"):
     MovieRepository.__init__(self)
     self.__fileName = fileName
     self.__loadFromFile()
コード例 #7
0
 def searchMovies(self, searchString, criteria):
     return MovieRepository.searchMovies(self, searchString, criteria)
コード例 #8
0
 def getAllMovies(self):
     return MovieRepository.getAllMovies(self)
コード例 #9
0
 def modifyGenre(self, movieId, newGenre):
     MovieRepository.modifyGenre(self, movieId, newGenre)
     self.storeToFile()
コード例 #10
0
 def addStartingMovies(self):
     MovieRepository.addStartingMovies(self)
     self.storeToFile()
コード例 #11
0
 def modifyTitle(self, movieId, newTitle):
     MovieRepository.modifyTitle(self, movieId, newTitle)
     self.storeToFile()
コード例 #12
0
 def remove(self, movieId):
     MovieRepository.remove(self, movieId)
     self.storeToFile()
コード例 #13
0
 def size(self):
     return MovieRepository.size(self)
コード例 #14
0
 def findMovieById(self, movieId):
     return MovieRepository.findMovieById(self, movieId)
コード例 #15
0
 def exists(self, movieId):
     return MovieRepository.exists(self, movieId)
コード例 #16
0
 def modifyDescription(self, movieId, newDescription):
     MovieRepository.modifyDescription(self, movieId, newDescription)
     self.storeToFile()
コード例 #17
0
 def add(self, movie):
     MovieRepository.add(self, movie)
     self.storeToFile()