ocarina/libsaria/sources/__init__.py
Bryan Schumaker e2fa7fff78 Don't have named sources
I don't use the named of each source any more.  It can be removed.
2010-12-07 20:45:30 -05:00

40 lines
770 B
Python

# Bryan Schumaker (8/8/2010)
import libsaria
call = libsaria.event.call
exists = libsaria.path.exists
expand = libsaria.path.expand
import library
import playlist
controls = libsaria.controls
cur_source = None
class Source:
def __init__(self):
self.get_attrs = None
self.get_cur_id = None
def load_file(self, path):
global cur_source
# I should probably get a lock here...
try:
cur_source = self
controls.load(path)
return True
except:
return False
def get_attrs(*attrs):
# I should probably get a lock here...
id = cur_source.get_cur_id()
return cur_source.get_attrs(id, *attrs)
def new_source(path, bg=True):
global library
path = expand(path)
if not exists(path):
return 0
return call("NEWSOURCE", library.scan, path)