import os import cPickle as pickle from library import Library class SavedData: def __init__(self,options): path = os.path.join(options.user,".ocarina") path = os.path.join(path,"ocarina-data.data") self.size = (800,600) self.divider = 150 self.library = Library() self.path = path if os.path.exists(path): try: self.load(path,options) except: if options.verbose == True: print "Error loading user data" # Dump user data to a file def dump(self): out = open(self.path,'w') p = pickle.Pickler(out,1) p.dump(self) out.close() # Read user data from the file def load(self,path,options): if options.verbose == True: print "User data found, loading..." p = pickle.Unpickler(open(path)) data = p.load() self.size = data.size self.library = data.library self.divider = data.divider