libsaria: Generic list_source() function
This function will loop over the entire source and collect attributes for each id. The resulting list will be returned to the caller. I also added a list_queue() function so the user doesn't need to pass the QUEUE flag.
This commit is contained in:
parent
5c056191f2
commit
d30eaeea50
|
@ -14,6 +14,8 @@ controls = libsaria.controls
|
||||||
cur_source = None
|
cur_source = None
|
||||||
cur_id = None
|
cur_id = None
|
||||||
|
|
||||||
|
LIBRARY, PLAYLIST, QUEUE = range(3)
|
||||||
|
|
||||||
class Source:
|
class Source:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.get_attrs = None
|
self.get_attrs = None
|
||||||
|
@ -70,3 +72,18 @@ def next():
|
||||||
if cur_id == None:
|
if cur_id == None:
|
||||||
cur_id = playlist.next()
|
cur_id = playlist.next()
|
||||||
return library.get_attrs(cur_id, "filepath")
|
return library.get_attrs(cur_id, "filepath")
|
||||||
|
|
||||||
|
def list_source(source, *attrs):
|
||||||
|
ret = []
|
||||||
|
list_func = None
|
||||||
|
get_attrs = library.get_attrs
|
||||||
|
append = ret.append
|
||||||
|
if source == QUEUE:
|
||||||
|
list_func = queue.list
|
||||||
|
if list_func != None:
|
||||||
|
for id in list_func():
|
||||||
|
append(get_attrs(id, *attrs))
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def list_queue(*attrs):
|
||||||
|
return list_source(QUEUE, *attrs)
|
||||||
|
|
|
@ -18,6 +18,10 @@ def walk_queue(*attrs):
|
||||||
res.append(library.get_attrs(id, *attrs))
|
res.append(library.get_attrs(id, *attrs))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def list():
|
||||||
|
for id in queue.queue_list:
|
||||||
|
yield id
|
||||||
|
|
||||||
def filter(text):
|
def filter(text):
|
||||||
global visible, filtered
|
global visible, filtered
|
||||||
if len(text) > 0:
|
if len(text) > 0:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user