|
From: <fuz...@vo...> - 2006-01-28 10:56:55
|
{emo;drive} `ConfigObj </python/configobj.html>`_ has also been spotted in the wild in a few interesting situations. Open Source projects that I've seen using it now include :
* `Bazaar <http://bazaar-ng.org>`_.
Bazaar is *the* Python distributed {acro;VCS;Version Control System}.
ConfigObj is used to read ``bazaar.conf`` and ``branches.conf``.
* `Planet Plus <http://planetplus.python-hosting.com/>`_
A new web application version of `Planet <http://www.planetplanet.org/>`_,
the web aggregator.
* `NeuroImaging in Python <http://projects.scipy.org/neuroimaging/ni/wiki>`_
BrainSTAT is a project with the ultimate goal to produce a
platform-independent python environment for the analysis of brain
imaging data.
* `Gruik <http://www.tracos.org/gruik/wiki>`_
Gruik is a free software network packet sniffer.
This is cool because **ConfigObj** is my favourite project. Not only was it a lot of work, but I genuinely think it provides a simple interface to a lot of functionality. Some of these projects are also using the more advanced features of ConfigObj - like validation and the `walk <http://www.voidspace.org.uk/python/configobj.html#walking-a-section>`_ method.
It has occurred to me that the ConfigObj {acro;API;Application Programmers Interface} and syntax is *basically* compatible with `ConfigParser <http://docs.python.org/lib/module-ConfigParser.html>`_, which is the Python standard library.
Hence the terrible idea. {sm;:-o}
It would be a lot of work, but completely feasible, to implement a ``ConfigParser`` compatibility layer on top of ConfigObj. This could retain backwards compatibility with ConfigParser, but add all the ConfigObj features like nested-sections and list values. This would address a lot of the issues raised in the `ConfigParser Shootout <http://wiki.python.org/moin/ConfigParserShootout>`_.
So I've donned my flame-proof pants (foolhardy chap that I am) and suggested it on `python-dev <http://mail.python.org/mailman/listinfo/python-dev>`_.
I said something like :
In the past there has been some discussion about a new module to replace
ConfigParser. Most notably at
http://wiki.python.org/moin/ConfigParserShootout
Specific issues that could be addressed include :
* Simpler API
* Nested subsections
* List values
* Storing/converting datatypes
* Config file schema
* Keeps track of order of values
Plus other issues.
I'm the (co-)author of ConfigObj -
http://www.voidspace.org.uk/python/configobj.html
This is a reasonably mature project (now in it's fourth incarnation),
and is being used in projects like Bazaar_
and `Planet Plus`_.
It occurs to me that the ConfigObj API and syntax is *almost* fully
compatible with ConfigParser.
It would be possible to extend to the ConfigObj API to be backwards
compatible with ConfigParser. This would bring the added benefits of
ConfigObj, without needing to add an extra module to the standard library.
Well nearly. ConfigObj supports config file schema with (optional) type
conversion, through a companion module called `validate </python/validate.html>`_. This could be
included or left as an added option.
Anyway. If this stands a *chance* of acceptance, I'll write the {acro;PEP;Python Enhancement Proposal} (and if accepted, do the work - which is not inconsiderable).
Summary of ConfigObj
====================
ConfigObj is a Python 2.2 compatible config file parser. It's major
feature is simplicity of use.
It reads (and writes) INI file like config files and presents the
members using a dictionary interface.
The order of keys/sections is preserved, and it allows nested
subsections to any level :
e.g. ::
key = value
[section]
key = value
[[sub-section]]
key = value
It is fully documented with a barrage of doctests.
All comments in the config file are also preserved as attributes of the
object, and will be written back out. This can be useful for including
comments in programatically generated config files.
It is integrated with a powerful validation system.
Difficulties & Differences
==========================
A ConfigObj instance is a sub-class of the dictionary datatpe. This
means that the ``get`` method of ConfigParser clashes.
ConfigObj allows values in the root section (why not ?).
ConfigObj doesn't support line continuations (it does allow multi-line
values through the use of triple quoted strings).
ConfigObj currently only allows '``=``' as a valid divider.
Creating ConfigParser (and related classes) compatibility is a big job.
Solution
========
All of these problems (if deemed necessary) can be resolved. Either
through options, or just by extending the ConfigObj API. I'm happy to
put the work in.
Comments ?
.. note::
I've had no reply to this suggestion on the **Python-Dev** list. However I have had some feedback from the **Bazaar** team on improvements I could make in this direction. |