|
From: Michael F. <fuz...@vo...> - 2010-08-29 20:05:12
|
On 27/08/2010 10:47, Tom wrote: > Hi, > > want i want is a configobj only with the spec. Then i want to use this > object to validate a simple dict and i want to use the same configobj > ever time i have to validate a dict. > Actually i create a new configobj every time i want to validate a dict. > That's very slow. I can imagine. > How can i do this? > Did you try my suggestion of reading the configspec into a ConfigObj instance (once) and then using the validate library directly to do your validation? All the best, Michael Foord > Cheers, > > Tom > > On Wed, 2010-08-25 at 21:26 +0300, Michael Foord wrote: >> On 25/08/2010 09:47, Tom wrote: >>> Hi, >>> >>> i have a configspec with about 200 lines and validate a simple dict with >>> about 5 key/value pairs. >>> >>> For validation of the dict, i create a new config-obj with the config >>> spec (and copy=True), merge the dict into the new config and run the >>> validate() method. >>> But this is very slow (on an embedded device (400 Mhz)). How can i speed >>> up this process? Is it possible to validate only the dict without all >>> the other stuff? >> You could use the validate library directly. ConfigObj will attempt to >> validate against the whole configspec, but you could pull the keys out >> of the configspec / dict and only validate against rules you actually >> need (I assume this is your intent?). >> >> The documentation for validate can be found at: >> >> http://www.voidspace.org.uk/python/validate.html >> >> You may first need to read your configspec into a ConfigObj instance. >> The correct way to do this is: >> >> from configobj import ConfigObj >> spec = ConfigObj(filename, list_values=False, _inspec=True) >> >> HTH. >> >> All the best, >> >> Michael Foord >> >>> Cheers, >>> >>> Tom >>> >>> >>> ------------------------------------------------------------------------------ >>> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program >>> Be part of this innovative community and reach millions of netbook users >>> worldwide. Take advantage of special opportunities to increase revenue and >>> speed time-to-market. Join now, and jumpstart your future. >>> http://p.sf.net/sfu/intel-atom-d2d >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop -- http://www.ironpythoninaction.com/ |