本文整理汇总了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'))
示例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'))
示例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")
示例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'))
示例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/æøå")
示例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'))
示例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")
示例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/æøå')
示例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')
示例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())
示例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)
示例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())
示例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())
示例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))
示例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