python - ConfigParser with multiple sections and same option names? -


i configparser working seems simple problem have ancient 2.2 jython system (that cannot updated).

i loop through sections in config file , use same operation on values. first section reads fine on second iteration of loop getting "exceptions.attributeerror".

[default] uhome=/opt/app/myapp/configs  [domains] domainlist=dom1,dom2  [dom1] userconfigfile=idm-jit.config userkeyfile=idm-jit.key admu=http://idmap01xj:7001  [dom2] userconfigfile=iam-jit.config userkeyfile=iam-jit.key admu=http://idmap01xjvip:7003 

my (greatly) simplified script:

import configparser config = configparser.configparser()  try:     config.optionxform = str     config.read(domainconfigfile);      domainlist = config.get("domains","domainlist")     domainnames = domainlist.split(",")      dname in domainnames:         ucf = config.get(dname,"uhome") + '/'+config.get(dname,"userconfigfile")         ukf = config.get(dname,"uhome") + '/'+config.get(dname,"userkeyfile")         admu = config.get(dname,"admu")          print "ucf=["+ucf+"] ukf=["+ukf+"] admu=["+admu+"]" except:     print "error occurred" 

i'm not fluent in python yet (but problem making me so). have been researching similar problems , playing snippets modify dict, , work in stock python 2.6 interpreter fail miserably in jython 2.2.6. how can fake same key names in different sections addressable?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -