本文整理汇总了Python中mopidy.models.Playlist.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.copy方法的具体用法?Python Playlist.copy怎么用?Python Playlist.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mopidy.models.Playlist
的用法示例。
在下文中一共展示了Playlist.copy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_new_name
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
def test_with_new_name(self):
tracks = [Track()]
last_modified = datetime.datetime.utcnow()
playlist = Playlist(uri="an uri", name="a name", tracks=tracks, last_modified=last_modified)
new_playlist = playlist.copy(name="another name")
self.assertEqual(new_playlist.uri, "an uri")
self.assertEqual(new_playlist.name, "another name")
self.assertEqual(list(new_playlist.tracks), tracks)
self.assertEqual(new_playlist.last_modified, last_modified)
示例2: test_with_new_uri
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
def test_with_new_uri(self):
tracks = [Track()]
last_modified = dt.datetime.now()
playlist = Playlist(uri=u"an uri", name=u"a name", tracks=tracks, last_modified=last_modified)
new_playlist = playlist.copy(uri=u"another uri")
self.assertEqual(new_playlist.uri, u"another uri")
self.assertEqual(new_playlist.name, u"a name")
self.assertEqual(list(new_playlist.tracks), tracks)
self.assertEqual(new_playlist.last_modified, last_modified)
示例3: test_with_new_last_modified
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
def test_with_new_last_modified(self):
tracks = [Track()]
last_modified = datetime.datetime.utcnow()
new_last_modified = last_modified + datetime.timedelta(1)
playlist = Playlist(uri="an uri", name="a name", tracks=tracks, last_modified=last_modified)
new_playlist = playlist.copy(last_modified=new_last_modified)
self.assertEqual(new_playlist.uri, "an uri")
self.assertEqual(new_playlist.name, "a name")
self.assertEqual(list(new_playlist.tracks), tracks)
self.assertEqual(new_playlist.last_modified, new_last_modified)
示例4: test_with_new_uri
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
def test_with_new_uri(self):
tracks = [Track()]
last_modified = datetime.datetime.utcnow()
playlist = Playlist(
uri='an uri', name='a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.copy(uri='another uri')
self.assertEqual(new_playlist.uri, 'another uri')
self.assertEqual(new_playlist.name, 'a name')
self.assertEqual(list(new_playlist.tracks), tracks)
self.assertEqual(new_playlist.last_modified, last_modified)
示例5: test_with_new_name
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
def test_with_new_name(self):
tracks = [Track()]
last_modified = 1390942873000
playlist = Playlist(
uri='an uri', name='a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.copy(name='another name')
self.assertEqual(new_playlist.uri, 'an uri')
self.assertEqual(new_playlist.name, 'another name')
self.assertEqual(list(new_playlist.tracks), tracks)
self.assertEqual(new_playlist.last_modified, last_modified)
示例6: InternetArchivePlaylistsProvider
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
class InternetArchivePlaylistsProvider(backend.PlaylistsProvider):
def __init__(self, config, backend):
super(InternetArchivePlaylistsProvider, self).__init__(backend)
self._bookmarks = []
self._username = config[Extension.ext_name]['username']
self._playlist = Playlist(
uri='%s://%s/bookmarks' % (Extension.ext_name, self._username),
name='Internet Archive Bookmarks'
)
self.playlists = [self._playlist]
def create(self, name):
pass # TODO
def delete(self, uri):
pass # TODO
def lookup(self, uri):
for playlist in self.playlists:
if playlist.uri == uri:
return playlist
return None
def refresh(self):
try:
bookmarks = self.backend.client.bookmarks(self._username)
logger.info('Loaded %d Internet Archive bookmarks', len(bookmarks))
if bookmarks == self._bookmarks:
return # unchanged
# FIXME: this can probably be removed when playlists return refs...
tracks = self._tracks(bookmarks)
logger.info('Loaded %d Internet Archive tracks', len(tracks))
self.playlists = [self._playlist.copy(tracks=tracks)]
backend.BackendListener.send('playlists_loaded')
self._bookmarks = bookmarks
except Exception as e:
logger.error('Error loading Internet Archive bookmarks: %s', e)
def save(self, playlist):
pass # TODO
def _tracks(self, bookmarks):
tracks = []
for doc in bookmarks:
tracks.extend(self.backend.library._lookup(doc['identifier']))
return tracks
示例7: test_copying_playlist
# 需要导入模块: from mopidy.models import Playlist [as 别名]
# 或者: from mopidy.models.Playlist import copy [as 别名]
def test_copying_playlist(self):
playlist = Playlist()
self.compare(playlist, playlist.copy())