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

Python path.path_to_uri函数代码示例

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

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



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

示例1: test_dir_and_path

 def test_dir_and_path(self):
     if sys.platform == 'win32':
         result = path.path_to_uri('C:/WINDOWS/', 'clock.avi')
         self.assertEqual(result, 'file:///C://WINDOWS/clock.avi')
     else:
         result = path.path_to_uri('/etc', 'fstab')
         self.assertEqual(result, 'file:///etc/fstab')
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例2: test_utf8_in_path

 def test_utf8_in_path(self):
     if sys.platform == 'win32':
         result = path.path_to_uri('C:/æøå'.encode('utf-8'))
         self.assertEqual(result, 'file:///C://%C3%A6%C3%B8%C3%A5')
     else:
         result = path.path_to_uri('/tmp/æøå'.encode('utf-8'))
         self.assertEqual(result, 'file:///tmp/%C3%A6%C3%B8%C3%A5')
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例3: test_space_in_path

 def test_space_in_path(self):
     if sys.platform == 'win32':
         result = path.path_to_uri('C:/test this')
         self.assertEqual(result, 'file:///C://test%20this')
     else:
         result = path.path_to_uri('/tmp/test this')
         self.assertEqual(result, 'file:///tmp/test%20this')
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例4: test_unicode_in_path

 def test_unicode_in_path(self):
     if sys.platform == "win32":
         result = path_to_uri(u"C:/æøå")
         self.assertEqual(result, "file:///C://%C3%A6%C3%B8%C3%A5")
     else:
         result = path_to_uri(u"/tmp/æøå")
         self.assertEqual(result, u"file:///tmp/%C3%A6%C3%B8%C3%A5")
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例5: test_unicode_in_path

 def test_unicode_in_path(self):
     if sys.platform == 'win32':
         result = path.path_to_uri(u'C:/æøå')
         self.assertEqual(result, 'file:///C://%C3%A6%C3%B8%C3%A5')
     else:
         result = path.path_to_uri(u'/tmp/æøå')
         self.assertEqual(result, u'file:///tmp/%C3%A6%C3%B8%C3%A5')
开发者ID:Dvad,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例6: test_folder_and_path

 def test_folder_and_path(self):
     if sys.platform == "win32":
         result = path_to_uri(u"C:/WINDOWS/", u"clock.avi")
         self.assertEqual(result, "file:///C://WINDOWS/clock.avi")
     else:
         result = path_to_uri(u"/etc", u"fstab")
         self.assertEqual(result, u"file:///etc/fstab")
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例7: test_space_in_path

 def test_space_in_path(self):
     if sys.platform == "win32":
         result = path_to_uri(u"C:/test this")
         self.assertEqual(result, "file:///C://test%20this")
     else:
         result = path_to_uri(u"/tmp/test this")
         self.assertEqual(result, u"file:///tmp/test%20this")
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例8: test_latin1_in_path

 def test_latin1_in_path(self):
     if sys.platform == 'win32':
         result = path.path_to_uri('C:/æøå'.encode('latin-1'))
         self.assertEqual(result, 'file:///C://%E6%F8%E5')
     else:
         result = path.path_to_uri('/tmp/æøå'.encode('latin-1'))
         self.assertEqual(result, 'file:///tmp/%E6%F8%E5')
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例9: test_simple_path

 def test_simple_path(self):
     if sys.platform == 'win32':
         result = path_to_uri(u'C:/WINDOWS/clock.avi')
         self.assertEqual(result, 'file:///C://WINDOWS/clock.avi')
     else:
         result = path_to_uri(u'/etc/fstab')
         self.assertEqual(result, 'file:///etc/fstab')
开发者ID:arambelo,项目名称:mopidy,代码行数:7,代码来源:path_test.py


示例10: _convert_mpd_data

