rendered paste bodyimport string
profileFile = open("./file.conf","r")
profileText = profileFile.read()
profilesList = []
profileFileLines = profileText.splitlines()
def makePropDict(propertiesLine):
fields = propertiesLine.split("|")
print fields, "****"
resultDict = {1: {"name" : fields[0] },
2: {"name" : fields[0],"type" : fields[1] },
3: {"name" : fields[0],"type" : fields[1],"defval" : fields[-1] } }[len(fields)]
print "----------", resultDict
return resultDict
for line in profileFileLines:
if(line.startswith("#")!=True):
if(line.startswith("[")):
thisProfileDict = {"name" : line.strip("[")}
elif(line.endswith("]") != True):
thisProfileDict[line.split("|")[0]] = makePropDict(line)
else:
profilesList.append(thisProfileDict)
thisProfileDict={}
print profilesList