diff --git a/site_ansto/instrument/util/config_edit.py b/site_ansto/instrument/util/config_edit.py index c94e7d9a..98f5b96d 100755 --- a/site_ansto/instrument/util/config_edit.py +++ b/site_ansto/instrument/util/config_edit.py @@ -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 """