• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Ref类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mopidy.models.Ref的典型用法代码示例。如果您正苦于以下问题:Python Ref类的具体用法?Python Ref怎么用?Python Ref使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Ref类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_as_list_with_folders_and_ignored_unloaded_playlist

def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
    result = provider.as_list()

    assert len(result) == 2

    assert result[0] == Ref.playlist(uri="spotify:user:alice:playlist:foo", name="Foo")
    assert result[1] == Ref.playlist(uri="spotify:playlist:bob:baz", name="Bar/Baz (by bob)")
开发者ID:kidaa30,项目名称:mopidy-spotify,代码行数:7,代码来源:test_playlists.py


示例2: country_to_ref

def country_to_ref(country_code):
    uri = unparse_uri('country', country_code.lower())
    try:
        country = pycountry.countries.get(alpha2=country_code.upper())
        return Ref.directory(uri=uri, name=country.name)
    except KeyError:
        return Ref.directory(uri=uri, name=country_code.upper())
开发者ID:kingosticks,项目名称:mopidy-dirble,代码行数:7,代码来源:translator.py


示例3: ref

def ref(obj, uri=uri):
    identifier = obj['identifier']
    mediatype = obj['mediatype']
    if mediatype == 'collection':
        return Ref.directory(name=name(obj), uri=uri(identifier))
    else:
        return Ref.album(name=name(obj), uri=uri(identifier))
开发者ID:tkem,项目名称:mopidy-internetarchive,代码行数:7,代码来源:translator.py


示例4: setUp

    def setUp(self):
        dummy1_root = Ref.directory(uri='dummy1:directory', name='dummy1')
        self.backend1 = mock.Mock()
        self.backend1.uri_schemes.get.return_value = ['dummy1']
        self.backend1.actor_ref.actor_class.__name__ = 'dummy1'
        self.library1 = mock.Mock(spec=backend.LibraryProvider)
        self.library1.root_directory.get.return_value = dummy1_root
        self.backend1.library = self.library1

        dummy2_root = Ref.directory(uri='dummy2:directory', name='dummy2')
        self.backend2 = mock.Mock()
        self.backend2.uri_schemes.get.return_value = ['dummy2']
        self.backend2.actor_ref.actor_class.__name__ = 'dummy2'
        self.library2 = mock.Mock(spec=backend.LibraryProvider)
        self.library2.root_directory.get.return_value = dummy2_root
        self.backend2.library = self.library2

        # A backend without the optional library provider
        self.backend3 = mock.Mock()
        self.backend3.uri_schemes.get.return_value = ['dummy3']
        self.backend3.actor_ref.actor_class.__name__ = 'dummy3'
        self.backend3.has_library().get.return_value = False
        self.backend3.has_library_browse().get.return_value = False

        self.core = core.Core(audio=None, backends=[
            self.backend1, self.backend2, self.backend3])
开发者ID:NilsNoreyson,项目名称:mopidy,代码行数:26,代码来源:test_library.py


示例5: __init__

    def __init__(self, *args, **kwargs):
        super(GMusicLibraryProvider, self).__init__(*args, **kwargs)
        self.tracks = {}
        self.albums = {}
        self.artists = {}
        self.aa_artists = {}
        self.aa_tracks = LruCache()
        self.aa_albums = LruCache()
        self.all_access = False
        self._radio_stations_in_browse = (
            self.backend.config['gmusic']['radio_stations_in_browse'])
        self._radio_stations_count = (
            self.backend.config['gmusic']['radio_stations_count'])
        self._radio_tracks_count = (
            self.backend.config['gmusic']['radio_tracks_count'])
        self._root = []
        self._root.append(Ref.directory(uri='gmusic:album', name='Albums'))
        self._root.append(Ref.directory(uri='gmusic:artist', name='Artists'))
        # browsing all tracks results in connection timeouts
        # self._root.append(Ref.directory(uri='gmusic:track', name='Tracks'))

        if self._radio_stations_in_browse:
            self._root.append(Ref.directory(uri='gmusic:radio',
                                            name='Radios'))
        # show root only if there is something to browse
        if len(self._root) > 0:
            GMusicLibraryProvider.root_directory = Ref.directory(
                uri='gmusic:directory', name='Google Music')
开发者ID:0nse,项目名称:mopidy-gmusic,代码行数:28,代码来源:library.py


示例6: setUp

    def setUp(self):  # noqa: N802
        dummy1_root = Ref.directory(uri='dummy1:directory', name='dummy1')
        self.backend1 = mock.Mock()
        self.backend1.uri_schemes.get.return_value = ['dummy1']
        self.backend1.actor_ref.actor_class.__name__ = 'DummyBackend1'
        self.library1 = mock.Mock(spec=backend.LibraryProvider)
        self.library1.get_images.return_value.get.return_value = {}
        self.library1.root_directory.get.return_value = dummy1_root
        self.backend1.library = self.library1
        self.backend1.has_playlists.return_value.get.return_value = False

        dummy2_root = Ref.directory(uri='dummy2:directory', name='dummy2')
        self.backend2 = mock.Mock()
        self.backend2.uri_schemes.get.return_value = ['dummy2', 'du2']
        self.backend2.actor_ref.actor_class.__name__ = 'DummyBackend2'
        self.library2 = mock.Mock(spec=backend.LibraryProvider)
        self.library2.get_images.return_value.get.return_value = {}
        self.library2.root_directory.get.return_value = dummy2_root
        self.backend2.library = self.library2
        self.backend2.has_playlists.return_value.get.return_value = False

        # A backend without the optional library provider
        self.backend3 = mock.Mock()
        self.backend3.uri_schemes.get.return_value = ['dummy3']
        self.backend3.actor_ref.actor_class.__name__ = 'DummyBackend3'
        self.backend3.has_library.return_value.get.return_value = False
        self.backend3.has_library_browse.return_value.get.return_value = False

        self.core = core.Core(mixer=None, backends=[
            self.backend1, self.backend2, self.backend3])
开发者ID:HaBaLeS,项目名称:mopidy,代码行数:30,代码来源:test_library.py


示例7: spotify_browse_process_results

def spotify_browse_process_results(results):
    logger.debug('Processing spotify browse result')
    if 'categories' in results:
        result_list = results['categories']
        browse_uri = 'spotifyweb:browse:categories:'
        arr = [Ref.directory(uri=browse_uri + cat['id'],
                             name=cat['name'])
               for cat in result_list['items']]
    elif 'playlists' in results:
        result_list = results['playlists']
        arr = [Ref.playlist(uri=playlist['uri'],
                            name=playlist['name'])
               for playlist in result_list['items']]
    elif 'albums' in results:
        result_list = results['albums']
        arr = [Ref.album(uri=album['uri'],
                         name=album['name'])
               for album in result_list['items']]
    else:
        result_list = None
        arr = []

    cont = result_list is not None and result_list['next'] is not None
    logger.debug('Spotify browse result cont: %s' % cont)
    return arr, cont
开发者ID:lfcabend,项目名称:mopidy-spotify-web,代码行数:25,代码来源:library.py


示例8: test_browse_root

def test_browse_root(backend, servers):
    with mock.patch.object(backend, 'client') as m:
        m.servers.return_value = Future.fromvalue(servers)
        assert backend.library.browse(backend.library.root_directory.uri) == [
            Ref.directory(name='Media Server #1', uri='dleyna://media1'),
            Ref.directory(name='Media Server #2', uri='dleyna://media2'),
        ]
开发者ID:anthonydahanne,项目名称:mopidy-dleyna,代码行数:7,代码来源:test_browse.py


示例9: test_browse_root

def test_browse_root(config, library, genres):
    responses.add(responses.GET, re.compile(r'.*/genres\b.*'), json=genres)
    assert library.browse('podcast+itunes:') == [
        Ref.directory(name='Top Podcasts', uri='podcast+itunes:charts:26'),
        Ref.directory(name='Bar', uri='podcast+itunes:genre:1001'),
        Ref.directory(name='Foo', uri='podcast+itunes:charts:1000')
    ]
开发者ID:eliassoares,项目名称:mopidy-podcast-itunes,代码行数:7,代码来源:test_browse.py


