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