Write option id into driver implementation section when saving the sics_config.ini
This commit is contained in:
@@ -43,6 +43,10 @@ class InstConfigData:
|
||||
# {optype: [impname] }
|
||||
imp_dict = defaultdict(list)
|
||||
|
||||
# imp2opt_dict: Maps each implementation to an option or None,
|
||||
# {imp: opt/None}
|
||||
imp2opt_dict = {}
|
||||
|
||||
def __init__(self):
|
||||
return
|
||||
|
||||
@@ -77,16 +81,28 @@ 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
|
||||
|
||||
self.opt_dict[s]['enabled'] = stateval
|
||||
self.opt_dict[s]['permanent'] = permanent
|
||||
self.opt_dict[s]['imptype'] = imptype
|
||||
self.opt_dict[s]['selected_imp'] = selected_imp
|
||||
if selected_imp in self.imp2opt_dict:
|
||||
self.opt_dict[s]['selected_imp'] = "none"
|
||||
else:
|
||||
self.opt_dict[s]['selected_imp'] = selected_imp
|
||||
print 'Add imp2opt_dict[{0}] = {1}'.format(selected_imp,s)
|
||||
self.imp2opt_dict[selected_imp] = s
|
||||
|
||||
def __get_implementations(self):
|
||||
for s in self.file_parser.sections():
|
||||
if self.file_parser.has_option(s, 'imptype'):
|
||||
key = self.file_parser.get(s, 'imptype')
|
||||
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"
|
||||
|
||||
def read_config_file(self, config_filename):
|
||||
self.config_filename = config_filename
|
||||
@@ -111,17 +127,25 @@ class InstConfigData:
|
||||
enabled = 'Always'
|
||||
else:
|
||||
enabled = dict['enabled'].__str__()
|
||||
|
||||
self.file_parser.set(item, 'enabled', enabled)
|
||||
self.file_parser.set(item, 'implementation', dict['selected_imp'])
|
||||
self.file_parser.set(item, 'optype', dict['imptype'])
|
||||
|
||||
for item,dict in self.configuration_dict.iteritems():
|
||||
enabled = dict['enabled'].__str__()
|
||||
self.file_parser.set(item, 'enabled', enabled)
|
||||
|
||||
for imp,opt in self.imp2opt_dict.iteritems():
|
||||
if imp != 'none' and 'id' in self.opt_dict[opt]:
|
||||
self.file_parser.set(imp, 'id', self.opt_dict[opt]['id'])
|
||||
|
||||
with open(self.config_filename,'w') as cfile:
|
||||
for section in sorted(self.file_parser.sections()):
|
||||
cfile.write("[%s]\n" % section)
|
||||
for option in sorted(self.file_parser.options(section)):
|
||||
cfile.write("%s = %s\n" % (option, self.file_parser.get(section, option)))
|
||||
|
||||
cfile.write("\n")
|
||||
#self.file_parser.write(cfile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user