本文整理汇总了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
开发者ID:jeremybmerrill,项目名称:mopidy,代码行数:17,代码来源:translator.py
示例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
开发者ID:bok,项目名称:mopidy,代码行数:18,代码来源:translator.py
示例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
开发者ID:abarisain,项目名称:mopidy,代码行数:18,代码来源:translator.py
示例4: test_initial_slash_is_ignored
def test_initial_slash_is_ignored(self):
self.assertEqual(["foo", "bar", "baz"], path.split_path("/foo/bar/baz"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py
示例5: test_dirs
def test_dirs(self):
self.assertEqual(["foo", "bar", "baz"], path.split_path("foo/bar/baz"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py
示例6: test_single_dir
def test_single_dir(self):
self.assertEqual(["foo"], path.split_path("foo"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py
示例7: test_empty_path
def test_empty_path(self):
self.assertEqual([], path.split_path(""))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py
示例8: test_initial_slash_is_ignored
def test_initial_slash_is_ignored(self):
self.assertEqual(
['foo', 'bar', 'baz'], path.split_path('/foo/bar/baz'))
开发者ID:Halfnhav,项目名称:mopidy,代码行数:3,代码来源:path_test.py
示例9: test_single_folder
def test_single_folder(self):
self.assertEqual(['foo'], split_path('foo'))
开发者ID:arambelo,项目名称:mopidy,代码行数:2,代码来源:path_test.py
示例10: test_folders
def test_folders(self):
self.assertEqual(["foo", "bar", "baz"], split_path("foo/bar/baz"))
开发者ID:Amli,项目名称:mopidy,代码行数:2,代码来源:path_test.py
示例11: test_only_slash
def test_only_slash(self):
self.assertEqual([], split_path('/'))
开发者ID:arambelo,项目名称:mopidy,代码行数:2,代码来源:path_test.py
示例12: test_only_slash
def test_only_slash(self):
self.assertEqual([], path.split_path("/"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py
示例13: test_empty_path
def test_empty_path(self):
self.assertEqual([], split_path(''))
开发者ID:arambelo,项目名称:mopidy,代码行数:2,代码来源:path_test.py
注:本文中的mopidy.utils.path.split_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论