libsaria: Comment out most code, begin new preferences

I commented out most of the code in libsaria/__init__.py to make it
easier to clean up.  I also began work on libsaria/prefs.py for managing
preferences.

NOTE: For the next several commits, the best way to test changes is by
importing libsaria through the python interpreter.  Trying to run
ocarina will probably fail.
This commit is contained in:
Bryan Schumaker 2011-04-28 08:27:51 -04:00
parent d2d894a2e4
commit 1921e78e55
3 changed files with 83 additions and 51 deletions

View File

@ -15,70 +15,72 @@ if __dev__ == True:
__vstr__ += "-dev"
__vers__ = "Libsaria %s" % __vstr__
import event
import path
from trees import Tree, PersPrefTree
from path.cache import Cache
import prefs
# The cache is also saved across sessions
prefs = None
cache = Cache()
#import event
#import path
#from trees import Tree, PersPrefTree
#from path.cache import Cache
#plugin = None
audio = None
lastfm = None
controls = None
## The cache is also saved across sessions
#prefs = None
#cache = Cache()
init_pref = None
##plugin = None
#audio = None
#lastfm = None
#controls = None
#init_pref = None
# Initialize helpful variables
def init():
global prefs
global init_pref
global audio
global lastfm
global controls
## Initialize helpful variables
#def init():
#global prefs
#global init_pref
#global audio
#global lastfm
#global controls
prefs = trees.get_pref_tree("preferences")
init_pref = prefs.init_pref
import audio
import controls
import sources
from path import lastfm
event.invite("POSTLIBLOAD", parse_user_input)
#prefs = trees.get_pref_tree("preferences")
#init_pref = prefs.init_pref
#import audio
#import controls
#import sources
#from path import lastfm
#event.invite("POSTLIBLOAD", parse_user_input)
sources.library.init_bg()
sources.playlist.init_bg()
sources.queue.init_bg()
controls.init()
event.start("POSTINIT")
#sources.library.init_bg()
#sources.playlist.init_bg()
#sources.queue.init_bg()
#controls.init()
#event.start("POSTINIT")
def startup():
# global plugin
# import plugin
#def startup():
## global plugin
## import plugin
event.start("PRESTART")
audio.init()
controls.init2()
# plugin.load_all()
prefs.enable_save()
event.start("POSTSTART")
sources.playlist.startup()
#event.start("PRESTART")
#audio.init()
#controls.init2()
## plugin.load_all()
#prefs.enable_save()
#event.start("POSTSTART")
#sources.playlist.startup()
def shutdown():
event.start("PREQUIT")
# import plugin
# plugin.quit()
event.start("POSTQUIT")
#def shutdown():
#event.start("PREQUIT")
## import plugin
## plugin.quit()
#event.start("POSTQUIT")
def parse_user_input():
import sys
for item in sys.argv[1:]:
path.files.universal_open(item)
#def parse_user_input():
#import sys
#for item in sys.argv[1:]:
#path.files.universal_open(item)
init()
#init()

6
libsaria/prefs.py Normal file
View File

@ -0,0 +1,6 @@
# Bryan Schumaker (4 / 28 / 2011)
import storage
prefs = storage.load_file("preferences", dict)

View File

@ -0,0 +1,24 @@
# Bryan Schumaker (4 / 28 / 2011)
import os
from os import path
import cPickle as pickle
import libsaria
USER_DIR = path.expanduser("~")
saria = ".saria"
if libsaria.__dev__ == True:
saria = ".saria-dev"
SARIA_DIR = path.join(USER_DIR, saria)
if path.exists(SARIA_DIR) == False:
os.mkdir(SARIA_DIR)
def load_file(filename, default):
file = path.join(SARIA_DIR, filename)
if path.exists(file) == False:
return default()
f = open(file)
item = pickle.loads(f.read())
f.close()
return item