本文整理汇总了Python中mopidy.utils.path.split_path函数的典型用法代码示例。如果您正苦于以下问题:Python split_path函数的具体用法?Python split_path怎么用?Python split_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split_path函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: tracks_to_directory_tree
def tracks_to_directory_tree(tracks):
directories = ({}, [])
for track in tracks:
path = u''
current = directories
local_folder = settings.LOCAL_MUSIC_PATH
track_path = uri_to_path(track.uri)
track_path = re.sub('^' + re.escape(local_folder), '', track_path)
track_dir = os.path.dirname(track_path)
for part in split_path(track_dir):
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
示例3: tracks_to_directory_tree
def tracks_to_directory_tree(tracks, media_dir):
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(media_dir), 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
示例4: test_initial_slash_is_ignored
def test_initial_slash_is_ignored(self):
self.assertEqual(["foo", "bar", "baz"], path.split_path("/foo/bar/baz"))
示例5: test_dirs
def test_dirs(self):
self.assertEqual(["foo", "bar", "baz"], path.split_path("foo/bar/baz"))
示例6: test_single_dir
def test_single_dir(self):
self.assertEqual(["foo"], path.split_path("foo"))
示例7: test_empty_path
def test_empty_path(self):
self.assertEqual([], path.split_path(""))
示例8: test_initial_slash_is_ignored
def test_initial_slash_is_ignored(self):
self.assertEqual(
['foo', 'bar', 'baz'], path.split_path('/foo/bar/baz'))
示例9: test_single_folder
def test_single_folder(self):
self.assertEqual(['foo'], split_path('foo'))
示例10: test_folders
def test_folders(self):
self.assertEqual(["foo", "bar", "baz"], split_path("foo/bar/baz"))
示例11: test_only_slash
def test_only_slash(self):
self.assertEqual([], split_path('/'))
示例12: test_only_slash
def test_only_slash(self):
self.assertEqual([], path.split_path("/"))
示例13: test_empty_path
def test_empty_path(self):
self.assertEqual([], split_path(''))