def __parse_section(self, config): # ''' # Retrieve the subsections, recursively. # Internal purposes. # ''' # sectDict = {} # for key in config.keys(): # if type(config[key]) == type(dict()): # sectDict[key] = vmgSection(key, self.__parse_section(config[key])) # else: # sectDict[key] = config[key] # # return sectDict # ''' Retrieve the subsections, recursively. Internal purposes. ''' sectDict = {} for key in config.keys(): if type(config[key]) is str: sectDict[key] = config[key] else: sectDict[key] = vmgSection(key, self.__parse_section(config[key])) return sectDict
def parse(self): ''' Use the configObj library to parse the file. ''' config = ConfigObj(infile=self.infile, raise_errors=True, file_error=True) rootDict = {} for sect in config.keys(): rootDict[sect] = vmgSection(sect, self.__parse_section(config[sect])) self.struct = vmgStruct(rootDict)