4
4
run_flags = "-i" # flags to for IPython's run magic when using <F5>
5
5
current_line = ''
6
6
7
- from Queue import Empty
7
+ try :
8
+ from queue import Empty # python3 convention
9
+ except ImportError :
10
+ from Queue import Empty
8
11
9
12
try :
10
13
import vim
@@ -13,7 +16,7 @@ class NoOp(object):
13
16
def __getattribute__ (self , key ):
14
17
return lambda * args : '0'
15
18
vim = NoOp ()
16
- print "uh oh, not running inside vim"
19
+ print ( "uh oh, not running inside vim" )
17
20
18
21
import sys
19
22
@@ -87,7 +90,6 @@ def km_from_string(s=''):
87
90
except ImportError :
88
91
raise ImportError ("Could not find IPython. " + _install_instructions )
89
92
from IPython .config .loader import KeyValueConfigLoader
90
- from Queue import Empty
91
93
try :
92
94
from IPython .kernel import (
93
95
KernelManager ,
@@ -103,7 +105,7 @@ def km_from_string(s=''):
103
105
# < 0.12, no find_connection_file
104
106
pass
105
107
106
- global km , kc , send , Empty
108
+ global km , kc , send
107
109
108
110
s = s .replace ('--existing' , '' )
109
111
if 'connection_file' in KernelManager .class_trait_names ():
@@ -123,7 +125,7 @@ def km_from_string(s=''):
123
125
fullpath = find_connection_file (k ,p )
124
126
else :
125
127
fullpath = find_connection_file (s .lstrip ().rstrip ())
126
- except IOError , e :
128
+ except IOError as e :
127
129
echo (":IPython " + s + " failed" , "Info" )
128
130
echo ("^-- failed '" + s + "' not found" , "Error" )
129
131
return
@@ -141,7 +143,7 @@ def km_from_string(s=''):
141
143
sub_address = (ip , cfg ['iopub_port' ]),
142
144
stdin_address = (ip , cfg ['stdin_port' ]),
143
145
hb_address = (ip , cfg ['hb_port' ]))
144
- except KeyError , e :
146
+ except KeyError as e :
145
147
echo (":IPython " + s + " failed" , "Info" )
146
148
echo ("^-- failed --" + e .message .replace ('_port' ,'' )+ " not specified" , "Error" )
147
149
return
@@ -194,7 +196,7 @@ def echo(arg,style="Question"):
194
196
vim .command ("echom \" %s\" " % arg .replace ('\" ' ,'\\ \" ' ))
195
197
vim .command ("echohl None" )
196
198
except vim .error :
197
- print "-- %s" % arg
199
+ print ( "-- %s" % arg )
198
200
199
201
def disconnect ():
200
202
"disconnect kernel manager"
@@ -532,7 +534,7 @@ def run_these_lines(dedent=False):
532
534
vim .command ("normal! " )
533
535
534
536
#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) )
536
538
prompt = "lines %d-%d " % (r .start + 1 ,r .end + 1 )
537
539
print_prompt (prompt ,msg_id )
538
540
@@ -602,30 +604,31 @@ def dedent_run_these_lines():
602
604
#def set_this_line():
603
605
# # not sure if there's a way to do this, since we have multiple clients
604
606
# 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)
606
608
# echo("line \'%s\' set at ipython prompt"% vim.current.line,'Statement')
607
609
608
610
609
611
def toggle_reselect ():
610
612
global reselect
611
613
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 " ))
613
616
614
617
#def set_breakpoint():
615
618
# send("__IP.InteractiveTB.pdb.set_break('%s',%d)" % (vim.current.buffer.name,
616
619
# 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]))
619
622
#
620
623
#def clear_breakpoint():
621
624
# send("__IP.InteractiveTB.pdb.clear_break('%s',%d)" % (vim.current.buffer.name,
622
625
# 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]))
625
628
#
626
629
#def clear_all_breakpoints():
627
630
# send("__IP.InteractiveTB.pdb.clear_all_breaks()");
628
- # print "clearing all breakpoints"
631
+ # print( "clearing all breakpoints")
629
632
#
630
633
#def run_this_file_pdb():
631
634
# send(' __IP.InteractiveTB.pdb.run(\'execfile("%s")\')' % (vim.current.buffer.name,))
0 commit comments