## ## # # A set of utility functions for dealing with configuration files. # # # # SOFTWARE HISTORY # # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 09/27/10 dgilling Initial Creation. # # # def parseKeyValueFile(fileName): propDict= dict() try: propFile= open(fileName, "rU") for propLine in propFile: propDef= propLine.strip() if len(propDef) == 0: continue if propDef[0] in ( '#' ): continue punctuation= [ propDef.find(c) for c in ':= ' ] + [ len(propDef) ] found= min( [ pos for pos in punctuation if pos != -1 ] ) name= propDef[:found].rstrip() value= propDef[found:].lstrip(":= ").rstrip() propDict[name]= value propFile.close() except: pass return propDict