""" @file alg_settings.py @brief extracts settings for a particular section. @par History - Brian Helgans, Dec 11 2019, initial version """ import configparser import os import Sample_Execution.exceptions def get_settings(settings, section): ''' reads in the settings file and prepares the run settings accordingly :param settings: the settings file :type settings: str :param section: section of the settings file. :type section: str ''' if not os.path.isfile(settings): raise Sample_Execution.exceptions.UserInputException('settings file '+settings+' does NOT exist.') try: parser = configparser.ConfigParser(empty_lines_in_values=False, inline_comment_prefixes="##<") parser.optionxform = str parser.read(settings) my_dict = dict(parser.items(section)) except Exception as e: raise Sample_Execution.exceptions.UserInputException("error reading the setttings file: '"+settings+"'. "+e.message) return my_dict