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


Python Ref.directory方法代码示例

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


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

示例1: __init__

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:37,代码来源:library.py

示例2: country_to_ref

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
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,代码行数:9,代码来源:translator.py

示例3: setUp

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:29,代码来源:test_library.py

示例4: __init__

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:30,代码来源:library.py

示例5: setUp

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:32,代码来源:test_library.py

示例6: test_browse_root

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
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,代码行数:9,代码来源:test_browse.py

示例7: test_browse_root

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
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,代码行数:9,代码来源:test_browse.py

示例8: setUp

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:28,代码来源:test_library.py

示例9: _browse_directory

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:36,代码来源:library.py

示例10: test_lsinfo_duplicate

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:10,代码来源:test_music_db.py

示例11: test_browse_subgenre

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
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,代码行数:10,代码来源:test_browse.py

示例12: test_lsinfo_duplicate

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    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,代码行数:10,代码来源:test_music_db.py

示例13: test_browse_root_returns_dir_ref_for_each_lib_with_root_dir_name

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    def test_browse_root_returns_dir_ref_for_each_lib_with_root_dir_name(self):
        result = self.core.library.browse(None)

        self.assertEqual(result, [
            Ref.directory(uri='dummy1:directory', name='dummy1'),
            Ref.directory(uri='dummy2:directory', name='dummy2'),
        ])
        self.assertFalse(self.library1.browse.called)
        self.assertFalse(self.library2.browse.called)
        self.assertFalse(self.backend3.library.browse.called)
开发者ID:EricJahn,项目名称:mopidy,代码行数:12,代码来源:test_library.py

示例14: test_browse_dir_returns_subdirs_and_tracks

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
    def test_browse_dir_returns_subdirs_and_tracks(self):
        self.library1.browse.return_value.get.return_value = [
            Ref.directory(uri='dummy1:directory:/foo/bar', name='Bar'),
            Ref.track(uri='dummy1:track:/foo/baz.mp3', name='Baz'),
        ]

        result = self.core.library.browse('dummy1:directory:/foo')
        self.assertEqual(result, [
            Ref.directory(uri='dummy1:directory:/foo/bar', name='Bar'),
            Ref.track(uri='dummy1:track:/foo/baz.mp3', name='Baz'),
        ])
开发者ID:HaBaLeS,项目名称:mopidy,代码行数:13,代码来源:test_library.py

示例15: _track_to_refs

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import directory [as 别名]
def _track_to_refs(track):
    track_path = translator.local_track_uri_to_path(track.uri, b'/')
    track_path = track_path.decode(sys.getfilesystemencoding(), 'replace')
    parts = re.findall(r'([^/]+)', track_path)

    track_ref = Ref.track(uri=track.uri, name=parts.pop())
    refs = [Ref.directory(uri='local:directory')]

    for i in range(len(parts)):
        directory = '/'.join(parts[:i+1])
        uri = translator.path_to_local_directory_uri(directory)
        refs.append(Ref.directory(uri=unicode(uri), name=parts[i]))

    return refs + [track_ref]
开发者ID:radiosilence,项目名称:mopidy-local-whoosh,代码行数:16,代码来源:library.py


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