def _convert_mpd_data(data, tracks, music_dir):
    if not data:
        return

    track_kwargs = {}
    album_kwargs = {}
    artist_kwargs = {}
    albumartist_kwargs = {}

    if "track" in data:
        album_kwargs["num_tracks"] = int(data["track"].split("/")[1])
        track_kwargs["track_no"] = int(data["track"].split("/")[0])

    if "artist" in data:
        artist_kwargs["name"] = data["artist"]
        albumartist_kwargs["name"] = data["artist"]

    if "albumartist" in data:
        albumartist_kwargs["name"] = data["albumartist"]

    if "album" in data:
        album_kwargs["name"] = data["album"]

    if "title" in data:
        track_kwargs["name"] = data["title"]

    if "musicbrainz_trackid" in data:
        track_kwargs["musicbrainz_id"] = data["musicbrainz_trackid"]

    if "musicbrainz_albumid" in data:
        album_kwargs["musicbrainz_id"] = data["musicbrainz_albumid"]

    if "musicbrainz_artistid" in data:
        artist_kwargs["musicbrainz_id"] = data["musicbrainz_artistid"]

    if "musicbrainz_albumartistid" in data:
        albumartist_kwargs["musicbrainz_id"] = data["musicbrainz_albumartistid"]

    if data["file"][0] == "/":
        path = data["file"][1:]
    else:
        path = data["file"]

    if artist_kwargs:
        artist = Artist(**artist_kwargs)
        track_kwargs["artists"] = [artist]

    if albumartist_kwargs:
        albumartist = Artist(**albumartist_kwargs)
        album_kwargs["artists"] = [albumartist]

    if album_kwargs:
        album = Album(**album_kwargs)
        track_kwargs["album"] = album

    track_kwargs["uri"] = path_to_uri(music_dir, path)
    track_kwargs["length"] = int(data.get("time", 0)) * 1000

    track = Track(**track_kwargs)
    tracks.add(track)
开发者ID:bok,项目名称:mopidy,代码行数:60,代码来源:translator.py


示例11: change_track

 def change_track(self, track):
     media_dir = self.backend.config['local']['media_dir']
     # TODO: check that type is correct.
     file_path = path.uri_to_path(track.uri).split(b':', 1)[1]
     file_path = os.path.join(media_dir, file_path)
     track = track.copy(uri=path.path_to_uri(file_path))
     return super(LocalPlaybackProvider, self).change_track(track)
开发者ID:eisnerd,项目名称:mopidy,代码行数:7,代码来源:playback.py


示例12: test_albumartist_tag_cache

 def test_albumartist_tag_cache(self):
     tracks = parse_mpd_tag_cache(path_to_data_dir("albumartist_tag_cache"), path_to_data_dir(""))
     uri = path_to_uri(path_to_data_dir("song1.mp3"))
     artist = Artist(name="albumartistname")
     album = expected_albums[0].copy(artists=[artist])
     track = Track(name="trackname", artists=expected_artists, track_no=1, album=album, length=4000, uri=uri)
     self.assertEqual(track, list(tracks)[0])
开发者ID:ruudud,项目名称:mopidy,代码行数:7,代码来源:translator_test.py


示例13: refresh

    def refresh(self):
        playlists = []

        for m3u in glob.glob(os.path.join(self._playlists_dir, '*.m3u')):
            uri = path.path_to_uri(m3u)
            name = os.path.splitext(os.path.basename(m3u))[0]

            tracks = []
            for track_uri in parse_m3u(m3u, self._media_dir):
                try:
                    # TODO We must use core.library.lookup() to support tracks
                    # from other backends
                    tracks += self.backend.library.lookup(track_uri)
                except LookupError as ex:
                    logger.warning('Playlist item could not be added: %s', ex)

            playlist = Playlist(uri=uri, name=name, tracks=tracks)
            playlists.append(playlist)

        self.playlists = playlists
        listener.BackendListener.send('playlists_loaded')

        logger.info(
            'Loaded %d local playlists from %s',
            len(playlists), self._playlists_dir)
开发者ID:Halfnhav,项目名称:mopidy,代码行数:25,代码来源:playlists.py


示例14: test_simple_cache

 def test_simple_cache(self):
     tracks = parse_mpd_tag_cache(path_to_data_dir('simple_tag_cache'),
         path_to_data_dir(''))
     uri = path_to_uri(path_to_data_dir('song1.mp3'))
     track = Track(name='trackname', artists=expected_artists, track_no=1,
         album=expected_albums[0], length=4000, uri=uri)
     self.assertEqual(set([track]), tracks)
开发者ID:Amli,项目名称:mopidy,代码行数:7,代码来源:translator_test.py


示例15: parse_m3u

