Reduce pylint noise and remove unused variable imp_lw

This commit is contained in:
Ferdi Franceschini
2014-07-06 10:13:40 +10:00
parent 7eaa8242bd
commit 13c837d9b5

View File

@ -56,10 +56,10 @@ class RadioButtonListWalker(urwid.SimpleListWalker):
mapped_rb_list = [] mapped_rb_list = []
self.button_dict = {} self.button_dict = {}
for item, stateval in item_states: for item, stateval in item_states:
rb = urwid.RadioButton( radio_grp, item, state=stateval, _rb = urwid.RadioButton( radio_grp, item, state=stateval,
on_state_change=on_state_change, user_data=user_data ) on_state_change=on_state_change, user_data=user_data )
self.button_dict[item] = rb self.button_dict[item] = _rb
mapped_rb = urwid.AttrMap(rb, 'body', 'focus') mapped_rb = urwid.AttrMap(_rb, 'body', 'focus')
mapped_rb_list.append(mapped_rb) mapped_rb_list.append(mapped_rb)
super(RadioButtonListWalker, self).__init__(mapped_rb_list) super(RadioButtonListWalker, self).__init__(mapped_rb_list)
@ -83,11 +83,11 @@ class CheckBoxListWalker(urwid.SimpleListWalker):
mapped_cb_list = [] mapped_cb_list = []
self.button_dict = {} self.button_dict = {}
for item, stateval in item_states: for item, stateval in item_states:
cb = urwid.CheckBox( item, state = stateval, _cb = urwid.CheckBox( item, state = stateval,
on_state_change = on_state_change, on_state_change = on_state_change,
user_data = user_data ) user_data = user_data )
self.button_dict[item] = cb self.button_dict[item] = _cb
mapped_cb = urwid.AttrMap(cb, 'body', 'focus') mapped_cb = urwid.AttrMap(_cb, 'body', 'focus')
mapped_cb_list.append(mapped_cb) mapped_cb_list.append(mapped_cb)
super(CheckBoxListWalker, self).__init__(mapped_cb_list) super(CheckBoxListWalker, self).__init__(mapped_cb_list)
@ -133,8 +133,8 @@ class ClosedListBox(urwid.ListBox):
"""Override keypress to limit navigation to within listbox. """Override keypress to limit navigation to within listbox.
""" """
pos = self.get_focus()[1] pos = self.get_focus()[1]
ll = len(self.body) _ll = len(self.body)
if (pos <= 0 and key == 'up') or (pos >= ll-1 and key == 'down'): if (pos <= 0 and key == 'up') or (pos >= _ll-1 and key == 'down'):
return return
else: else:
return super(ClosedListBox, self).keypress(size, key) return super(ClosedListBox, self).keypress(size, key)
@ -207,11 +207,11 @@ class InstConfigData:
"""Parse instrument configuration definitions from INI file into """Parse instrument configuration definitions from INI file into
configuration_dict attribute of InstConfigData object configuration_dict attribute of InstConfigData object
""" """
for s in self.file_parser.sections(): for sect in self.file_parser.sections():
cascade_list = [] cascade_list = []
if self.file_parser.has_option(s, 'cascade'): if self.file_parser.has_option(sect, 'cascade'):
enabled = self.file_parser.get(s, 'enabled') enabled = self.file_parser.get(sect, 'enabled')
for cascade_str in self.file_parser.get(s, for cascade_str in self.file_parser.get(sect,
'cascade').split(','): 'cascade').split(','):
cascade_list.append(tuple(cascade_str.split(':'))) cascade_list.append(tuple(cascade_str.split(':')))
if enabled.lower() in ['true', 'always']: if enabled.lower() in ['true', 'always']:
@ -219,18 +219,18 @@ class InstConfigData:
else: else:
stateval = False stateval = False
self.configuration_dict[s]['enabled'] = stateval self.configuration_dict[sect]['enabled'] = stateval
self.configuration_dict[s]['cascade_list'] = cascade_list self.configuration_dict[sect]['cascade_list'] = cascade_list
def __get_options(self): def __get_options(self):
"""Parse configuration options from INI file into opt_dict attribute of """Parse configuration options from INI file into opt_dict attribute of
InstConfigData object. InstConfigData object.
""" """
for s in self.file_parser.sections(): for sect in self.file_parser.sections():
if self.file_parser.has_option(s, 'implementation'): if self.file_parser.has_option(sect, 'implementation'):
selected_imp = self.file_parser.get(s, 'implementation') selected_imp = self.file_parser.get(sect, 'implementation')
imptype = self.file_parser.get(s, 'optype') imptype = self.file_parser.get(sect, 'optype')
enabled = self.file_parser.get(s, 'enabled').lower() enabled = self.file_parser.get(sect, 'enabled').lower()
if enabled == 'always': if enabled == 'always':
stateval = True stateval = True
permanent = True permanent = True
@ -241,36 +241,36 @@ class InstConfigData:
stateval = False stateval = False
permanent = False permanent = False
if self.file_parser.has_option(s, 'id'): if self.file_parser.has_option(sect, 'id'):
id = self.file_parser.get(s, 'id') _id = self.file_parser.get(sect, 'id')
self.opt_dict[s]['id'] = id self.opt_dict[sect]['id'] = _id
self.opt_dict[s]['enabled'] = stateval self.opt_dict[sect]['enabled'] = stateval
self.opt_dict[s]['permanent'] = permanent self.opt_dict[sect]['permanent'] = permanent
self.opt_dict[s]['imptype'] = imptype self.opt_dict[sect]['imptype'] = imptype
if selected_imp in self.imp2opt_dict: if selected_imp in self.imp2opt_dict:
self.opt_dict[s]['selected_imp'] = 'none' self.opt_dict[sect]['selected_imp'] = 'none'
else: else:
self.opt_dict[s]['selected_imp'] = selected_imp self.opt_dict[sect]['selected_imp'] = selected_imp
if selected_imp != 'none': if selected_imp != 'none':
print 'Add imp2opt_dict[{0}]={1}'.format( print 'Add imp2opt_dict[{0}]={1}'.format(
selected_imp, s) selected_imp, sect)
self.imp2opt_dict[selected_imp] = s self.imp2opt_dict[selected_imp] = sect
def __get_implementations(self): def __get_implementations(self):
"""Parse implementation lists from INI file into imp_dict attribute of """Parse implementation lists from INI file into imp_dict attribute of
InstConfigData object. InstConfigData object.
""" """
for s in self.file_parser.sections(): for sect in self.file_parser.sections():
if self.file_parser.has_option(s, 'imptype'): if self.file_parser.has_option(sect, 'imptype'):
key = self.file_parser.get(s, 'imptype') key = self.file_parser.get(sect, 'imptype')
if 'none' not in self.imp_dict[key]: if 'none' not in self.imp_dict[key]:
self.imp_dict[key].append('none') self.imp_dict[key].append('none')
self.imp_dict[key].append(s) self.imp_dict[key].append(sect)
if s not in self.imp2opt_dict: if sect not in self.imp2opt_dict:
print 'Add imp2opt_dict[{0}] = none'.format(s) print 'Add imp2opt_dict[{0}] = none'.format(sect)
self.imp2opt_dict[s] = 'none' self.imp2opt_dict[sect] = 'none'
def read_config_file(self, config_filename): def read_config_file(self, config_filename):
""" Load and parse a sics_config.ini file """ """ Load and parse a sics_config.ini file """
@ -375,13 +375,13 @@ class InstConfigView(urwid.Pile):
""" """
self.cf_dat = cf_dat self.cf_dat = cf_dat
self.cf_man = cf_man self.cf_man = cf_man
option_ListBoxes = [ option_listboxes = [
self.cf_man.config_lb, self.cf_man.config_lb,
self.cf_man.opt_lb, self.cf_man.opt_lb,
self.cf_man.imp_lb, self.cf_man.imp_lb,
dbmsg] dbmsg]
super(InstConfigView, self).__init__(option_ListBoxes) super(InstConfigView, self).__init__(option_listboxes)
return return
def keyinput(self, key): def keyinput(self, key):
@ -494,7 +494,6 @@ class InstConfigManager:
for opt, imp in cascade: for opt, imp in cascade:
self.cf_dat.set_imp(opt, imp) self.cf_dat.set_imp(opt, imp)
self.opt_lw.button_dict[opt].set_state(True) self.opt_lw.button_dict[opt].set_state(True)
imp_lw = self.__gen_imp_listwalker(opt)
for opt in self.cf_dat.opt_dict.keys(): for opt in self.cf_dat.opt_dict.keys():
if self.cf_dat.opt_dict[opt]['permanent'] == True: if self.cf_dat.opt_dict[opt]['permanent'] == True:
@ -559,10 +558,10 @@ class DEBUG:
def __init__(self, enabled=False): def __init__(self, enabled=False):
self.enabled = enabled self.enabled = enabled
if enabled: if enabled:
for msgID in self.msg_ids: for msg_id in self.msg_ids:
msgText = urwid.Text(u'Space for message {0}'.format(msgID)) msg_text = urwid.Text(u'Space for message {0}'.format(msg_id))
self.msgTextDict[msgID] = msgText self.msgTextDict[msg_id] = msg_text
self.msglist.append(urwid.AttrMap(msgText, 'body', 'focus')) self.msglist.append(urwid.AttrMap(msg_text, 'body', 'focus'))
mlw = urwid.SimpleListWalker(self.msglist) mlw = urwid.SimpleListWalker(self.msglist)
self.mlb = urwid.ListBox(mlw) self.mlb = urwid.ListBox(mlw)