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


Python path.uri_to_path函数代码示例

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


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

示例1: test_space_in_uri

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

示例2: test_simple_uri

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

示例3: test_space_in_uri

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

示例4: test_unicode_in_uri

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

示例5: test_unicode_in_uri

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

示例6: test_latin1_in_uri

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

示例7: test_simple_uri

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

示例8: test_unicode_in_uri

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

示例9: _save_m3u

 def _save_m3u(self, playlist):
     file_path = path.uri_to_path(playlist.uri)
     path.check_file_path_is_inside_base_dir(file_path, self._path)
     with open(file_path, 'w') as file_handle:
         for track in playlist.tracks:
             if track.uri.startswith('file://'):
                 uri = path.uri_to_path(track.uri)
             else:
                 uri = track.uri
             file_handle.write(uri + '\n')
开发者ID:0xadam,项目名称:mopidy,代码行数:10,代码来源:playlists.py

示例10: translate

 def translate(self, track):
     base_path = self.media_dir.encode('utf-8')
     result = dict(translator.track_to_mpd_format(track))
     result['file'] = uri_to_path(result['file'])[len(base_path) + 1:]
     result['key'] = os.path.basename(result['file'])
     result['mtime'] = mtime('')
     return translator.order_mpd_track_info(result.items())
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:translator_test.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: translate

 def translate(self, track):
     base_path = self.media_dir.encode("utf-8")
     result = dict(translator.track_to_mpd_format(track))
     result["file"] = uri_to_path(result["file"])[len(base_path) + 1 :]
     result["key"] = os.path.basename(result["file"])
     result["mtime"] = mtime("")
     return translator.order_mpd_track_info(result.items())
开发者ID:vorodev,项目名称:mopidy,代码行数:7,代码来源:translator_test.py

示例13: translate

 def translate(self, track):
     folder = settings.LOCAL_MUSIC_PATH
     result = dict(translator.track_to_mpd_format(track))
     result['file'] = uri_to_path(result['file'])
     result['file'] = result['file'][len(folder)+1:]
     result['key'] = os.path.basename(result['file'])
     result['mtime'] = mtime('')
     return translator.order_mpd_track_info(result.items())
开发者ID:MechanisM,项目名称:mopidy,代码行数:8,代码来源:serializer_test.py

示例14: _rename_m3u

    def _rename_m3u(self, playlist):
        src_file_path = path.uri_to_path(playlist.uri)
        path.check_file_path_is_inside_base_dir(src_file_path, self._path)

        dst_file_path = self._get_m3u_path(playlist.name)
        path.check_file_path_is_inside_base_dir(dst_file_path, self._path)

        shutil.move(src_file_path, dst_file_path)

        return playlist.copy(uri=path.path_to_uri(dst_file_path))
开发者ID:0xadam,项目名称:mopidy,代码行数:10,代码来源:playlists.py

示例15: tracks_to_directory_tree

def tracks_to_directory_tree(tracks):
    directories = ({}, [])

    for track in tracks:
        path = b""
        current = directories

        absolute_track_dir_path = os.path.dirname(uri_to_path(track.uri))
        relative_track_dir_path = re.sub("^" + re.escape(settings.LOCAL_MUSIC_PATH), b"", absolute_track_dir_path)

        for part in split_path(relative_track_dir_path):
            path = os.path.join(path, part)
            if path not in current[0]:
                current[0][path] = ({}, [])
            current = current[0][path]
        current[1].append(track)
    return directories
开发者ID:jeremybmerrill,项目名称:mopidy,代码行数:17,代码来源:translator.py


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