def parse_m3u(file_path, media_dir):
    r"""
    Convert M3U file list of uris

    Example M3U data::

        # This is a comment
        Alternative\Band - Song.mp3
        Classical\Other Band - New Song.mp3
        Stuff.mp3
        D:\More Music\Foo.mp3
        http://www.example.com:8000/Listen.pls
        http://www.example.com/~user/Mine.mp3

    - Relative paths of songs should be with respect to location of M3U.
    - Paths are normaly platform specific.
    - Lines starting with # should be ignored.
    - m3u files are latin-1.
    - This function does not bother with Extended M3U directives.
    """
    # TODO: uris as bytes
    uris = []
    try:
        with open(file_path) as m3u:
            contents = m3u.readlines()
    except IOError as error:
        logger.warning('Couldn\'t open m3u: %s', locale_decode(error))
        return uris

    for line in contents:
        line = line.strip().decode('latin1')

        if line.startswith('#'):
            continue

        if urlparse.urlsplit(line).scheme:
            uris.append(line)
        elif os.path.normpath(line) == os.path.abspath(line):
            path = path_to_uri(line)
            uris.append(path)
        else:
            path = path_to_uri(os.path.join(media_dir, line))
            uris.append(path)

    return uris
开发者ID:eisnerd,项目名称:mopidy,代码行数:45,代码来源:translator.py


示例16: test_albumartist_tag_cache

 def test_albumartist_tag_cache(self):
     tracks = parse_mpd_tag_cache(data_folder('albumartist_tag_cache'),
         data_folder(''))
     uri = path_to_uri(data_folder('song1.mp3'))
     artist = Artist(name='albumartistname')
     album = expected_albums[0].copy(artists=[artist])
     track = Track(name='trackname', artists=expected_artists, track_no=1,
         album=album, length=4000, uri=uri)
     self.assertEqual(track, list(tracks)[0])
开发者ID:bok,项目名称:mopidy,代码行数:9,代码来源:translator_test.py


示例17: test_playlists_are_loaded_at_startup

    def test_playlists_are_loaded_at_startup(self):
        playlist_path = os.path.join(self.playlists_dir, 'test.m3u')

        track = Track(uri=path_to_uri(path_to_data_dir('uri2')))
        playlist = self.core.playlists.create('test')
        playlist = playlist.copy(tracks=[track])
        playlist = self.core.playlists.save(playlist)

        backend = self.backend_class(config=self.config, audio=self.audio)

        self.assert_(backend.playlists.playlists)
        self.assertEqual(
            path_to_uri(playlist_path),
            backend.playlists.playlists[0].uri)
        self.assertEqual(
            playlist.name, backend.playlists.playlists[0].name)
        self.assertEqual(
            track.uri, backend.playlists.playlists[0].tracks[0].uri)
开发者ID:Halfnhav,项目名称:mopidy,代码行数:18,代码来源:playlists_test.py


示例18: test_unicode_cache

    def test_unicode_cache(self):
        tracks = parse_mpd_tag_cache(path_to_data_dir("utf8_tag_cache"), path_to_data_dir(""))

        uri = path_to_uri(path_to_data_dir("song1.mp3"))
        artists = [Artist(name=u"æøå")]
        album = Album(name=u"æøå", artists=artists)
        track = Track(uri=uri, name=u"æøå", artists=artists, album=album, length=4000)

        self.assertEqual(track, list(tracks)[0])
开发者ID:ruudud,项目名称:mopidy,代码行数:9,代码来源:translator_test.py


示例19: scan

 def scan(self, paths):
     scanner = scan.Scanner()
     for path in paths:
         uri = path_lib.path_to_uri(path)
         key = uri[len('file://'):]
         try:
             self.data[key] = scanner.scan(uri)
         except exceptions.ScannerError as error:
             self.errors[key] = error
开发者ID:NilsNoreyson,项目名称:mopidy,代码行数:9,代码来源:test_scan.py


示例20: setUp

 def setUp(self):
     config = {
         'audio': {
             'mixer': 'fakemixer track_max_volume=65536',
             'mixer_track': None,
             'output': 'fakesink',
         }
     }
     self.song_uri = path_to_uri(path_to_data_dir('song1.wav'))
     self.audio = audio.Audio.start(config=config).proxy()
开发者ID:Halfnhav,项目名称:mopidy,代码行数:10,代码来源:actor_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python path.split_path函数代码示例发布时间:2022-05-27
下一篇:
Python path.expand_path函数代码示例发布时间: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