Fix some type inconsistencies
(pylint)
This commit is contained in:
parent
50d6edc30b
commit
2252f2779c
4 changed files with 21 additions and 19 deletions
|
@ -188,32 +188,32 @@ class CommandCore:
|
||||||
@command_args_parser.quoted(1)
|
@command_args_parser.quoted(1)
|
||||||
def win(self, args):
|
def win(self, args):
|
||||||
"""
|
"""
|
||||||
/win <number>
|
/win <number or name>
|
||||||
"""
|
"""
|
||||||
if args is None:
|
if args is None:
|
||||||
return self.help('win')
|
return self.help('win')
|
||||||
|
|
||||||
nb = args[0]
|
name = args[0]
|
||||||
try:
|
try:
|
||||||
nb = int(nb)
|
number = int(name)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
number = -1
|
||||||
if self.core.current_tab_nb == nb:
|
if number != -1 and self.core.current_tab_nb == number:
|
||||||
return
|
return
|
||||||
|
prev_nb = self.core.previous_tab_nb
|
||||||
self.core.previous_tab_nb = self.core.current_tab_nb
|
self.core.previous_tab_nb = self.core.current_tab_nb
|
||||||
old_tab = self.core.current_tab()
|
old_tab = self.core.current_tab()
|
||||||
if isinstance(nb, int):
|
if 0 <= number < len(self.core.tabs):
|
||||||
if 0 <= nb < len(self.core.tabs):
|
if not self.core.tabs[number]:
|
||||||
if not self.core.tabs[nb]:
|
self.core.previous_tab_nb = prev_nb
|
||||||
return
|
return
|
||||||
self.core.current_tab_nb = nb
|
self.core.current_tab_nb = number
|
||||||
else:
|
else:
|
||||||
matchs = []
|
matchs = []
|
||||||
for tab in self.core.tabs:
|
for tab in self.core.tabs:
|
||||||
for name in tab.matching_names():
|
for tab_name in tab.matching_names():
|
||||||
if nb.lower() in name[1].lower():
|
if name.lower() in tab_name[1].lower():
|
||||||
matchs.append((name[0], tab))
|
matchs.append((tab_name[0], tab))
|
||||||
self.core.current_tab_nb = tab.nb
|
|
||||||
if not matchs:
|
if not matchs:
|
||||||
return
|
return
|
||||||
tab = min(matchs, key=lambda m: m[0])[1]
|
tab = min(matchs, key=lambda m: m[0])[1]
|
||||||
|
|
|
@ -32,6 +32,7 @@ class ListTab(Tab):
|
||||||
"""
|
"""
|
||||||
Tab.__init__(self, core)
|
Tab.__init__(self, core)
|
||||||
self.state = 'normal'
|
self.state = 'normal'
|
||||||
|
self._error_message = ''
|
||||||
self.name = name
|
self.name = name
|
||||||
columns = collections.OrderedDict()
|
columns = collections.OrderedDict()
|
||||||
for col, num in cols:
|
for col, num in cols:
|
||||||
|
|
|
@ -14,7 +14,7 @@ from poezio.theming import to_curses_attr, get_theme
|
||||||
|
|
||||||
class FieldInput(object):
|
class FieldInput(object):
|
||||||
"""
|
"""
|
||||||
All input type in a data form should inherite this class,
|
All input types in a data form should inherit this class,
|
||||||
in addition with windows.Input or any relevant class from the
|
in addition with windows.Input or any relevant class from the
|
||||||
'windows' library.
|
'windows' library.
|
||||||
"""
|
"""
|
||||||
|
@ -124,8 +124,10 @@ class TextMultiWin(FieldInput, Win):
|
||||||
def __init__(self, field):
|
def __init__(self, field):
|
||||||
FieldInput.__init__(self, field)
|
FieldInput.__init__(self, field)
|
||||||
Win.__init__(self)
|
Win.__init__(self)
|
||||||
self.options = field.get_value()
|
options = field.get_value()
|
||||||
if not isinstance(self.options, list):
|
if isinstance(self.options, list):
|
||||||
|
self.options = options
|
||||||
|
else:
|
||||||
self.options = self.options.split('\n') if self.options else []
|
self.options = self.options.split('\n') if self.options else []
|
||||||
self.val_pos = 0
|
self.val_pos = 0
|
||||||
self.edition_input = None
|
self.edition_input = None
|
||||||
|
|
|
@ -563,6 +563,7 @@ class HistoryInput(Input):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Input.__init__(self)
|
Input.__init__(self)
|
||||||
self.help_message = ''
|
self.help_message = ''
|
||||||
|
self.histo_pos = -1
|
||||||
self.current_completed = ''
|
self.current_completed = ''
|
||||||
self.key_func['^R'] = self.toggle_search
|
self.key_func['^R'] = self.toggle_search
|
||||||
self.search = False
|
self.search = False
|
||||||
|
@ -647,7 +648,6 @@ class MessageInput(HistoryInput):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
HistoryInput.__init__(self)
|
HistoryInput.__init__(self)
|
||||||
self.last_completion = None
|
self.last_completion = None
|
||||||
self.histo_pos = -1
|
|
||||||
self.key_func["KEY_UP"] = self.key_up
|
self.key_func["KEY_UP"] = self.key_up
|
||||||
self.key_func["M-A"] = self.key_up
|
self.key_func["M-A"] = self.key_up
|
||||||
self.key_func["KEY_DOWN"] = self.key_down
|
self.key_func["KEY_DOWN"] = self.key_down
|
||||||
|
@ -702,7 +702,6 @@ class CommandInput(HistoryInput):
|
||||||
self.key_func["M-A"] = self.key_up
|
self.key_func["M-A"] = self.key_up
|
||||||
self.key_func["KEY_DOWN"] = self.key_down
|
self.key_func["KEY_DOWN"] = self.key_down
|
||||||
self.key_func["M-B"] = self.key_down
|
self.key_func["M-B"] = self.key_down
|
||||||
self.histo_pos = -1
|
|
||||||
|
|
||||||
def do_command(self, key, reset=True, raw=False):
|
def do_command(self, key, reset=True, raw=False):
|
||||||
res = Input.do_command(self, key, reset=reset, raw=raw)
|
res = Input.do_command(self, key, reset=reset, raw=raw)
|
||||||
|
|
Loading…
Reference in a new issue