def _create_shelf(file_name,data): """Use this to write the data to a new file """ shelf_name = file_name.split('.')[0] f = dumb_shelve.open(shelf_name,'w') for i in data.keys(): # print 'saving...',i f[i] = data[i] # print 'done' f.close()
def _load(module): """ Load data into module from a shelf with the same name as the module. """ dir,filename = os.path.split(module.__file__) filebase = filename.split('.')[0] fn = os.path.join(dir, filebase) f = dumb_shelve.open(fn, "r") #exec( 'import ' + module.__name__) for i in f.keys(): exec( 'import ' + module.__name__+ ';' + module.__name__+'.'+i + '=' + 'f["' + i + '"]')