##// END OF EJS Templates
Added enhancement to allow for specifying variable name to restore....
Michael Shuffett -
Show More
@@ -33,7 +33,7 b' from IPython.testing.skipdoctest import skip_doctest'
33 #-----------------------------------------------------------------------------
33 #-----------------------------------------------------------------------------
34 # Functions and classes
34 # Functions and classes
35 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
36
36
37 def restore_aliases(ip):
37 def restore_aliases(ip):
38 staliases = ip.db.get('stored_aliases', {})
38 staliases = ip.db.get('stored_aliases', {})
39 for k,v in staliases.items():
39 for k,v in staliases.items():
@@ -100,6 +100,8 b' class StoreMagics(Magics):'
100 * ``%store -z`` - Remove all variables from storage
100 * ``%store -z`` - Remove all variables from storage
101 * ``%store -r`` - Refresh all variables from store (delete
101 * ``%store -r`` - Refresh all variables from store (delete
102 current vals)
102 current vals)
103 * ``%store -r spam`` - Refresh specified variable from store (delete
104 current val)
103 * ``%store foo >a.txt`` - Store value of foo to new file a.txt
105 * ``%store foo >a.txt`` - Store value of foo to new file a.txt
104 * ``%store foo >>a.txt`` - Append value of foo to file a.txt
106 * ``%store foo >>a.txt`` - Append value of foo to file a.txt
105
107
@@ -133,8 +135,16 b' class StoreMagics(Magics):'
133 del db[k]
135 del db[k]
134
136
135 elif 'r' in opts:
137 elif 'r' in opts:
136 refresh_variables(ip)
138 if args:
137
139 try:
140 obj = db['autorestore/' + args[0]]
141 except KeyError:
142 print "Unable to restore variable '%s', (use %%store -d to forget!)" % args[0]
143 print "The error was:", sys.exc_info()[0]
144 else:
145 ip.user_ns[args[0]] = obj
146 else:
147 refresh_variables(ip)
138
148
139 # run without arguments -> list variables & values
149 # run without arguments -> list variables & values
140 elif not args:
150 elif not args:
General Comments 0
You need to be logged in to leave comments. Login now