# 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
