##// END OF EJS Templates
merge from trunk
Ville M. Vainio -
r1064:1e320026 merge
parent child Browse files
Show More
@@ -211,15 +211,10 b' def hg_completer(self,event):'
211
211
212
212
213
213
214 bzr_commands = """
214 def bzr_commands():
215 add annotate bind branch break-lock bundle-revisions cat check
215 out = os.popen('bzr help commands')
216 checkout commit conflicts deleted diff export gannotate gbranch
216 return [l.split()[0] for l in out]
217 gcommit gdiff help ignore ignored info init init-repository inventory
217
218 log merge missing mkdir mv nick pull push reconcile register-branch
219 remerge remove renames resolve revert revno root serve sign-my-commits
220 status testament unbind uncommit unknowns update upgrade version
221 version-info visualise whoami
222 """
223
218
224 def bzr_completer(self,event):
219 def bzr_completer(self,event):
225 """ Completer for bazaar commands """
220 """ Completer for bazaar commands """
@@ -232,7 +227,7 b' def bzr_completer(self,event):'
232 param = cmd_param[-1]
227 param = cmd_param[-1]
233 output_file = (param == '--output=')
228 output_file = (param == '--output=')
234 if cmd == 'help':
229 if cmd == 'help':
235 return bzr_commands.split()
230 return bzr_commands()
236 elif cmd in ['bundle-revisions','conflicts',
231 elif cmd in ['bundle-revisions','conflicts',
237 'deleted','nick','register-branch',
232 'deleted','nick','register-branch',
238 'serve','unbind','upgrade','version',
233 'serve','unbind','upgrade','version',
@@ -242,7 +237,7 b' def bzr_completer(self,event):'
242 # the rest are probably file names
237 # the rest are probably file names
243 return ip.IP.Completer.file_matches(event.symbol)
238 return ip.IP.Completer.file_matches(event.symbol)
244
239
245 return bzr_commands.split()
240 return bzr_commands()
246
241
247
242
248 def shlex_split(x):
243 def shlex_split(x):
@@ -533,7 +533,7 b' class DebugTools:'
533 if name in self.hotnames:
533 if name in self.hotnames:
534 self.debug_stack( "HotName '%s' caught" % name)
534 self.debug_stack( "HotName '%s' caught" % name)
535
535
536 def launch_new_instance(user_ns = None):
536 def launch_new_instance(user_ns = None,shellclass = None):
537 """ Make and start a new ipython instance.
537 """ Make and start a new ipython instance.
538
538
539 This can be called even without having an already initialized
539 This can be called even without having an already initialized
@@ -542,7 +542,7 b' def launch_new_instance(user_ns = None):'
542 This is also used as the egg entry point for the 'ipython' script.
542 This is also used as the egg entry point for the 'ipython' script.
543
543
544 """
544 """
545 ses = make_session(user_ns)
545 ses = make_session(user_ns,shellclass)
546 ses.mainloop()
546 ses.mainloop()
547
547
548
548
@@ -578,7 +578,7 b' def make_user_global_ns(ns = None):'
578 return ns
578 return ns
579
579
580
580
581 def make_session(user_ns = None):
581 def make_session(user_ns = None, shellclass = None):
582 """Makes, but does not launch an IPython session.
582 """Makes, but does not launch an IPython session.
583
583
584 Later on you can call obj.mainloop() on the returned object.
584 Later on you can call obj.mainloop() on the returned object.
@@ -591,6 +591,6 b' def make_session(user_ns = None):'
591 WARNING: This should *not* be run when a session exists already."""
591 WARNING: This should *not* be run when a session exists already."""
592
592
593 import IPython.Shell
593 import IPython.Shell
594 return IPython.Shell.start(user_ns)
594 if shellclass is None:
595
595 return IPython.Shell.start(user_ns)
596
596 return shellclass(user_ns = user_ns)
@@ -58,6 +58,14 b' from IPython.iplib import InteractiveShell'
58 from IPython.usage import cmd_line_usage,interactive_usage
58 from IPython.usage import cmd_line_usage,interactive_usage
59 from IPython.genutils import *
59 from IPython.genutils import *
60
60
61 def force_import(modname):
62 if modname in sys.modules:
63 print "reload",modname
64 reload(sys.modules[modname])
65 else:
66 __import__(modname)
67
68
61 #-----------------------------------------------------------------------------
69 #-----------------------------------------------------------------------------
62 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
70 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
63 rc_override=None,shell_class=InteractiveShell,
71 rc_override=None,shell_class=InteractiveShell,
@@ -633,15 +641,17 b" object? -> Details about 'object'. ?object also works, ?? prints more."
633 if opts_all.profile and not profile_handled_by_legacy:
641 if opts_all.profile and not profile_handled_by_legacy:
634 profmodname = 'ipy_profile_' + opts_all.profile
642 profmodname = 'ipy_profile_' + opts_all.profile
635 try:
643 try:
636 __import__(profmodname)
644
645 force_import(profmodname)
637 except:
646 except:
638 IP.InteractiveTB()
647 IP.InteractiveTB()
639 print "Error importing",profmodname,"- perhaps you should run %upgrade?"
648 print "Error importing",profmodname,"- perhaps you should run %upgrade?"
640 import_fail_info(profmodname)
649 import_fail_info(profmodname)
641 else:
650 else:
642 import ipy_profile_none
651 force_import('ipy_profile_none')
643 try:
652 try:
644 import ipy_user_conf
653
654 force_import('ipy_user_conf')
645
655
646 except:
656 except:
647 conf = opts_all.ipythondir + "/ipy_user_conf.py"
657 conf = opts_all.ipythondir + "/ipy_user_conf.py"
@@ -6,27 +6,43 b' user namespace.'
6 """
6 """
7
7
8 import sys
8 import sys
9 sys.path.append('..')
9 sys.path.insert(1,'..')
10
10
11 import IPython.ipapi
11 import IPython.ipapi
12
12
13 my_ns = dict(a=10)
14
13
15 ses = IPython.ipapi.make_session(my_ns)
16
14
17 # Now get the ipapi instance, to be stored somewhere in your program for manipulation of the running
15 def test_session(shellclass):
18 # IPython session. See http://ipython.scipy.org/moin/IpythonExtensionApi
16 print "*****************\nLaunch shell for",shellclass
19
17 my_ns = dict(a=10)
20 ip = ses.IP.getapi()
18 ses = IPython.ipapi.make_session(my_ns, shellclass=shellclass)
21
19
22 # let's play with the ipapi a bit, creating a magic function for a soon-to-be-started IPython
20 # Now get the ipapi instance, to be stored somewhere in your program for manipulation of the running
23 def mymagic_f(self,s):
21 # IPython session. See http://ipython.scipy.org/moin/IpythonExtensionApi
24 print "mymagic says",s
22
25
23 ip = ses.IP.getapi()
26 ip.expose_magic("mymagic",mymagic_f)
24
27
25 # let's play with the ipapi a bit, creating a magic function for a soon-to-be-started IPython
28 # And finally, start the IPython interaction! This will block until you say Exit.
26 def mymagic_f(self,s):
29
27 print "mymagic says",s
30 ses.mainloop()
28
31
29 ip.expose_magic("mymagic",mymagic_f)
32 print "IPython session finished! namespace content:",my_ns
30
31 # And finally, start the IPython interaction! This will block until you say Exit.
32
33 ses.mainloop()
34
35 print "IPython session for shell ",shellclass," finished! namespace content:"
36 for k,v in my_ns.items():
37 print k,':',str(v)[:80].rstrip()
38
39 import IPython.Shell
40
41 def do_test(arg_line):
42 test_session(IPython.Shell._select_shell(arg_line.split()))
43
44 do_test('')
45 do_test('ipython -gthread')
46 do_test('ipython -q4thread')
47 do_test('ipython -pylab')
48 do_test('ipython -pylab -gthread') No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now