def refresh_variables(ip, key=None):
    db = ip.db
    if key is None:
        keys = db.keys('jot/*')
    else:
        keys = db.keys('jot/'+key)
    for key in keys:
        # strip autorestore
        justkey = os.path.basename(key)
        print("Restoring from", justkey, "...")
        try:
            obj = db[key]
        except KeyError:
            print("Unable to restore variable '%s', ignoring (use %%jot -d to forget!)" % justkey)
            print("The error was:",sys.exc_info()[0])
        else:
            #print "restored",justkey,"=",obj #dbg
            try:
                origname = obj.name
            except:
                ip.user_ns[justkey] = obj
                print("Restored", justkey)
            else:
                ip.user_ns[origname] = obj['val']
                print("Restored", origname)
dataset/ETHPy150Open ipython/ipython-py3k/IPython/quarantine/ipy_jot.py/refresh_variables/original