def getConfig( self, file, must_have ) : error = None config = ConfigReader( file ) does_not_have_sections = [] for section in must_have: if not config.hasSection( section ): does_not_have_sections.append( section ) if does_not_have_sections: error = "Error: Config file does not contain sections:- " + ", ".join( does_not_have_sections ) return config, error
def getConfig( self, config_file, must_have ) : # Add self.config so new config config can be added to old. config = ConfigReader(config_file, self.config, overwrite_sections=True) does_not_have_sections = [] for section in must_have: if len(section) > 0 and not config.hasSection( section ): print("section {0} not found".format(section)) does_not_have_sections.append( section ) if does_not_have_sections: error = "Error: Config file does not contain sections:- " + ", ".join( does_not_have_sections ) raise ValueError(error) self.config = config