|
From: Michael F. <fuz...@vo...> - 2010-08-13 18:52:40
|
On 13/08/2010 15:40, François wrote: > Le 13/08/2010 14:34, Michael Foord a écrit : > >> On 13/08/2010 13:29, François wrote: >> >>> Hi, >>> >>> I don't know if it is a bug or if I'm using the library in a wrong way >>> but I can pass successfully a configfile which is obviously wrong. >>> >>> >>> >> I think you are using validation incorrectly. Try printing the result of >> config.validate(Validator()) and I think you will see your mistake. >> >> Michael >> >> > You mean I have to make a for loop on the hash elements to be sure they > are all correct? > > > From the docs on the validate method: By default, the validate method either returns True (everything passed) or a dictionary of True / False representing pass/fail. The dictionary follows the structure of the ConfigObj. http://www.voidspace.org.uk/python/configobj.html#return-value So in the event of a validation fail you will get a dictionary of values telling you which one(s) failed. This is going to evaluate as True if you check it in an if statement. Instead you should do (something like): result = configobj.validate(Validator()) if result == True: # validation succeeded All the best, Michael Foord >>> here, the files: >>> cat monte.py >>> http://pastebin.com/2Z8JUHrH >>> cat choices.conf >>> http://pastebin.com/EstuqNhK >>> cat specs.conf >>> http://pastebin.com/EVhh6vfy >>> >>> _________________ >>> If choices.conf is >>> >>> [Pierre] >>> Lundi=r >>> >>> then it prints OOPS. >>> >>> >>> _________________ >>> If choices.conf is >>> >>> [Pierre] >>> Lundi=r >>> >>> [Paul] >>> Lundi=r >>> >>> >>> then it prints OOPS. >>> >>> >>> But if only one variable named Lundi is wrong, it prints 'OK' >>> >>> >>> Do you have any idea? I didn't any clue in the documentation, maybe I >>> missed an option... >>> >>> Regards, >>> Francois. >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by >>> >>> Make an app they can't live without >>> Enter the BlackBerry Developer Challenge >>> http://p.sf.net/sfu/RIM-dev2dev >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >>> >> > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer. |