def recreate(self, playlist: Playlist, songs: Iterable[AudioFile]): """Keep a playlist but entirely replace its contents This is useful for applying new external sorting etc""" playlist._list.clear() playlist._list.extend(songs) playlist.finalize() playlist.write() self.changed([playlist])
def test_read(self): pl = Playlist(self.temp, "playlist") pl.extend(NUMERIC_SONGS) pl.write() lib = FileLibrary("foobar") lib.add(NUMERIC_SONGS) pl = Playlist(self.temp, "playlist", lib) self.assertEqual(len(pl), len(NUMERIC_SONGS))
def test_write(self): pl = Playlist(self.temp, "playlist") pl.extend(NUMERIC_SONGS) pl.extend([fsnative(u"xf0xf0")]) pl.write() with open(pl.filename, "rb") as h: self.assertEqual(len(h.read().splitlines()), len(NUMERIC_SONGS) + 1)