def do_clear(self,arg): """ Clear all 'data' from the workspace This clears everything that looks like a variable, ie simple data types and class instances """ args = split_args(arg) if len(args) == 0: dname = [None] else: dname = args for d in dname: data = self.interp.symbol_table.get_data_dict(name=d) for key in data.keys(): del self.interp.symbol_table.data[key] return SUCCESS
def do_clear(self, arg): """ Clear all 'data' from the workspace This clears everything that looks like a variable, ie simple data types and class instances """ args = split_args(arg) if len(args) == 0: dname = [None] else: dname = args for d in dname: data = self.interp.symbol_table.get_data_dict(name=d) for key in data.keys(): del self.interp.symbol_table.data[key] return SUCCESS
def do_save(self,args): """ Save program state to a file Note this may fail since not all objects can be pickled... needs improvement! Examples: --------- >>save # save all to default fname >>save fname # save all to fname >>save data fname # save data to file """ from pds.shellutil import pickle_1 as pickle #from pds.shellutil import pickle_2 as pickle # parse input, get filename args = split_args(args) dname = None if len(args) == 0: t = time.strftime("%Y_%m_%d_%H%M", time.localtime()) fname = 'save_%s.sav' % t else: if len(args) == 1: fname = args[0] elif len(args) == 2: dname = args[0] fname = args[1] else: return # get data dictionary data = self.interp.symbol_table.get_data_dict(name=dname) if data == None: return SUCCESS # pickle it pickle(data,fname)
def do_save(self, args): """ Save program state to a file Note this may fail since not all objects can be pickled... needs improvement! Examples: --------- >>save # save all to default fname >>save fname # save all to fname >>save data fname # save data to file """ from pds.shellutil import pickle_1 as pickle #from pds.shellutil import pickle_2 as pickle # parse input, get filename args = split_args(args) dname = None if len(args) == 0: t = time.strftime("%Y_%m_%d_%H%M", time.localtime()) fname = 'save_%s.sav' % t else: if len(args) == 1: fname = args[0] elif len(args) == 2: dname = args[0] fname = args[1] else: return # get data dictionary data = self.interp.symbol_table.get_data_dict(name=dname) if data == None: return SUCCESS # pickle it pickle(data, fname)