457bea2ff3
The new preferences code is much easier to work with. Rather than inheriting from a complicated tree class, I just set values in a python dictionary directly.
29 lines
441 B
Python
29 lines
441 B
Python
# Bryan Schumaker (4 / 28 / 2011)
|
|
|
|
import storage
|
|
|
|
FILE = "preferences"
|
|
prefs = storage.load_obj(FILE, dict)
|
|
save_enable = False
|
|
|
|
def save():
|
|
if save_enable == True:
|
|
storage.save_obj(FILE, prefs)
|
|
|
|
def enable_save():
|
|
global save_enable
|
|
save_enable = True
|
|
save()
|
|
|
|
def get(key):
|
|
return prefs.get(key, None)
|
|
|
|
def set(key, value):
|
|
prefs[key] = value
|
|
save()
|
|
|
|
def init(key, value):
|
|
val = prefs.setdefault(key, value)
|
|
save()
|
|
return val
|