示例10: _browse_directory

    def _browse_directory(self, uri, order=('type', 'name')):
        query = dict(uritools.urisplit(uri).getquerylist())
        type = query.pop('type', None)
        role = query.pop('role', None)

        # TODO: handle these in schema (generically)?
        if type == 'date':
            format = query.get('format', '%Y-%m-%d')
            return map(_dateref, schema.dates(self._connect(), format=format))
        if type == 'genre':
            return map(_genreref, schema.list_distinct(self._connect(), 'genre'))  # noqa

        # Fix #38: keep sort order of album tracks; this also applies
        # to composers and performers
        if type == Ref.TRACK and 'album' in query:
            order = ('disc_no', 'track_no', 'name')

        roles = role or ('artist', 'albumartist')  # FIXME: re-think 'roles'...

        refs = []
        for ref in schema.browse(self._connect(), type, order, role=roles, **query):  # noqa
            if ref.type == Ref.TRACK or (not query and not role):
                refs.append(ref)
            elif ref.type == Ref.ALBUM:
                refs.append(Ref.directory(uri=uritools.uricompose(
                    'local', None, 'directory', dict(query, type=Ref.TRACK, album=ref.uri)  # noqa
                ), name=ref.name))
            elif ref.type == Ref.ARTIST:
                refs.append(Ref.directory(uri=uritools.uricompose(
                    'local', None, 'directory', dict(query, **{role: ref.uri})
                ), name=ref.name))
            else:
                logger.warn('Unexpected SQLite browse result: %r', ref)
        return refs
开发者ID:siam28,项目名称:mopidy-local-sqlite,代码行数:34,代码来源:library.py


示例11: __init__

    def __init__(self, *args, **kwargs):
        super(GMusicLibraryProvider, self).__init__(*args, **kwargs)

        # tracks, albums, and artists here refer to what is explicitly
        # in our library.
        self.tracks = {}
        self.albums = {}
        self.artists = {}

        # aa_* caches are *only* used for temporary objects. Library
        # objects will never make it here.
        self.aa_artists = LRUCache(1024)
        self.aa_tracks = LRUCache(1024)
        self.aa_albums = LRUCache(1024)

        self._radio_stations_in_browse = (
            self.backend.config['gmusic']['radio_stations_in_browse'])
        self._radio_stations_count = (
            self.backend.config['gmusic']['radio_stations_count'])
        self._radio_tracks_count = (
            self.backend.config['gmusic']['radio_tracks_count'])

        self._top_tracks_count = (
            self.backend.config['gmusic']['top_tracks_count'])

        # Setup the root of library browsing.
        self._root = [
            Ref.directory(uri='gmusic:album', name='Albums'),
            Ref.directory(uri='gmusic:artist', name='Artists'),
            Ref.directory(uri='gmusic:track', name='Tracks')
        ]

        if self._radio_stations_in_browse:
            self._root.append(Ref.directory(uri='gmusic:radio',
                                            name='Radios'))
开发者ID:mopidy,项目名称:mopidy-gmusic,代码行数:35,代码来源:library.py


示例12: setUp

    def setUp(self):  # noqa: N802
        dummy1_root = Ref.directory(uri='dummy1:directory', name='dummy1')
        self.backend1 = mock.Mock()
        self.backend1.uri_schemes.get.return_value = ['dummy1']
        self.library1 = mock.Mock(spec=backend.LibraryProvider)
        self.library1.get_images().get.return_value = {}
        self.library1.get_images.reset_mock()
        self.library1.root_directory.get.return_value = dummy1_root
        self.backend1.library = self.library1

        dummy2_root = Ref.directory(uri='dummy2:directory', name='dummy2')
        self.backend2 = mock.Mock()
        self.backend2.uri_schemes.get.return_value = ['dummy2', 'du2']
        self.library2 = mock.Mock(spec=backend.LibraryProvider)
        self.library2.get_images().get.return_value = {}
        self.library2.get_images.reset_mock()
        self.library2.root_directory.get.return_value = dummy2_root
        self.backend2.library = self.library2

        # A backend without the optional library provider
        self.backend3 = mock.Mock()
        self.backend3.uri_schemes.get.return_value = ['dummy3']
        self.backend3.has_library().get.return_value = False
        self.backend3.has_library_browse().get.return_value = False

        self.core = core.Core(mixer=None, backends=[
            self.backend1, self.backend2, self.backend3])
开发者ID:EricJahn,项目名称:mopidy,代码行数:27,代码来源:test_library.py


示例13: test_as_list

    def test_as_list(self):
        result = self.provider.as_list()

        self.assertEqual(len(result), 2)
        self.assertEqual(
            result[0], Ref.playlist(uri='gmusic:playlist:boo', name='boo'))
        self.assertEqual(
            result[1], Ref.playlist(uri='gmusic:playlist:foo', name='foo'))
开发者ID:mopidy,项目名称:mopidy-gmusic,代码行数:8,代码来源:test_playlist.py


