[bzrweb PATCH] look up repository descriptions in a config file
Chris McCormick
chris at mccormick.cx
Fri May 20 15:51:25 BST 2005
On Fri, May 20, 2005 at 09:35:24AM -0400, Sean Russell wrote:
>
> The provided example is an excellent reason why XML should be considered for
> this. I can easily imagine, six months from now, a proposal to add more
> information to the <author> section:
>
> <treedescription>
> ...
> <author>
> <email>...</email>
> <web>...</web>
> </author>
> </treedescription>
>
> Using XML will guarantee extensibility, and provides the ability to store
> hierarchical structure.
I agree that it's pointless having religious wars about what config
file format is best, but I do think that if you have to edit a config
file a lot by hand it is nice to have one that is easy to parse with the
human eye. That said, I don't want to make flames, so it's as a purely
academic exercise and with no hidden motives that I propose a method
for using ConfigParser in a manner that is extensible in a way that is
similar to an XML file:
---------------------------------------
[treedescription]
author: *myauthor
foo: bar
pants: 100
[myauthor]
email: dude at dudeland.org
web: http://awesomedude.org/
---------------------------------------
So your config parser instance would do something like this:
author = cfg.get("treedescription", "author")
if author[0] == "*":
authbits = cfg.options(author[1:])
You could easily write a superclass of ConfigParser that handled this
style of referencing elegantly.
Another example; later if you wanted to make 'web' more complicated your
entry would look like:
---------------------------------------
...
[author]
email: dude at dudeland.org
web: *myweb
[myweb]
http: http://awesomedude.org/
rss: http://awesomedude.org/blah/rss/
---------------------------------------
On the other hand, you present many other good reasons to use XML, even
if some people do find it annoying to edit by hand. I guess it comes
down to how people are going to edit the config files and what their
preference is.
Best regards,
Chris.
-------------------
chris at mccormick.cx
http://mccormick.cx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050520/f0d37d63/attachment.pgp
More information about the bazaar
mailing list