[Python-Announce] cfgparse v01_00 released

David Fraser davidf at sjsoft.com
Tue Feb 1 02:49:57 EST 2005


Dan Gass wrote:
> I'm pleased to announce the initial release of cfgparse (V01_00)
>  
> Background
> -------------------------------------------------------------
> cfgparse is a more convenient, flexible, and powerful module for
> parsing configuration files than the standard library ConfigParser
> module. cfgparse uses a more declarative style modelled after the
> popular optparse standard library module.
> 
> cfgparse can optionally cooperate with the optparse module to provide
> coordination between command line and configuration file options. In
> addition, the cooperation can be used to allow the user to control
> features of the parser from the command line.

I like this, its really nice that it fits well with optparse.
I read through the docs, mostly it seems very logical, the following 
things stood out to me as not really fitting:

http://cfgparse.sourceforge.net/cfgparse-round-trip-set.html
It doesn't seem logical that in order to modify the option in the 
desired section correctly, you need to pass the config file in. The keys 
argument in the option itself should be able to determine this.

http://cfgparse.sourceforge.net/node24.html
The use of <b> and <v> for quoting seems obscure. Would it not be better 
to use pythonic triple-quoted strings?
On first glance they look like markup tags rather than multi-line 
continuations (particularly <b> looks like "bold").

The fact that lines without an equals sign are ignored seems a bit 
lenient ...

It also seems strange how different the structure is between the 
ini-style and the Python-style formats:
http://cfgparse.sourceforge.net/cfgparse-python.html

driver = 'ethernet'
path = { 'DEFAULT' : '192.168.0.99',
          'DEV0'    : '192.168.0.0',
          'DEV1'    : '192.168.0.1' }

Is equivalent to:

[DEFAULT]
driver = 'ethernet'
path = 192.168.0.99
[DEV0]
path = 192.168.0.0
[DEV1]
path = 192.168.0.1

I wonder whether it would be better to use Python classes to represent 
the same thing:

class DEFAULT:
   driver = 'ethernet'
   path = '192.168.0.99'

class DEV0(DEFAULT):
   path = '192.168.0.0'

class DEV1(DEFAULT):
   path = '192.168.0.1'

This seems to me to bear more logical structure resemblance to the 
ini-style format.

Otherwise really cool!

David



More information about the Python-list mailing list