def read(name = None, hardcopy = True,np = False, register = 'a', caller_name = None): if name == None: name = register sxs = False out = -1 if not caller_name:caller_name = inspect.stack()[1][3] try: lname = globals()['lastname_'+caller_name+register] if lname == name or name == register: return globals()['last_'+caller_name+register], True else: raise Exception() except Exception as e: if not hardcopy: return out, sxs savename = caller_name +'_'+name + '.memo' path = os.path.join(config.getTempPath(),savename) if hardcopy: path = os.path.join(config.getTempPath(), savename) try: f = open(path,'r') except Exception as e: return out, sxs if np: out = load(f) sxs = True else: out = pickle.load( f) sxs = True f.close() globals()['lastname_'+caller_name +register] = name globals()['last_'+caller_name+register] = out return out, sxs
def write(name = None,value = None, hardcopy = True, np = False, register= 'a', caller_name = None): if name == None: name = register if not caller_name: caller_name = inspect.stack()[1][3] savename = caller_name + '_' +name + '.memo' globals()['lastname_'+caller_name +register] = name globals()['last_'+caller_name+register] = value if hardcopy: path = os.path.join(config.getTempPath(), savename) f = open(path,'w') if np: save( f,value) else: pickle.dump(value, f) f.close()