libsaria: list_source() takes a function pointer
I was taking a flag that I used to determine which list func to call. I think it is simpler to take a function pointer passed from either list_playlist() or list_queue()
This commit is contained in:
parent
76975ecead
commit
93a785dafa
|
@ -13,8 +13,6 @@ controls = libsaria.controls
|
|||
cur_source = None
|
||||
cur_id = None
|
||||
|
||||
LIBRARY, PLAYLIST, QUEUE = range(3)
|
||||
|
||||
class Source:
|
||||
def __init__(self):
|
||||
self.get_attrs = None
|
||||
|
@ -70,22 +68,16 @@ def next():
|
|||
cur_id = id
|
||||
return library.get_attrs(cur_id, "filepath")
|
||||
|
||||
def list_source(source, *attrs):
|
||||
def list_source(list_func, *attrs):
|
||||
ret = []
|
||||
list_func = None
|
||||
get_attrs = library.get_attrs
|
||||
append = ret.append
|
||||
if source == PLAYLIST:
|
||||
list_func = playlist.list_ids
|
||||
elif source == QUEUE:
|
||||
list_func = queue.list_ids
|
||||
if list_func != None:
|
||||
for id in list_func():
|
||||
append(get_attrs(id, *attrs))
|
||||
for id in list_func():
|
||||
append(get_attrs(id, *attrs))
|
||||
return ret
|
||||
|
||||
def list_queue(*attrs):
|
||||
return list_source(QUEUE, *attrs)
|
||||
|
||||
def list_playlist(*attrs):
|
||||
return list_source(PLAYLIST, *attrs)
|
||||
return list_source(playlist.list_ids, *attrs)
|
||||
|
||||
def list_queue(*attrs):
|
||||
return list_source(queue.list_ids, *attrs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user