libsaria: New preferences functions
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.
This commit is contained in:
parent
af5947b088
commit
457bea2ff3
|
@ -2,5 +2,27 @@
|
|||
|
||||
import storage
|
||||
|
||||
prefs = storage.load_file("preferences", dict)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue