@@ -22,8 +22,8 @@ def ask(self, prompt, default=None, starting=None):
2222 if starting is None :
2323 starting = ''
2424 if default is not None :
25- prompt = prompt + ( '[%s ] ' % default )
26- result = call ('input("%s ", "%s ")' % (prompt , starting ))
25+ prompt = prompt + '[{0} ] '. format ( default )
26+ result = call ('input("{0} ", "{1} ")' . format (prompt , starting ))
2727 if default is not None and result == '' :
2828 return default
2929 return result
@@ -33,11 +33,14 @@ def ask_values(self, prompt, values, default=None,
3333 if show_values or (show_values is None and len (values ) < 14 ):
3434 self ._print_values (values )
3535 if default is not None :
36- prompt = prompt + ( '[%s ] ' % default )
36+ prompt = prompt + '[{0} ] '. format ( default )
3737 starting = starting or ''
3838 _completer .values = values
39- answer = call ('input("%s", "%s", "customlist,RopeValueCompleter")' %
40- (prompt , starting ))
39+ answer = call (
40+ 'input("{0}", "{1}", "customlist,RopeValueCompleter")' .format (
41+ prompt , starting
42+ )
43+ )
4144 if answer is None :
4245 if 'cancel' in values :
4346 return 'cancel'
@@ -55,14 +58,14 @@ def _print_values(self, values):
5558 echo ('\n ' .join (numbered ) + '\n ' )
5659
5760 def ask_directory (self , prompt , default = None , starting = None ):
58- return call ('input("%s ", ".", "dir")' % prompt )
61+ return call ('input("{0} ", ".", "dir")' . format ( prompt ) )
5962
6063 def _update_proposals (self , values ):
6164 self .completeopt = vim .eval ('&completeopt' )
6265 self .preview = 'preview' in self .completeopt
6366
6467 if not self .get ('extended_complete' ):
65- return u',' .join (u"'%s'" % self ._completion_text (proposal )
68+ return u',' .join (u"'{0}'" . format ( self ._completion_text (proposal ) )
6669 for proposal in values )
6770
6871 return u',' .join (self ._extended_completion (proposal )
@@ -79,7 +82,7 @@ def ask_completion(self, prompt, values, starting=None):
7982 col = int (call ('col(".")' ))
8083 if starting :
8184 col -= len (starting )
82- self ._command (u'call complete(%s , [%s ])' % (col , proposals ),
85+ self ._command (u'call complete({0} , [{1} ])' . format (col , proposals ),
8386 encode = True )
8487 return None
8588
@@ -96,8 +99,8 @@ def y_or_n(self, prompt):
9699 return self .yes_or_no (prompt )
97100
98101 def get (self , name , default = None ):
99- vimname = 'g:pymode_rope_%s' % name
100- if str (vim .eval ('exists("%s ")' % vimname )) == '0' :
102+ vimname = 'g:pymode_rope_{0}' . format ( name )
103+ if str (vim .eval ('exists("{0} ")' . format ( vimname ) )) == '0' :
101104 return default
102105 result = vim .eval (vimname )
103106 if isinstance (result , str ) and result .isdigit ():
@@ -262,8 +265,9 @@ def _writedefs(self, locations, filename):
262265
263266 def show_doc (self , docs , altview = False ):
264267 if docs :
265- cmd = 'call pymode#ShowStr("%s")' % str (docs .replace ('"' , '\\ "' ))
266- vim .command (cmd )
268+ vim .command (
269+ 'call pymode#ShowStr("{0}")' .format (docs .replace ('"' , '\\ "' ))
270+ )
267271
268272 def preview_changes (self , diffs ):
269273 echo (diffs )
@@ -282,23 +286,33 @@ def add_hook(self, name, callback, hook):
282286 'after_save' : 'FileWritePost,BufWritePost' ,
283287 'exit' : 'VimLeave' }
284288 self ._add_function (name , callback )
285- vim .command ('autocmd %s *.py call %s()' %
286- (mapping [hook ], _vim_name (name )))
289+ vim .command (
290+ 'autocmd {0} *.py call {1}()' .format (
291+ mapping [hook ], _vim_name (name )
292+ )
293+ )
287294
288295 def _add_command (self , name , callback , key , prefix , prekey ):
289296 self ._add_function (name , callback , prefix )
290- vim .command ('command! -range %s call %s()' %
291- (_vim_name (name ), _vim_name (name )))
297+ vim .command (
298+ 'command! -range {0} call {1}()' .format (
299+ _vim_name (name ), _vim_name (name )
300+ )
301+ )
292302 if key is not None :
293303 key = prekey + key .replace (' ' , '' )
294- vim .command ('noremap %s :call %s()<cr>' % (key , _vim_name (name )))
304+ vim .command (
305+ 'noremap {0} :call {1}()<cr>' .format (key , _vim_name (name ))
306+ )
295307
296308 def _add_function (self , name , callback , prefix = False ):
297309 globals ()[name ] = callback
298310 arg = 'None' if prefix else ''
299- vim .command ('function! %s()\n ' % _vim_name (name ) +
300- 'python ropevim.%s(%s)\n ' % (name , arg ) +
301- 'endfunction\n ' )
311+ vim .command (
312+ 'function! {0}()\n '
313+ 'python ropevim.{1}({2})\n '
314+ 'endfunction\n ' .format (_vim_name (name ), name , arg )
315+ )
302316
303317 def _completion_data (self , proposal ):
304318 return proposal
@@ -318,7 +332,7 @@ def _extended_completion(self, proposal):
318332
319333 if proposal .scope == 'parameter_keyword' :
320334 default = proposal .get_default ()
321- ci ["menu" ] += '*' if default is None else '= %s' % default
335+ ci ["menu" ] += '*' if default is None else '= {0}' . format ( default )
322336
323337 if self .preview and not ci ['menu' ]:
324338 doc = proposal .get_doc ()
@@ -329,9 +343,9 @@ def _extended_completion(self, proposal):
329343 def _conv (self , obj ):
330344 if isinstance (obj , dict ):
331345 return u'{' + u',' .join ([
332- u"%s:%s" % (self ._conv (key ), self ._conv (value ))
346+ u"{0}:{1}" . format (self ._conv (key ), self ._conv (value ))
333347 for key , value in obj .iteritems ()]) + u'}'
334- return u'"%s"' % str (obj ).replace (u'"' , u'\\ "' )
348+ return u'"{0}"' . format ( str (obj ).replace (u'"' , u'\\ "' ) )
335349
336350
337351def _vim_name (name ):
@@ -345,19 +359,21 @@ class VimProgress(object):
345359 def __init__ (self , name ):
346360 self .name = name
347361 self .last = 0
348- status ('%s ... ' % self .name )
362+ status ('{0} ... ' . format ( self .name ) )
349363
350364 def update (self , percent ):
351365 try :
352366 vim .eval ('getchar(0)' )
353367 except vim .error :
354- raise KeyboardInterrupt ('Task %s was interrupted!' % self .name )
368+ raise KeyboardInterrupt (
369+ 'Task {0} was interrupted!' .format (self .name )
370+ )
355371 if percent > self .last + 4 :
356- status ('%s ... %s%%' % (self .name , percent ))
372+ status ('{0} ... {1}%' . format (self .name , percent ))
357373 self .last = percent
358374
359375 def done (self ):
360- status ('%s ... done' % self .name )
376+ status ('{0} ... done' . format ( self .name ) )
361377
362378
363379def echo (message ):
@@ -369,7 +385,7 @@ def echo(message):
369385def status (message ):
370386 if isinstance (message , unicode ):
371387 message = message .encode (vim .eval ('&encoding' ))
372- vim .command ('redraw | echon "%s"' % message )
388+ vim .command ('redraw | echon "{0}"' . format ( message ) )
373389
374390
375391def call (command ):
@@ -396,7 +412,7 @@ def __call__(self, arg_lead, cmd_line, cursor_pos):
396412 else :
397413 result = [proposal for proposal in self .values
398414 if proposal .startswith (arg_lead )]
399- vim .command ('let s:completions = %s' % result )
415+ vim .command ('let s:completions = {0}' . format ( result ) )
400416
401417
402418class RopeMode (interface .RopeMode ):
0 commit comments