44run_flags = "-i" # flags to for IPython's run magic when using <F5>
55current_line = ''
66
7- from Queue import Empty
7+ try :
8+ from queue import Empty # python3 convention
9+ except ImportError :
10+ from Queue import Empty
811
912try :
1013 import vim
@@ -13,7 +16,7 @@ class NoOp(object):
1316 def __getattribute__ (self , key ):
1417 return lambda * args : '0'
1518 vim = NoOp ()
16- print "uh oh, not running inside vim"
19+ print ( "uh oh, not running inside vim" )
1720
1821import sys
1922
@@ -87,7 +90,6 @@ def km_from_string(s=''):
8790 except ImportError :
8891 raise ImportError ("Could not find IPython. " + _install_instructions )
8992 from IPython .config .loader import KeyValueConfigLoader
90- from Queue import Empty
9193 try :
9294 from IPython .kernel import (
9395 KernelManager ,
@@ -103,7 +105,7 @@ def km_from_string(s=''):
103105 # < 0.12, no find_connection_file
104106 pass
105107
106- global km , kc , send , Empty
108+ global km , kc , send
107109
108110 s = s .replace ('--existing' , '' )
109111 if 'connection_file' in KernelManager .class_trait_names ():
@@ -123,7 +125,7 @@ def km_from_string(s=''):
123125 fullpath = find_connection_file (k ,p )
124126 else :
125127 fullpath = find_connection_file (s .lstrip ().rstrip ())
126- except IOError , e :
128+ except IOError as e :
127129 echo (":IPython " + s + " failed" , "Info" )
128130 echo ("^-- failed '" + s + "' not found" , "Error" )
129131 return
@@ -141,7 +143,7 @@ def km_from_string(s=''):
141143 sub_address = (ip , cfg ['iopub_port' ]),
142144 stdin_address = (ip , cfg ['stdin_port' ]),
143145 hb_address = (ip , cfg ['hb_port' ]))
144- except KeyError , e :
146+ except KeyError as e :
145147 echo (":IPython " + s + " failed" , "Info" )
146148 echo ("^-- failed --" + e .message .replace ('_port' ,'' )+ " not specified" , "Error" )
147149 return
@@ -194,7 +196,7 @@ def echo(arg,style="Question"):
194196 vim .command ("echom \" %s\" " % arg .replace ('\" ' ,'\\ \" ' ))
195197 vim .command ("echohl None" )
196198 except vim .error :
197- print "-- %s" % arg
199+ print ( "-- %s" % arg )
198200
199201def disconnect ():
200202 "disconnect kernel manager"
@@ -532,7 +534,7 @@ def run_these_lines(dedent=False):
532534 vim .command ("normal! " )
533535
534536 #vim lines start with 1
535- #print "lines %d-%d sent to ipython"% (r.start+1,r.end+1)
537+ #print( "lines %d-%d sent to ipython"% (r.start+1,r.end+1) )
536538 prompt = "lines %d-%d " % (r .start + 1 ,r .end + 1 )
537539 print_prompt (prompt ,msg_id )
538540
@@ -602,30 +604,31 @@ def dedent_run_these_lines():
602604#def set_this_line():
603605# # not sure if there's a way to do this, since we have multiple clients
604606# send("get_ipython().shell.set_next_input(\'%s\')" % vim.current.line.replace("\'","\\\'"))
605- # #print "line \'%s\' set at ipython prompt"% vim.current.line
607+ # #print( "line \'%s\' set at ipython prompt"% vim.current.line)
606608# echo("line \'%s\' set at ipython prompt"% vim.current.line,'Statement')
607609
608610
609611def toggle_reselect ():
610612 global reselect
611613 reselect = not reselect
612- print "F9 will%sreselect lines after sending to ipython" % (reselect and " " or " not " )
614+ print ("F9 will%sreselect lines after sending to ipython" %
615+ (reselect and " " or " not " ))
613616
614617#def set_breakpoint():
615618# send("__IP.InteractiveTB.pdb.set_break('%s',%d)" % (vim.current.buffer.name,
616619# vim.current.window.cursor[0]))
617- # print "set breakpoint in %s:%d"% (vim.current.buffer.name,
618- # vim.current.window.cursor[0])
620+ # print( "set breakpoint in %s:%d"% (vim.current.buffer.name,
621+ # vim.current.window.cursor[0]))
619622#
620623#def clear_breakpoint():
621624# send("__IP.InteractiveTB.pdb.clear_break('%s',%d)" % (vim.current.buffer.name,
622625# vim.current.window.cursor[0]))
623- # print "clearing breakpoint in %s:%d" % (vim.current.buffer.name,
624- # vim.current.window.cursor[0])
626+ # print( "clearing breakpoint in %s:%d" % (vim.current.buffer.name,
627+ # vim.current.window.cursor[0]))
625628#
626629#def clear_all_breakpoints():
627630# send("__IP.InteractiveTB.pdb.clear_all_breaks()");
628- # print "clearing all breakpoints"
631+ # print( "clearing all breakpoints")
629632#
630633#def run_this_file_pdb():
631634# send(' __IP.InteractiveTB.pdb.run(\'execfile("%s")\')' % (vim.current.buffer.name,))
0 commit comments