curds: Remove icon argument from lookup() and alloc_child()

We were ignoring this argument and setting whatever is appropriate in
alloc_child(), so let's just remove it entirely.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-12-17 12:22:52 -05:00
parent 7f2864ec07
commit b728137588
10 changed files with 45 additions and 45 deletions

View File

@ -10,7 +10,7 @@ ARTIST_SORT = [ "album", "discnumber", "tracknumber" ]
class ArtistPlaylist(playlist.Playlist):
def alloc_child(self, name, icon):
def alloc_child(self, name):
return playlist.Playlist(name, ALBUM_ICON, ALBUM_SORT)
def add(self, track):
@ -22,7 +22,7 @@ class ArtistNode(tree.ETree):
def __init__(self):
tree.ETree.__init__(self, "Artists", ARTIST_ICON)
def alloc_child(self, name, icon):
def alloc_child(self, name):
return ArtistPlaylist(name, ARTIST_ICON, ARTIST_SORT)
def new_track(self, track):

View File

@ -10,7 +10,7 @@ YEAR_SORT = [ "artist", "album", "discnumber", "tracknumber" ]
class DecadePlaylist(playlist.Playlist):
def alloc_child(self, name, icon):
def alloc_child(self, name):
return playlist.Playlist(name, YEAR_ICON, YEAR_SORT)
def add(self, track):
@ -22,7 +22,7 @@ class DecadeNode(tree.ETree):
def __init__(self):
tree.ETree.__init__(self, "Decades", DECADE_ICON)
def alloc_child(self, name, icon):
def alloc_child(self, name):
return DecadePlaylist(name, DECADE_ICON, DECADE_SORT)
def new_track(self, track):

View File

@ -9,7 +9,7 @@ class GenreNode(tree.ETree):
def __init__(self):
tree.ETree.__init__(self, "Genres", GENRE_ICON)
def alloc_child(self, name, icon):
def alloc_child(self, name):
return playlist.Playlist(name, GENRE_ICON, GENRE_SORT)
def new_track(self, track):

View File

@ -28,7 +28,7 @@ class LibraryNode(tree.ETree):
def __init__(self):
tree.ETree.__init__(self, "Libraries", LIBRARY_ICON)
def alloc_child(self, path, icon):
def alloc_child(self, path):
return LibraryPlaylist(path, LIBRARY_ICON, LIBRARY_SORT)
def lookup(self, path):

View File

@ -22,7 +22,7 @@ class TestArtistPlaylist(unittest.TestCase):
def test_artist_alloc_child(self):
anode = artist.ArtistNode()
plist = anode.alloc_child("Test Artist", artist.ARTIST_ICON)
plist = anode.alloc_child("Test Artist")
self.assertIsInstance(plist, artist.ArtistPlaylist)
self.assertEqual(plist.name, "Test Artist")
self.assertEqual(plist.icon, "avatar-default-symbolic")
@ -50,7 +50,7 @@ class TestArtistPlaylist(unittest.TestCase):
def test_artist_playlist_alloc(self):
anode = artist.ArtistPlaylist("Test Playlist", artist.ARTIST_ICON)
album = anode.alloc_child("Test Album", artist.ALBUM_ICON)
album = anode.alloc_child("Test Album")
self.assertIsInstance(album, playlist.Playlist)
self.assertEqual(album.name, "Test Album")

View File

@ -25,7 +25,7 @@ class TestDecadePlaylist(unittest.TestCase):
def test_decade_alloc_child(self):
dnode = decade.DecadeNode()
plist = dnode.alloc_child("1980s", decade.DECADE_ICON)
plist = dnode.alloc_child("1980s")
self.assertIsInstance(plist, decade.DecadePlaylist)
self.assertEqual(plist.name, "1980s")
self.assertEqual(plist.icon, "x-office-calendar")
@ -54,7 +54,7 @@ class TestDecadePlaylist(unittest.TestCase):
def test_decade_playlist_alloc(self):
dnode = decade.DecadePlaylist("Test Decade", decade.DECADE_ICON)
year = dnode.alloc_child("1973", decade.DECADE_ICON)
year = dnode.alloc_child("1973")
self.assertIsInstance(year, playlist.Playlist)
self.assertEqual(year.name, "1973")

View File

@ -33,7 +33,7 @@ class TestGenrePlaylist(unittest.TestCase):
def test_genre_alloc_child(self):
gnode = genre.GenreNode()
plist = gnode.alloc_child("Test Genre", genre.GENRE_ICON)
plist = gnode.alloc_child("Test Genre")
self.assertIsInstance(plist, playlist.Playlist)
self.assertEqual(plist.name, "Test Genre")
self.assertEqual(plist.icon, "emblem-generic")

View File

@ -28,7 +28,7 @@ class TestLibraryPlaylist(unittest.TestCase):
def test_library_alloc_child(self):
lnode = library.LibraryNode()
plist = lnode.alloc_child(test_library, library.LIBRARY_ICON)
plist = lnode.alloc_child(test_library)
self.assertIsInstance(plist, library.LibraryPlaylist)
self.assertEqual(plist.name, test_library)
self.assertEqual(plist.icon, "folder-music")

