##// END OF EJS Templates
callable alias fixes
vivainio -
Show More
@@ -20,7 +20,8 b' def restore_aliases(self):'
20 staliases = ip.db.get('stored_aliases', {})
20 staliases = ip.db.get('stored_aliases', {})
21 for k,v in staliases.items():
21 for k,v in staliases.items():
22 #print "restore alias",k,v # dbg
22 #print "restore alias",k,v # dbg
23 self.alias_table[k] = v
23 #self.alias_table[k] = v
24 ip.defalias(k,v)
24
25
25
26
26 def refresh_variables(ip):
27 def refresh_variables(ip):
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 2607 2007-08-13 13:25:24Z fperez $"""
4 $Id: Magic.py 2637 2007-08-17 16:18:05Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -2289,7 +2289,11 b' Defaulting color scheme to \'NoColor\'"""'
2289 res = []
2289 res = []
2290 showlast = []
2290 showlast = []
2291 for alias in aliases:
2291 for alias in aliases:
2292 tgt = atab[alias][1]
2292 try:
2293 tgt = atab[alias][1]
2294 except TypeError:
2295 # unsubscriptable? probably a callable
2296 tgt = atab[alias]
2293 # 'interesting' aliases
2297 # 'interesting' aliases
2294 if (alias in stored or
2298 if (alias in stored or
2295 alias.lower() != os.path.splitext(tgt)[0].lower() or
2299 alias.lower() != os.path.splitext(tgt)[0].lower() or
@@ -362,13 +362,12 b' class IPApi:'
362 setattr(IPython.shadowns, name,cmd)
362 setattr(IPython.shadowns, name,cmd)
363 return
363 return
364
364
365
365 if isinstance(cmd,basestring):
366 nargs = cmd.count('%s')
366 nargs = cmd.count('%s')
367 if nargs>0 and cmd.find('%l')>=0:
367 if nargs>0 and cmd.find('%l')>=0:
368 raise Exception('The %s and %l specifiers are mutually exclusive '
368 raise Exception('The %s and %l specifiers are mutually exclusive '
369 'in alias definitions.')
369 'in alias definitions.')
370
370
371 else: # all looks OK
372 self.IP.alias_table[name] = (nargs,cmd)
371 self.IP.alias_table[name] = (nargs,cmd)
373
372
374 def defmacro(self, *args):
373 def defmacro(self, *args):
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 2631 2007-08-15 07:07:36Z fperez $
9 $Id: iplib.py 2637 2007-08-17 16:18:05Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -1742,7 +1742,10 b' want to merge them back into the new files.""" % locals()'
1742 def transform_alias(self, alias,rest=''):
1742 def transform_alias(self, alias,rest=''):
1743 """ Transform alias to system command string.
1743 """ Transform alias to system command string.
1744 """
1744 """
1745 nargs,cmd = self.alias_table[alias]
1745 trg = self.alias_table[alias]
1746
1747 nargs,cmd = trg
1748 # print trg #dbg
1746 if ' ' in cmd and os.path.isfile(cmd):
1749 if ' ' in cmd and os.path.isfile(cmd):
1747 cmd = '"%s"' % cmd
1750 cmd = '"%s"' % cmd
1748
1751
General Comments 0
You need to be logged in to leave comments. Login now