コード例 #1
0
ファイル: translator.py プロジェクト: jeremybmerrill/mopidy
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
0
ファイル: translator.py プロジェクト: bok/mopidy
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
0
def tracks_to_directory_tree(tracks):
    directories = ({}, [])
    for track in tracks:
        path = ''
        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
コード例 #4
0
ファイル: translator.py プロジェクト: abarisain/mopidy
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
コード例 #5
0
ファイル: translator.py プロジェクト: eisnerd/mopidy
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
コード例 #6
0
ファイル: path_test.py プロジェクト: Halfnhav/mopidy
 def test_dirs(self):
     self.assertEqual(['foo', 'bar', 'baz'], path.split_path('foo/bar/baz'))
コード例 #7
0
ファイル: path_test.py プロジェクト: Halfnhav/mopidy
 def test_single_dir(self):
     self.assertEqual(['foo'], path.split_path('foo'))
コード例 #8
0
 def test_only_slash(self):
     self.assertEqual([], path.split_path('/'))
コード例 #9
0
ファイル: path_test.py プロジェクト: arambelo/mopidy
 def test_single_folder(self):
     self.assertEqual(['foo'], split_path('foo'))
コード例 #10
0
ファイル: test_path.py プロジェクト: karlpilkington/mopidy
 def test_initial_slash_is_ignored(self):
     self.assertEqual(["foo", "bar", "baz"], path.split_path("/foo/bar/baz"))
コード例 #11
0
ファイル: test_path.py プロジェクト: karlpilkington/mopidy
 def test_single_dir(self):
     self.assertEqual(["foo"], path.split_path("foo"))
コード例 #12
0
ファイル: path_test.py プロジェクト: Halfnhav/mopidy
 def test_initial_slash_is_ignored(self):
     self.assertEqual(
         ['foo', 'bar', 'baz'], path.split_path('/foo/bar/baz'))
コード例 #13
0
ファイル: path_test.py プロジェクト: ruudud/mopidy
 def test_folders(self):
     self.assertEqual(['foo', 'bar', 'baz'], split_path('foo/bar/baz'))
コード例 #14
0
ファイル: path_test.py プロジェクト: ruudud/mopidy
 def test_single_folder(self):
     self.assertEqual(['foo'], split_path('foo'))
コード例 #15
0
ファイル: path_test.py プロジェクト: Amli/mopidy
 def test_folders(self):
     self.assertEqual(["foo", "bar", "baz"], split_path("foo/bar/baz"))
コード例 #16
0
ファイル: path_test.py プロジェクト: Amli/mopidy
 def test_single_folder(self):
     self.assertEqual(["foo"], split_path("foo"))
コード例 #17
0
ファイル: path_test.py プロジェクト: arambelo/mopidy
 def test_only_slash(self):
     self.assertEqual([], split_path('/'))
コード例 #18
0
ファイル: path_test.py プロジェクト: arambelo/mopidy
 def test_folders(self):
     self.assertEqual(['foo', 'bar', 'baz'], split_path('foo/bar/baz'))
コード例 #19
0
ファイル: test_path.py プロジェクト: karlpilkington/mopidy
 def test_empty_path(self):
     self.assertEqual([], path.split_path(""))
コード例 #20
0
 def test_empty_path(self):
     self.assertEqual([], path.split_path(''))
コード例 #21
0
ファイル: test_path.py プロジェクト: karlpilkington/mopidy
 def test_dirs(self):
     self.assertEqual(["foo", "bar", "baz"], path.split_path("foo/bar/baz"))
コード例 #22
0
 def test_single_dir(self):
     self.assertEqual(['foo'], path.split_path('foo'))
コード例 #23
0
ファイル: test_path.py プロジェクト: karlpilkington/mopidy
 def test_only_slash(self):
     self.assertEqual([], path.split_path("/"))
コード例 #24
0
 def test_dirs(self):
     self.assertEqual(['foo', 'bar', 'baz'], path.split_path('foo/bar/baz'))
コード例 #25
0
 def test_initial_slash_is_ignored(self):
     self.assertEqual(['foo', 'bar', 'baz'],
                      path.split_path('/foo/bar/baz'))
コード例 #26
0
ファイル: path_test.py プロジェクト: arambelo/mopidy
 def test_empty_path(self):
     self.assertEqual([], split_path(''))