View File

@ -67,9 +67,9 @@ class TestETree(unittest.TestCase):
def test_etree_child_index(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = root.lookup("B", "icon")
c = a.lookup("C", "icon")
a = root.lookup("A")
b = root.lookup("B")
c = a.lookup("C")
self.assertEqual( root.child_index(a), 0)
self.assertEqual( root.child_index(b), 1)
@ -81,9 +81,9 @@ class TestETree(unittest.TestCase):
def test_etree_get_path(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = a.lookup("B", "icon")
c = b.lookup("C", "icon")
a = root.lookup("A")
b = a.lookup("B")
c = b.lookup("C")
self.assertEqual(root.get_path(), [ ])
self.assertEqual(a.get_path(), [ 0 ])
@ -122,27 +122,27 @@ class TestETree(unittest.TestCase):
def test_etree_lookup(self):
root = tree.ETree()
b = root.lookup("B", "icon")
b = root.lookup("B")
self.assertEqual(root.children, [ b ])
self.assertEqual(b.parent, root)
d = root.lookup("D", "icon")
d = root.lookup("D")
self.assertEqual(root.children, [ b, d ])
self.assertEqual(b.sibling, d)
c = root.lookup("C", "icon")
c = root.lookup("C")
self.assertEqual(root.children, [ b, c, d ])
self.assertEqual(b.sibling, c)
self.assertEqual(c.sibling, d)
a = root.lookup("A", "icon")
a = root.lookup("A")
self.assertEqual(root.children, [ a, b, c, d ])
self.assertEqual(a.sibling, b)
self.assertEqual(root.lookup("A", "icon"), a)
self.assertEqual(root.lookup("B", "icon"), b)
self.assertEqual(root.lookup("C", "icon"), c)
self.assertEqual(root.lookup("D", "icon"), d)
self.assertEqual(root.lookup("A"), a)
self.assertEqual(root.lookup("B"), b)
self.assertEqual(root.lookup("C"), c)
self.assertEqual(root.lookup("D"), d)
self.assertEqual(root.children, [ a, b, c, d ])
self.assertEqual(root.child_ids, { id(a) : a, id(b) : b, id(c) : c, id(d) : d })
@ -163,9 +163,9 @@ class TestETree(unittest.TestCase):
def test_etree_lookup_path(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = a.lookup("B", "icon")
c = b.lookup("C", "icon")
a = root.lookup("A")
b = a.lookup("B")
c = b.lookup("C")
self.assertEqual( root.lookup_path([ ]), root)
self.assertEqual( root.lookup_path([ 0 ]), a)
@ -183,15 +183,15 @@ class TestETree(unittest.TestCase):
def test_etree_n_children(self):
root = tree.ETree()
self.assertEqual(root.n_children(), 0)
a = root.lookup("A", "icon")
a = root.lookup("A")
self.assertEqual(root.n_children(), 1)
b = root.lookup("B", "icon")
b = root.lookup("B")
self.assertEqual(root.n_children(), 2)
def test_etree_next_child(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = root.lookup("B", "icon")
a = root.lookup("A")
b = root.lookup("B")
self.assertIsNone(root.next_child())
self.assertEqual( a.next_child(), b)
@ -199,8 +199,8 @@ class TestETree(unittest.TestCase):
def test_etree_nth_child(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = root.lookup("B", "icon")
a = root.lookup("A")
b = root.lookup("B")
self.assertIsNone(root.nth_child(-1))
self.assertEqual( root.nth_child(0), a)
@ -209,8 +209,8 @@ class TestETree(unittest.TestCase):
def test_etree_reset(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = root.lookup("B", "icon")
a = root.lookup("A")
b = root.lookup("B")
root.reset()
self.assertEqual(root.children, [ ])
@ -224,10 +224,10 @@ class TestETree(unittest.TestCase):
def test_etree_walk(self):
root = tree.ETree()
a = root.lookup("A", "icon")
b = a.lookup("B", "icon")
c = a.lookup("C", "icon")
d = b.lookup("D", "icon")
a = root.lookup("A")
b = a.lookup("B")
c = a.lookup("C")
d = b.lookup("D")
vals = [ a, b, d, c ]
for i, n in enumerate(root.walk()):

View File

@ -65,8 +65,8 @@ class ETree:
self.sibling = state["sibling"]
self.__new_track__()
def alloc_child(self, name, icon):
return ETree(name, icon)
def alloc_child(self, name):
return ETree(name)
def child_index(self, child):
with self.tree_lock:
@ -89,12 +89,12 @@ class ETree:
return child
return self.__insert__(index, child)
def lookup(self, name, icon=None):
def lookup(self, name):
with self.tree_lock:
(index, child) = sort.bisect(self.children, sort.key(name))
if child != None:
return child
return self.__insert__(index, self.alloc_child(name, icon))
return self.__insert__(index, self.alloc_child(name))
def lookup_byid(self, id):
return self.child_ids.get(id, None)