Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
 def test_dirs(self):
     self.assertEqual(['foo', 'bar', 'baz'], path.split_path('foo/bar/baz'))
Exemplo n.º 7
0
 def test_single_dir(self):
     self.assertEqual(['foo'], path.split_path('foo'))
Exemplo n.º 8
0
 def test_only_slash(self):
     self.assertEqual([], path.split_path('/'))
Exemplo n.º 9
0
 def test_single_folder(self):
     self.assertEqual(['foo'], split_path('foo'))
Exemplo n.º 10
0
 def test_initial_slash_is_ignored(self):
     self.assertEqual(["foo", "bar", "baz"], path.split_path("/foo/bar/baz"))
Exemplo n.º 11
0
 def test_single_dir(self):
     self.assertEqual(["foo"], path.split_path("foo"))
Exemplo n.º 12
0
 def test_initial_slash_is_ignored(self):
     self.assertEqual(
         ['foo', 'bar', 'baz'], path.split_path('/foo/bar/baz'))
Exemplo n.º 13
0
 def test_folders(self):
     self.assertEqual(['foo', 'bar', 'baz'], split_path('foo/bar/baz'))
Exemplo n.º 14
0
 def test_single_folder(self):
     self.assertEqual(['foo'], split_path('foo'))
Exemplo n.º 15
0
 def test_folders(self):
     self.assertEqual(["foo", "bar", "baz"], split_path("foo/bar/baz"))
Exemplo n.º 16
0
 def test_single_folder(self):
     self.assertEqual(["foo"], split_path("foo"))
Exemplo n.º 17
0
 def test_only_slash(self):
     self.assertEqual([], split_path('/'))
Exemplo n.º 18
0
 def test_folders(self):
     self.assertEqual(['foo', 'bar', 'baz'], split_path('foo/bar/baz'))
Exemplo n.º 19
0
 def test_empty_path(self):
     self.assertEqual([], path.split_path(""))
Exemplo n.º 20
0
 def test_empty_path(self):
     self.assertEqual([], path.split_path(''))
Exemplo n.º 21
0
 def test_dirs(self):
     self.assertEqual(["foo", "bar", "baz"], path.split_path("foo/bar/baz"))
Exemplo n.º 22
0
 def test_single_dir(self):
     self.assertEqual(['foo'], path.split_path('foo'))
Exemplo n.º 23
0
 def test_only_slash(self):
     self.assertEqual([], path.split_path("/"))
Exemplo n.º 24
0
 def test_dirs(self):
     self.assertEqual(['foo', 'bar', 'baz'], path.split_path('foo/bar/baz'))
Exemplo n.º 25
0
 def test_initial_slash_is_ignored(self):
     self.assertEqual(['foo', 'bar', 'baz'],
                      path.split_path('/foo/bar/baz'))
Exemplo n.º 26
0
 def test_empty_path(self):
     self.assertEqual([], split_path(''))