def __init__(self): ''' Instantiate the Repo list ''' self._rentalList = IterableDataStruct() self._rentedMoviesCounter = {} self._rentedClientsCounter = {} self._state = IterableDataStruct()
def load(self, type, path): path = path + ".json" objectsList = IterableDataStruct() try: with open(path) as file: for line in file: jsonObj = json.loads(line.strip("'")) for key in jsonObj: if type == "Client": crtObj = Client(jsonObj[key]["name"]) crtObj.setManuallyClientId(int(key)) if type == "Movie": crtObj = Movie(jsonObj[key]["title"], jsonObj[key]["description"], jsonObj[key]["genre"]) crtObj.setManuallyMovieId(int(key)) if type == "Rental": crtObj = Rental(jsonObj[key]["movieId"], jsonObj[key]["clientId"], jsonObj[key]["rentedDate"], jsonObj[key]["dueDate"], jsonObj[key]["returnedDate"]) crtObj.setManuallyRentalId(int(key)) objectsList.append(crtObj) except IOError as e: print(e) return objectsList
def setUp(self): self._obj = IterableDataStruct() self._obj[0] = 0 self._obj[1] = 1 self._obj[2] = 2 self._obj[3] = 3 self._obj[4] = 4 self._obj[5] = 5
def currentlyRentedUnreturnedMovies(self): ''' :return: a list containing all the movies that are currently rented and unreturned ''' rtrn = [] for crt in self._rentalList: if crt.getReturnedDate() == "": continue if crt.getReturnedDate() > crt.getDueDate(): rtrn.append(crt) #auxObj = sorted(rtrn, key = lambda x: ((x.getReturnedDate() - x.getDueDate()).days), reverse = True) auxObj = IterableDataStruct().sort(rtrn, self.sortF) return auxObj
def __init__(self): ''' Instantiates the MovieRepository with an empty list of movies ''' self._movieList = IterableDataStruct()
def __init__(self): ''' Instantiate the class with an empty lists of clients ''' self._clientList = IterableDataStruct()