[bzrweb PATCH] look up repository descriptions in a config file

John A Meinel john at arbash-meinel.com
Sun May 22 14:15:45 BST 2005


Sean E. Russell wrote:
> On Saturday 21 May 2005 14:13, John A Meinel wrote:
> 
>>But that is quite a bit of overhead for a config file. I would argue for
>>a standard .ini style, with a mandatory version number, so whatever
>>changes with time can still be parsed.
> 
> 
> All other comments aside... "standard"?  Standard where?  I've never seen this 
> before.  What is this ".ini" you're talking about?
> 

Well, I can't say that the .ini format is truly standardized, but the
summary is that sections are denoted with [], and entries are key-value
pairs delimited with = or :. If an entry is long, it can be continued on
the next line by using whitespace.
A # character makes the rest of the line a comment (some also support ;
as a comment character).

I'm not saying that this is the best format, but it is a simple one that
people can understand and use easily.

Where I work, we wrote a parser for an ini-like format, which allows
nesting, variable substitution, meta-characters, and a few other things.
However, I wouldn't recommend that, since it is a custom solution.

XML is very good at some things, but the overhead for using it as a
configuration file is quite a bit.

Take, for example, Mac OS's plist format. Admittedly it does allow
nesting, but as a moderately simple example:
!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Major Version</key>
  <integer>1</integer>
  <key>Minor Version</key>
  <integer>1</integer>
  <key>Application Version</key>
  <string>3.0.1</string>
  <key>Tracks</key>
  <dict>
    <key>115</key>
    <dict>
      <key>Track ID</key>
      <integer>115</integer>
      <key>Name</key>
      <string>Baby Goes To Eleven</string>
      <key>Artist</key>
      <string>Superdrag</string>
      <key>Album</key>
      <string>Last Call For Vitriol</string>
      <key>Genre</key>
      <string>Alternative & Punk</string>
      <key>Kind</key>
...
</dict>
</plist>

Instead of this, you could use:

[Config]
Major Version = 1
Minor Version = 1
Application Version = 3.0.1
Tracks = 115

[Track 115]
ID = 115
Name = Baby Goes To Eleven
Artist = Superdrag
Album = Last Call For Vitriol
...

Now, this isn't the greatest example, but which one is easier to edit,
and add new information/customize. It is *really* hard to edit a plist
file without a plist editor.
Now, it's possible to come up with a better XML schema, but remember
that you can't have spaces in tag names, and case is discouraged.
<config>
  <version>1.1</version>
  <appversion>3.0.1</appversion>
</config>

This is still quite a bit to write, and easy to mess up. It is great for
on over-the-wire protocol, or a long-term-storage protocol, since the
text is self documenting, and errors are obvious. But for something that
a human has to edit (possibly often), it is pretty crappy.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050522/4157271e/attachment.pgp 


More information about the bazaar mailing list