The implementation field is set only if an option is enabled in the config file.

All other options should be shown as disabled with 'none' as the implementation.
Conflicts between enabled options are resolved in favour of the first option returned
by the ConfigParser which isn't necessarily the first enabled option in the file.
Only enabled options are mapped in the imp2opt_dict dictionary.
This commit is contained in:
Ferdi Franceschini
2014-07-08 17:57:45 +10:00
parent cd80f567fe
commit cc6634abe9

View File

@ -266,17 +266,20 @@ class InstConfigData(object):
_id = self.file_parser.get(sect, 'id')
self.opt_dict[sect]['id'] = _id
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[sect]['selected_imp'] = 'none'
else:
self.opt_dict[sect]['selected_imp'] = selected_imp
if selected_imp != 'none':
print 'Add imp2opt_dict[{0}]={1}'.format(
selected_imp, sect)
if stateval == True:
if selected_imp == 'none' or (selected_imp in self.imp2opt_dict):
self.opt_dict[sect]['enabled'] = False
self.opt_dict[sect]['selected_imp'] = 'none'
else:
self.opt_dict[sect]['enabled'] = True
self.opt_dict[sect]['selected_imp'] = selected_imp
self.imp2opt_dict[selected_imp] = sect
print 'Add imp2opt_dict[{0}] = {1}'.format(selected_imp, sect)
else:
self.opt_dict[sect]['enabled'] = False
self.opt_dict[sect]['selected_imp'] = 'none'
def __get_implementations(self):
"""Parse implementation lists from INI file into imp_dict attribute of
@ -285,13 +288,13 @@ class InstConfigData(object):
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(sect)
if 'none' not in self.imp_dict[key]:
self.imp_dict[key].insert(0, 'none')
if sect not in self.imp2opt_dict:
print 'Add imp2opt_dict[{0}] = none'.format(sect)
self.imp2opt_dict[sect] = 'none'
print 'Add imp2opt_dict[{0}] = none'.format(sect)
def read_config_file(self, **kwargs):
""" Load and parse a sics_config.ini file """