示例14: test_lsinfo_duplicate

    def test_lsinfo_duplicate(self):
        self.backend.library.dummy_browse_result = {
            "dummy:/": [Ref.directory(uri="dummy:/a1", name="a"), Ref.directory(uri="dummy:/a2", name="a")]
        }

        self.sendRequest('lsinfo "/dummy"')
        self.assertInResponse("directory: dummy/a")
        self.assertInResponse("directory: dummy/a [2]")
开发者ID:valentinb,项目名称:mopidy,代码行数:8,代码来源:test_music_db.py


示例15: test_lsinfo_for_root_includes_dirs_for_each_lib_with_content

    def test_lsinfo_for_root_includes_dirs_for_each_lib_with_content(self):
        self.backend.library.dummy_browse_result = {
            "dummy:/": [Ref.track(uri="dummy:/a", name="a"), Ref.directory(uri="dummy:/foo", name="foo")]
        }

        self.sendRequest('lsinfo "/"')
        self.assertInResponse("directory: dummy")
        self.assertInResponse("OK")
开发者ID:valentinb,项目名称:mopidy,代码行数:8,代码来源:test_music_db.py


示例16: test_browse_subgenre

def test_browse_subgenre(config, library, genres, charts, lookup):
    responses.add(responses.GET, re.compile(r'.*/genres\b.*'), json=genres)
    responses.add(responses.GET, re.compile(r'.*/charts\b.*'), json=charts)
    responses.add(responses.GET, re.compile(r'.*/lookup\b.*'), json=lookup)
    assert library.browse('podcast+itunes:genre:1001') == [
        Ref.directory(name='Top Bar', uri='podcast+itunes:charts:1001'),
        Ref.directory(name='Baz', uri='podcast+itunes:charts:1002')
    ]
开发者ID:eliassoares,项目名称:mopidy-podcast-itunes,代码行数:8,代码来源:test_browse.py


示例17: test_browse_charts

def test_browse_charts(config, library, genres, charts, lookup):
    responses.add(responses.GET, re.compile(r'.*/genres\b.*'), json=genres)
    responses.add(responses.GET, re.compile(r'.*/charts\b.*'), json=charts)
    responses.add(responses.GET, re.compile(r'.*/lookup\b.*'), json=lookup)
    assert library.browse('podcast+itunes:charts:1000') == [
        Ref.album(name='foo', uri='podcast+http://example.com/1234'),
        Ref.album(name='bar', uri='podcast+http://example.com/5678')
    ]
开发者ID:eliassoares,项目名称:mopidy-podcast-itunes,代码行数:8,代码来源:test_browse.py


示例18: test_lsinfo_for_dir_with_and_without_leading_slash_is_the_same

    def test_lsinfo_for_dir_with_and_without_leading_slash_is_the_same(self):
        self.backend.library.dummy_browse_result = {
            "dummy:/": [Ref.track(uri="dummy:/a", name="a"), Ref.directory(uri="dummy:/foo", name="foo")]
        }

        response1 = self.sendRequest('lsinfo "dummy"')
        response2 = self.sendRequest('lsinfo "/dummy"')
        self.assertEqual(response1, response2)
开发者ID:valentinb,项目名称:mopidy,代码行数:8,代码来源:test_music_db.py


示例19: _ref

def _ref(metadata):
    identifier = metadata['identifier']
    uri = uritools.uricompose(SCHEME, path=identifier)
    name = metadata.get('title', identifier)
    if metadata.get('mediatype', 'collection') == 'collection':
        return Ref.directory(uri=uri, name=name)
    else:
        return Ref.album(uri=uri, name=name)
开发者ID:Neoheurist,项目名称:mopidy-internetarchive,代码行数:8,代码来源:library.py


示例20: test_lsinfo_duplicate

    def test_lsinfo_duplicate(self):
        self.backend.library.dummy_browse_result = {
            'dummy:/': [Ref.directory(uri='dummy:/a1', name='a'),
                        Ref.directory(uri='dummy:/a2', name='a')]}

        self.sendRequest('lsinfo "/dummy"')
        self.assertInResponse('directory: dummy/a')
        self.assertInResponse('directory: dummy/a [2]')
开发者ID:AndroidMarv,项目名称:mopidy,代码行数:8,代码来源:test_music_db.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Track类代码示例发布时间:2022-05-27
下一篇:
Python models.Playlist类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap