|
From: Marc T. <mar...@gm...> - 2008-06-20 01:25:44
|
Hi all - I hope this is not a horribly stupid question... I'm setting up my configspec thusly: > tmpStr = """[Current] > npiXMLFile = string(default="npiMap.XML") > InHist = string_list(default=None) > OutHist = string_list(default=None) > Submitter = string(default=None) > Carrier = string(default=None) > MainSize = tuple() > MainPos = tuple() > SummarySize = tuple() > SummaryPos = tuple() > ConfirmSuccess = boolean(default=True) > CvtCarrier = boolean(default=False) > KeepLicense = boolean(default=False) > KeepInsID = boolean(default=False) > KeepTaxID = boolean(default=True) > KeepUxIN = boolean(default=True) > KeepFacID = boolean(default=False) > UseSecID = boolean(default=False) > FixSSN = boolean(default=True) > DNtoDQ = boolean(default=False) > [JobProfiles] > [[__many__]] > Submitter = string(default=" ") > Carrier = string(default=" ") > CvtCarrier = boolean(default=False) > KeepLicense = boolean(default=False) > KeepInsID = boolean(default=False) > KeepTaxID = boolean(default=True) > KeepUxIN = boolean(default=True) > KeepFacID = boolean(default=False) > UseSecID = boolean(default=False) > FixSSN = boolean(default=True) > DNtoDQ = boolean(default=False) > InFile = string(default="") > OutFile = string(default="") > """ > cfgSpec = StringIO.StringIO(tmpStr) > cfgFile = ConfigObj(cfgFileName, > configspec=cfgSpec, raise_errors=True, write_empty_values = > True, > create_empty=True, indent_type=' ', list_values = True) > vtor = Validator() > and validating it thusly: > test = cfgFile.validate(vtor, copy=True) > cfgFile.write() > My actual ini file looks like so: > [Current] > npiXMLFile = file:///E:/ultrahld/npiMap.xml > Submitter = 1234567 > Carrier = ColoradoMedicare > ConfirmSuccess = True > KeepLicense = False > KeepInsID = False > KeepTaxID = True > KeepUxIN = False > KeepFacID = False > UseSecID = True > FixSSN = True > DNtoDQ = False > InHist = E:\ultrahld\MCARE06.837, E:\ultrahld\MCARE04.837, > E:\bbs\out.837 > OutHist = E:\bbs\out.837, E:\bbs\MCAL03.NPI > CvtCarrier = True > [JobProfiles] > [[Bogus]] > Submitter = 8675309 > Carrier = NHIC > CvtCarrier = False > KeepLicense = False > KeepInsID = False > KeepTaxID = True > KeepUxIN = True > KeepFacID = False > UseSecID = False > FixSSN = True > DNtoDQ = False > InFile = E:\ultrahld\MCARE04.837 > OutFile = E:\bbs\out.837 > [[ReallyBogus]] > Submitter = 345678 > Carrier = NHIC > CvtCarrier = False > KeepLicense = False > KeepInsID = False > KeepTaxID = True > KeepUxIN = True > KeepFacID = False > UseSecID = False > FixSSN = True > DNtoDQ = False > InFile = E:\ultrahld\MCARE03.837 > OutFile = E:\bbs\out.837 > If I cut the file short after [JobProfiles], all is well, but if I include [[Bogus]] or [[ReallyBogus]] the validation blows up with the following: Traceback (most recent call last): > File "E:\fsrPy\FSR-X12\fsr_x12.pyw", line 538, in <module> > main() > File "E:\fsrPy\FSR-X12\fsr_x12.pyw", line 530, in main > test = Global.cfgFile.validate(Global.vtor, copy=True) > File "c:\python25\lib\site-packages\configobj.py", line 2301, in validate > copy=copy, section=section[entry]) > File "c:\python25\lib\site-packages\configobj.py", line 2297, in validate > section.comments[entry] = section._cs_section_comments[entry] > KeyError: 'Bogus' > Script terminated. > I was poking around adding pprint() statements in configobj.py, and the problem seems to be that when "__many__" occurs in the configspec, no entries are created in section._cs_section_comments - which of course they wouldn't be, because we don't know what the subsection names are yet. I'm not actually using comments, and probably never will, so I suppose I could just rip out all of that... but there must be a better way, and I can't possibly be the only one who's run into this. However, I haven't seen it mentioned in the list archives, so I suspect I'm doing something wrong. What should I do? Windows XP Pro SP3 Python 2.5.1 wxPython 2.8.7.1 ConfigObj 4 -- www.fsrtechnologies.com |