Show More
@@ -17,11 +17,13 b' Or to use it temporarily, run this in your IPython session::' | |||
|
17 | 17 | """ |
|
18 | 18 | |
|
19 | 19 | from IPython.core.error import TryNext, UsageError |
|
20 | from IPython.core.plugin import Plugin | |
|
20 | 21 | from IPython.utils import pickleshare |
|
22 | from IPython.utils.traitlets import Bool, Instance | |
|
21 | 23 | |
|
22 | 24 | import inspect,pickle,os,sys,textwrap |
|
23 | 25 | from IPython.core.fakemodule import FakeModule |
|
24 | ||
|
26 | ||
|
25 | 27 | def restore_aliases(ip): |
|
26 | 28 | staliases = ip.db.get('stored_aliases', {}) |
|
27 | 29 | for k,v in staliases.items(): |
@@ -183,6 +185,24 b" def magic_store(self, parameter_s=''):" | |||
|
183 | 185 | self.db[ 'autorestore/' + args[0] ] = obj |
|
184 | 186 | print "Stored '%s' (%s)" % (args[0], obj.__class__.__name__) |
|
185 | 187 | |
|
188 | ||
|
189 | class StoreMagic(Plugin): | |
|
190 | shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | |
|
191 | autorestore = Bool(False, config=True) | |
|
192 | ||
|
193 | def __init__(self, shell, config): | |
|
194 | super(StoreMagic, self).__init__(shell=shell, config=config) | |
|
195 | shell.define_magic('store', magic_store) | |
|
196 | ||
|
197 | if self.autorestore: | |
|
198 | restore_data(shell) | |
|
199 | ||
|
200 | _loaded = False | |
|
201 | ||
|
186 | 202 | def load_ipython_extension(ip): |
|
187 | ip.define_magic('store', magic_store) | |
|
188 | restore_data(ip) | |
|
203 | """Load the extension in IPython.""" | |
|
204 | global _loaded | |
|
205 | if not _loaded: | |
|
206 | plugin = StoreMagic(shell=ip, config=ip.config) | |
|
207 | ip.plugin_manager.register_plugin('storemagic', plugin) | |
|
208 | _loaded = True |
General Comments 0
You need to be logged in to leave comments.
Login now