##// END OF EJS Templates
ipalias deprecated/redundant; aliases are converted and called...
vivainio -
r169:20c073de
parent child
Show More
@@ -6,7 +6,7 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 1107 2006-01-30 19:02:20Z vivainio $
9 $Id: iplib.py 1111 2006-01-30 21:16:07Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -661,7 +661,7 class InteractiveShell(object,Magic):
661 reference to IPython itself."""
661 reference to IPython itself."""
662
662
663 # TODO: deprecate all except _ip; 'jobs' should be installed
663 # TODO: deprecate all except _ip; 'jobs' should be installed
664 # by an extension and the rest are under _ip
664 # by an extension and the rest are under _ip, ipalias is redundant
665 builtins_new = dict(__IPYTHON__ = self,
665 builtins_new = dict(__IPYTHON__ = self,
666 ip_set_hook = self.set_hook,
666 ip_set_hook = self.set_hook,
667 jobs = self.jobs,
667 jobs = self.jobs,
@@ -1500,14 +1500,10 want to merge them back into the new files.""" % locals()
1500 if self.InteractiveTB.call_pdb and self.has_readline:
1500 if self.InteractiveTB.call_pdb and self.has_readline:
1501 self.readline.set_completer(self.Completer.complete)
1501 self.readline.set_completer(self.Completer.complete)
1502
1502
1503 def call_alias(self,alias,rest=''):
1503 def transform_alias(self, alias,rest=''):
1504 """Call an alias given its name and the rest of the line.
1504 """ Transform alias to system command string
1505
1505
1506 This function MUST be given a proper alias, because it doesn't make
1506 """
1507 any checks when looking up into the alias table. The caller is
1508 responsible for invoking it only with a valid alias."""
1509
1510 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1511 nargs,cmd = self.alias_table[alias]
1507 nargs,cmd = self.alias_table[alias]
1512 # Expand the %l special to be the user's input line
1508 # Expand the %l special to be the user's input line
1513 if cmd.find('%l') >= 0:
1509 if cmd.find('%l') >= 0:
@@ -1522,9 +1518,20 want to merge them back into the new files.""" % locals()
1522 if len(args)< nargs:
1518 if len(args)< nargs:
1523 error('Alias <%s> requires %s arguments, %s given.' %
1519 error('Alias <%s> requires %s arguments, %s given.' %
1524 (alias,nargs,len(args)))
1520 (alias,nargs,len(args)))
1525 return
1521 return None
1526 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1522 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1527 # Now call the macro, evaluating in the user's namespace
1523 # Now call the macro, evaluating in the user's namespace
1524
1525 return cmd
1526
1527 def call_alias(self,alias,rest=''):
1528 """Call an alias given its name and the rest of the line.
1529
1530 This is only used to provide backwards compatibility for users of
1531 ipalias(), use of which is not recommended for anymore."""
1532
1533 # Now call the macro, evaluating in the user's namespace
1534 cmd = self.transform_alias(alias, rest)
1528 try:
1535 try:
1529 self.system(cmd)
1536 self.system(cmd)
1530 except:
1537 except:
@@ -1959,7 +1966,8 want to merge them back into the new files.""" % locals()
1959
1966
1960 # pre is needed, because it carries the leading whitespace. Otherwise
1967 # pre is needed, because it carries the leading whitespace. Otherwise
1961 # aliases won't work in indented sections.
1968 # aliases won't work in indented sections.
1962 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1969 transformed = self.transform_alias(iFun, theRest)
1970 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
1963 self.log(line_out,continue_prompt)
1971 self.log(line_out,continue_prompt)
1964 return line_out
1972 return line_out
1965
1973
@@ -6,7 +6,7 Requires Python 2.1 or better.
6
6
7 This file contains the main make_IPython() starter function.
7 This file contains the main make_IPython() starter function.
8
8
9 $Id: ipmaker.py 1092 2006-01-27 23:56:32Z vivainio $"""
9 $Id: ipmaker.py 1111 2006-01-30 21:16:07Z vivainio $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -562,8 +562,6 object? -> Details about 'object'. ?object also works, ?? prints more.
562 print 'loaded first).\n'
562 print 'loaded first).\n'
563 pprint(IP_rc.__dict__)
563 pprint(IP_rc.__dict__)
564
564
565 # Make it easy to import extensions
566 sys.path.append(os.path.join(IPython_dir,"Extensions"))
567 for mod in IP_rc.import_mod:
565 for mod in IP_rc.import_mod:
568 try:
566 try:
569 exec 'import '+mod in IP.user_ns
567 exec 'import '+mod in IP.user_ns
@@ -16,6 +16,9
16 * path.py move to Extensions so that pickleshare does not need
16 * path.py move to Extensions so that pickleshare does not need
17 IPython-specific import. Extensions added to pythonpath right
17 IPython-specific import. Extensions added to pythonpath right
18 at __init__.
18 at __init__.
19
20 * iplib.py: ipalias deprecated/redundant; aliases are converted and
21 called with _ip.system and the pre-transformed command string.
19
22
20 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
23 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
21
24
General Comments 0
You need to be logged in to leave comments. Login now