1- #
21# The MIT License
32#
43# Copyright (c) 2010-2011 Marien Zwart
3837import signal
3938import urwid
4039
41- from pygments .token import Token
42-
4340from . import args as bpargs , repl , translations
4441from .formatter import theme_map
4542from .importcompletion import find_coroutine
4643from .translations import _
4744from .keys import urwid_key_dispatch as key_dispatch
4845
49- Parenthesis = Token .Punctuation .Parenthesis
50-
5146# Urwid colors are:
5247# 'black', 'dark red', 'dark green', 'brown', 'dark blue',
5348# 'dark magenta', 'dark cyan', 'light gray', 'dark gray',
@@ -147,22 +142,21 @@ class StatusbarEdit(urwid.Edit):
147142
148143 def __init__ (self , * args , ** kwargs ):
149144 self .single = False
150- urwid . Edit . __init__ (self , * args , ** kwargs )
145+ super (). __init__ (* args , ** kwargs )
151146
152147 def keypress (self , size , key ):
153148 if self .single :
154149 urwid .emit_signal (self , "prompt_enter" , self , key )
155150 elif key == "enter" :
156151 urwid .emit_signal (self , "prompt_enter" , self , self .get_edit_text ())
157152 else :
158- return urwid . Edit . keypress (self , size , key )
153+ return super (). keypress (size , key )
159154
160155
161156urwid .register_signal (StatusbarEdit , "prompt_enter" )
162157
163158
164159class Statusbar :
165-
166160 """Statusbar object, ripped off from bpython.cli.
167161
168162 This class provides the status bar at the bottom of the screen.
@@ -290,7 +284,6 @@ def format_tokens(tokensource):
290284
291285
292286class BPythonEdit (urwid .Edit ):
293-
294287 """Customized editor *very* tightly interwoven with URWIDRepl.
295288
296289 Changes include:
@@ -322,10 +315,10 @@ def __init__(self, config, *args, **kwargs):
322315 self ._bpy_may_move_cursor = False
323316 self .config = config
324317 self .tab_length = config .tab_length
325- urwid . Edit . __init__ (self , * args , ** kwargs )
318+ super (). __init__ (* args , ** kwargs )
326319
327320 def set_edit_pos (self , pos ):
328- urwid . Edit . set_edit_pos (self , pos )
321+ super (). set_edit_pos (pos )
329322 self ._emit ("edit-pos-changed" , self .edit_pos )
330323
331324 def get_edit_pos (self ):
@@ -366,25 +359,25 @@ def get_cursor_coords(self, *args, **kwargs):
366359 # urwid gets confused if a nonselectable widget has a cursor position.
367360 if not self ._bpy_selectable :
368361 return None
369- return urwid . Edit . get_cursor_coords (self , * args , ** kwargs )
362+ return super (). get_cursor_coords (* args , ** kwargs )
370363
371364 def render (self , size , focus = False ):
372365 # XXX I do not want to have to do this, but listbox gets confused
373366 # if I do not (getting None out of get_cursor_coords because
374367 # we just became unselectable, then having this render a cursor)
375368 if not self ._bpy_selectable :
376369 focus = False
377- return urwid . Edit . render (self , size , focus = focus )
370+ return super (). render (size , focus = focus )
378371
379372 def get_pref_col (self , size ):
380373 # Need to make this deal with us being nonselectable
381374 if not self ._bpy_selectable :
382375 return "left"
383- return urwid . Edit . get_pref_col (self , size )
376+ return super (). get_pref_col (size )
384377
385378 def move_cursor_to_coords (self , * args ):
386379 if self ._bpy_may_move_cursor :
387- return urwid . Edit . move_cursor_to_coords (self , * args )
380+ return super (). move_cursor_to_coords (* args )
388381 return False
389382
390383 def keypress (self , size , key ):
@@ -425,18 +418,18 @@ def keypress(self, size, key):
425418 if not (cpos or len (line ) % self .tab_length or line .strip ()):
426419 self .set_edit_text (line [: - self .tab_length ])
427420 else :
428- return urwid . Edit . keypress (self , size , key )
421+ return super (). keypress (size , key )
429422 else :
430423 # TODO: Add in specific keypress fetching code here
431- return urwid . Edit . keypress (self , size , key )
424+ return super (). keypress (size , key )
432425 return None
433426 finally :
434427 self ._bpy_may_move_cursor = False
435428
436429 def mouse_event (self , * args ):
437430 self ._bpy_may_move_cursor = True
438431 try :
439- return urwid . Edit . mouse_event (self , * args )
432+ return super (). mouse_event (* args )
440433 finally :
441434 self ._bpy_may_move_cursor = False
442435
@@ -453,7 +446,6 @@ def keypress(self, size, key):
453446
454447
455448class Tooltip (urwid .BoxWidget ):
456-
457449 """Container inspired by Overlay to position our tooltip.
458450
459451 bottom_w should be a BoxWidget.
@@ -466,7 +458,7 @@ class Tooltip(urwid.BoxWidget):
466458 """
467459
468460 def __init__ (self , bottom_w , listbox ):
469- self . __super .__init__ ()
461+ super () .__init__ ()
470462
471463 self .bottom_w = bottom_w
472464 self .listbox = listbox
@@ -534,7 +526,7 @@ def render(self, size, focus=False):
534526
535527class URWIDInteraction (repl .Interaction ):
536528 def __init__ (self , config , statusbar , frame ):
537- repl . Interaction . __init__ (self , config , statusbar )
529+ super (). __init__ (config , statusbar )
538530 self .frame = frame
539531 urwid .connect_signal (statusbar , "prompt_result" , self ._prompt_result )
540532 self .callback = None
@@ -577,7 +569,7 @@ class URWIDRepl(repl.Repl):
577569 _time_between_redraws = 0.05 # seconds
578570
579571 def __init__ (self , event_loop , palette , interpreter , config ):
580- repl . Repl . __init__ (self , interpreter , config )
572+ super (). __init__ (interpreter , config )
581573
582574 self ._redraw_handle = None
583575 self ._redraw_pending = False
0 commit comments