Commit 5ab9ef44 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

remove quote marks surrounding strings in configfile

parent d3ec33c7
Pipeline #62509 passed with stages
in 6 minutes and 8 seconds
......@@ -193,28 +193,55 @@ def perc_id(param):
class Conf_all_parser(configparser.ConfigParser):
Read configfile and return arguments found, according to required type
conffile : str
path to configuration file
readsec : list
list of sections of the config file to read
conffile : str
Path to configfile
sec_dicts : dict
{section1: {param: value}, {section2: {param:value}}}
def __init__(self, conffile, readsec=[]):
# If there is a config file specified, but it does not exist -> exit with error message
if conffile != "" and not os.path.isfile(conffile):
print(f"Error: config file {conffile} not found.")
self.conffile = conffile
# Read the config file
except configparser.DuplicateOptionError as err:
self.sec_dicts = {}
# Convert configfile sections to dicts
for sec in readsec:
# If section in configfile, put its arguments and values to a dict
# If not, create empty section, and associate with empty dict
if sec in dict(self):
self.sec_dicts[sec] = dict(self[sec])
self.sec_dicts[sec] = {}
def clean_strings(self, section):
Remove quote marks surrounding strings
for param in self.sec_dicts[section]:
initial = self.sec_dicts[section][param]
self.sec_dicts[section][param] = initial.strip('"')
def get_section_dict(self, section):
get dictionary of values for 'section' section
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment