Show More
@@ -210,6 +210,14 b' class AliasManager(Configurable):' | |||||
210 | raise InvalidAliasError("An alias command must be a string, " |
|
210 | raise InvalidAliasError("An alias command must be a string, " | |
211 | "got: %r" % cmd) |
|
211 | "got: %r" % cmd) | |
212 | return True |
|
212 | return True | |
|
213 | ||||
|
214 | def retrieve_alias(self, name): | |||
|
215 | """Retrieve the command to which an alias expands.""" | |||
|
216 | caller = self.shell.magics_manager.magics['line'].get(name, None) | |||
|
217 | if isinstance(caller, AliasCaller): | |||
|
218 | return caller.cmd | |||
|
219 | else: | |||
|
220 | raise ValueError('%s is not an alias' % name) | |||
213 |
|
221 | |||
214 | def call_alias(self, alias, rest=''): |
|
222 | def call_alias(self, alias, rest=''): | |
215 | """Call an alias given its name and the rest of the line.""" |
|
223 | """Call an alias given its name and the rest of the line.""" |
@@ -211,16 +211,17 b' class StoreMagics(Magics, Configurable):' | |||||
211 | except KeyError: |
|
211 | except KeyError: | |
212 | # it might be an alias |
|
212 | # it might be an alias | |
213 | # This needs to be refactored to use the new AliasManager stuff. |
|
213 | # This needs to be refactored to use the new AliasManager stuff. | |
214 |
|
|
214 | name = args[0] | |
215 |
|
|
215 | try: | |
216 |
|
|
216 | cmd = ip.alias_manager.retrieve_alias(name) | |
217 | staliases = db.get('stored_aliases',{}) |
|
217 | except ValueError: | |
218 | staliases[ name ] = cmd |
|
218 | raise UsageError("Unknown variable '%s'" % name) | |
219 | db['stored_aliases'] = staliases |
|
219 | ||
220 | print "Alias stored: %s (%s)" % (name, cmd) |
|
220 | staliases = db.get('stored_aliases',{}) | |
221 | return |
|
221 | staliases[name] = cmd | |
222 | else: |
|
222 | db['stored_aliases'] = staliases | |
223 | raise UsageError("Unknown variable '%s'" % args[0]) |
|
223 | print "Alias stored: %s (%s)" % (name, cmd) | |
|
224 | return | |||
224 |
|
225 | |||
225 | else: |
|
226 | else: | |
226 | modname = getattr(inspect.getmodule(obj), '__name__', '') |
|
227 | modname = getattr(inspect.getmodule(obj), '__name__', '') |
General Comments 0
You need to be logged in to leave comments.
Login now