Skip to content

Instantly share code, notes, and snippets.

@guestl
Created February 23, 2017 16:18
Show Gist options
  • Select an option

  • Save guestl/40ca381ed1aad93cfd9948799d3d066e to your computer and use it in GitHub Desktop.

Select an option

Save guestl/40ca381ed1aad93cfd9948799d3d066e to your computer and use it in GitHub Desktop.
read config file
def get_parms_from_conf_file(conf_file_name, default_parms):
config = configparser.ConfigParser()
try:
config.read(conf_file_name)
except Exception as e:
print("Error reading {} file".format(conf_file_name))
logging.error("Error reading %s file" % conf_file_name)
raise e
try:
default_parms['ext'] = config['USER_SETTINGS']['Extensions'].split(',')
except Exception as e:
pass
try:
default_parms['out_fn'] = config['USER_SETTINGS']['Out_file_name']
except Exception as e:
pass
try:
default_parms['cdl_fn'] = config['USER_SETTINGS']['FileWithDirectoryList']
except Exception as e:
logging.error("Error reading params in %s file" % conf_file_name)
pass
try:
default_parms['dir_list'] = config['USER_SETTINGS']['DirectoryListForScan'].split(',')
except Exception as e:
logging.error("Error reading params in %s file" % conf_file_name)
pass
return default_parms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment