def add_song(self, artist, song_name): song = Song(artist, song_name) llist = self.get_all(lambda x, y: x<y) if llist is None: llist = OrderedList() if llist.find(song) == True: raise ValueError("Song is already in list!") llist.insert(song) self._repo.save_all(llist) return song
def add_song(self, artist, song_name): song = Song(artist, song_name) llist = self.get_all(lambda x, y: x < y) if llist is None: llist = OrderedList() if llist.find(song) == True: raise ValueError("Song is already in list!") llist.insert(song) self._repo.save_all(llist) return song
def get_all(self, rel): f = open(self._fn, 'r', encoding='utf-8') llist = OrderedList(rel) for s in f: name, rating, number_of_ratings = s.split("//") rating = float(rating) number_of_ratings = int(number_of_ratings) artist, song_name = name.split(";;") artist.strip() song_name.strip() llist.insert(Song(artist, song_name, rating, number_of_ratings)) f.close() return llist
def get_all(self, rel): f = open(self._fn, 'r', encoding = 'utf-8') llist = OrderedList(rel) for s in f: name, rating, number_of_ratings = s.split("//") rating = float(rating) number_of_ratings = int(number_of_ratings) artist, song_name = name.split(";;") artist.strip() song_name.strip() llist.insert(Song(artist, song_name, rating, number_of_ratings)) f.close() return llist