##// END OF EJS Templates
-Expose IPApi is _ip in user namespace....
vivainio -
Show More
@@ -26,7 +26,7 b' def hnd_magic(line,mo):'
26 26 var = mo.group('varname')
27 27 cmd = mo.group('cmd')
28 28 expr = make_quoted_expr(cmd)
29 return itpl('$var = ipmagic($expr)')
29 return itpl('$var = _ip.magic($expr)')
30 30
31 31 def hnd_syscmd(line,mo):
32 32 """ Handle a = !ls """
@@ -36,7 +36,7 b' def hnd_syscmd(line,mo):'
36 36 var = mo.group('varname')
37 37 cmd = mo.group('cmd')
38 38 expr = make_quoted_expr(itpl("sc -l =$cmd"))
39 return itpl('$var = ipmagic($expr)')
39 return itpl('$var = _ip.magic($expr)')
40 40
41 41 def install_re_handler(pat, hnd):
42 42 ip.meta().re_prefilters.append((re.compile(pat), hnd))
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 1094 2006-01-28 00:47:41Z vivainio $"""
4 $Id: Magic.py 1096 2006-01-28 20:08:02Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -506,7 +506,7 b' Currently the magic system has the following functions:\\n"""'
506 506 like magics or aliases are turned into function calls, for
507 507 example). With this option, you'll see the unfiltered history
508 508 instead of the filtered version: '%cd /' will be seen as '%cd /'
509 instead of 'ipmagic("%cd /")'.
509 instead of '_ip.magic("%cd /")'.
510 510 """
511 511
512 512 shell = self.shell
@@ -573,7 +573,7 b' Currently the magic system has the following functions:\\n"""'
573 573 for n in range(len(self.shell.input_hist)-2,0,-1):
574 574 input = self.shell.input_hist[n]
575 575 # skip plain 'r' lines so we don't recurse to infinity
576 if input != 'ipmagic("r")\n' and \
576 if input != '_ip.magic("r")\n' and \
577 577 (input.startswith(start) or input.startswith(start_magic)):
578 578 #print 'match',`input` # dbg
579 579 print 'Executing:',input,
@@ -1150,11 +1150,10 b' Currently the magic system has the following functions:\\n"""'
1150 1150
1151 1151 If you really need to assign this value via an explicit function call,
1152 1152 you can always tap directly into the true name of the magic function
1153 by using the ipmagic function (which IPython automatically adds to the
1154 builtins):\\
1155 In [3]: stats = ipmagic('prun','-r print 4')
1153 by using the _ip.magic function:\\
1154 In [3]: stats = _ip.magic('prun','-r print 4')
1156 1155
1157 You can type ipmagic? for more details on ipmagic.
1156 You can type _ip.magic? for more details.
1158 1157
1159 1158 -s <key>: sort profile by given key. You can provide more than one key
1160 1159 by using the option several times: '-s key1 -s key2 -s key3...'. The
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6 6
7 7 This file contains all the classes and helper functions specific to IPython.
8 8
9 $Id: iplib.py 1093 2006-01-28 00:18:49Z vivainio $
9 $Id: iplib.py 1096 2006-01-28 20:08:02Z vivainio $
10 10 """
11 11
12 12 #*****************************************************************************
@@ -680,12 +680,15 b' class InteractiveShell(object,Magic):'
680 680 Some parts of ipython operate via builtins injected here, which hold a
681 681 reference to IPython itself."""
682 682
683 # TODO: deprecate all except _ip; 'jobs' should be installed
684 # by an extension and the rest are under _ip
683 685 builtins_new = dict(__IPYTHON__ = self,
684 686 ip_set_hook = self.set_hook,
685 687 jobs = self.jobs,
686 688 ipmagic = self.ipmagic,
687 689 ipalias = self.ipalias,
688 690 ipsystem = self.ipsystem,
691 _ip = self.api
689 692 )
690 693 for biname,bival in builtins_new.items():
691 694 try:
@@ -1240,8 +1243,9 b' want to merge them back into the new files.""" % locals()'
1240 1243
1241 1244 return False
1242 1245 try:
1243 if not ask_yes_no('Return to editor to correct syntax error? '
1244 '[Y/n] ','y'):
1246 if (self.rc.autoedit_syntax != 2 and
1247 not ask_yes_no('Return to editor to correct syntax error? '
1248 '[Y/n] ','y')):
1245 1249 return False
1246 1250 except EOFError:
1247 1251 return False
@@ -2013,7 +2017,7 b' want to merge them back into the new files.""" % locals()'
2013 2017 """Execute magic functions."""
2014 2018
2015 2019
2016 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2020 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2017 2021 self.log(cmd,continue_prompt)
2018 2022 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2019 2023 return cmd
@@ -1,5 +1,15 b''
1 1 2006-01-27 Ville Vainio <vivainio@gmail.com>
2 2
3 * iplib.py: Expose ipapi as _ip in builtin namespace.
4 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
5 and ip_set_hook (-> _ip.set_hook) redundant. % and !
6 syntax now produce _ip.* variant of the commands.
7
8 * "_ip.options().autoedit_syntax = 2" automatically throws
9 user to editor for syntax error correction without prompting.
10
11 2006-01-27 Ville Vainio <vivainio@gmail.com>
12
3 13 * ipmaker.py: Give "realistic" sys.argv for scripts (without
4 14 'ipython' at argv[0]) executed through command line.
5 15 NOTE: this DEPRECATES calling ipython with multiple scripts
@@ -11,7 +11,7 b' import sys,IPython,re'
11 11 fil=open("magic.tex","w")
12 12 oldout=sys.stdout
13 13 sys.stdout=fil
14 ipmagic("magic -latex")
14 _ip.magic("magic -latex")
15 15 sys.stdout=oldout
16 16 fil.close()
17 17
General Comments 0
You need to be logged in to leave comments. Login now