Make sure all instance attributes are defined in __init__ methods.
Also play with named arguments that don't define a default value (**kwargs)
This commit is contained in:
@ -198,6 +198,8 @@ class InstConfigData:
|
|||||||
msg_index = 4
|
msg_index = 4
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.file_parser = ConfigParser.SafeConfigParser()
|
||||||
|
self.config_filename = 'sics_config.ini'
|
||||||
#configuration_dict: dict of instrument configurations as defined below,
|
#configuration_dict: dict of instrument configurations as defined below,
|
||||||
# {configname: {'enabled':T/F, 'cascade_list':[(option, dflt_imp)]} }
|
# {configname: {'enabled':T/F, 'cascade_list':[(option, dflt_imp)]} }
|
||||||
self.configuration_dict = defaultdict(dict)
|
self.configuration_dict = defaultdict(dict)
|
||||||
@ -287,11 +289,11 @@ class InstConfigData:
|
|||||||
print 'Add imp2opt_dict[{0}] = none'.format(sect)
|
print 'Add imp2opt_dict[{0}] = none'.format(sect)
|
||||||
self.imp2opt_dict[sect] = 'none'
|
self.imp2opt_dict[sect] = 'none'
|
||||||
|
|
||||||
def read_config_file(self, config_filename):
|
def read_config_file(self, **kwargs):
|
||||||
""" Load and parse a sics_config.ini file """
|
""" Load and parse a sics_config.ini file """
|
||||||
self.config_filename = config_filename
|
if 'config_filename' in kwargs:
|
||||||
self.file_parser = ConfigParser.SafeConfigParser()
|
self.config_filename = kwargs['config_filename']
|
||||||
self.file_parser.read(config_filename)
|
self.file_parser.read(self.config_filename)
|
||||||
self.__get_options()
|
self.__get_options()
|
||||||
self.__get_implementations()
|
self.__get_implementations()
|
||||||
self.__get_configurations()
|
self.__get_configurations()
|
||||||
@ -317,7 +319,8 @@ class InstConfigData:
|
|||||||
enabled = opt_desc['enabled'].__str__()
|
enabled = opt_desc['enabled'].__str__()
|
||||||
|
|
||||||
self.file_parser.set(opt, 'enabled', enabled)
|
self.file_parser.set(opt, 'enabled', enabled)
|
||||||
self.file_parser.set(opt, 'implementation', opt_desc['selected_imp'])
|
self.file_parser.set(opt, 'implementation',
|
||||||
|
opt_desc['selected_imp'])
|
||||||
self.file_parser.set(opt, 'optype', opt_desc['imptype'])
|
self.file_parser.set(opt, 'optype', opt_desc['imptype'])
|
||||||
|
|
||||||
for config, config_desc in self.configuration_dict.iteritems():
|
for config, config_desc in self.configuration_dict.iteritems():
|
||||||
@ -593,7 +596,7 @@ def main(config_ini):
|
|||||||
|
|
||||||
# Make configuration data
|
# Make configuration data
|
||||||
cf_dat = InstConfigData()
|
cf_dat = InstConfigData()
|
||||||
cf_dat.read_config_file(config_ini)
|
cf_dat.read_config_file(config_filename = config_ini)
|
||||||
|
|
||||||
# Make configuration editor
|
# Make configuration editor
|
||||||
cf_man = InstConfigManager(cf_dat)
|
cf_man = InstConfigManager(cf_dat)
|
||||||
|
Reference in New Issue
Block a user