当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.copy方法代码示例

本文整理汇总了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)
开发者ID:serman,项目名称:mopidy,代码行数:11,代码来源:models_test.py

示例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)
开发者ID:Amli,项目名称:mopidy,代码行数:11,代码来源:models_test.py

示例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)
开发者ID:serman,项目名称:mopidy,代码行数:12,代码来源:models_test.py

示例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)
开发者ID:eisnerd,项目名称:mopidy,代码行数:13,代码来源:models_test.py

示例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)
开发者ID:FabrizioCongia,项目名称:mopidy,代码行数:13,代码来源:test_models.py

示例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
开发者ID:soujak,项目名称:mopidy-internetarchive,代码行数:49,代码来源:playlists.py

示例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())
开发者ID:serman,项目名称:mopidy,代码行数:5,代码来源:models_test.py


注:本文中的mopidy.models.Playlist.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。