Smart config file parsing

Cliff Wells cliff at develix.com
Wed Jun 11 15:11:30 PDT 2008


On Wed, 2008-06-11 at 11:03 +0100, Gustavo Niemeyer wrote:
> Cliff Wells wrote:
> > Looking at smart/channel.py, it appears that the config file is manually
> > parsed, despite the fact that it's just an RFC 822 (ini) file that could
> > be much more easily parsed by ConfigParser or equivalent.  
> > 
> > Is there a particular reason for this?   AFAIK, ConfigParser has been in
> > the Python standard library since at least 2.3, so portability shouldn't
> > be an issue.
> 
> Let me invert the question: is there a particular reason to
> use ConfigParser?
> 
> The whole channel parsing logic is done in a function of 18 lines, and
> that includes the application logic which does the actual processing
> of the channel turning it into a Channel instance, and verifying if
> the channel has a type.  I doubt using ConfigParser would be easier
> or simpler, and it'd be slower for sure.

For the same reasons you'd use any standard library feature: higher
expectation of code correctnesss due to a larger user base, reduction of
code in your application (even if it's only a few dozen lines), etc.
ConfigParser might be slower, but I doubt it would be significantly
slower (i.e. something an end-user would notice).  It's also worth
noting that an oft-requested feature (config variables) would also be
available as a bonus.

Regards,
Cliff





More information about the Smart mailing list