By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

Comments in configuration files

P: n/a
Bonjour,

I am developing an application and I have a configuration file with a
lot of comments to help the application users understand what the
options mean

I would like it to be editable, through a web browser or a GUI
application. With ConfigParser I can read the configuration file and
edit the options, but when I write the result all the comments are lost

Are there modules that work on the same kind of ini files (for the needs
of my application, I prefer this format to XML or YAML) and don't remove
the comments ?

TIA,
Pierre
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Pierre Quentel wrote:
Bonjour,

I am developing an application and I have a configuration file with a
lot of comments to help the application users understand what the
options mean

I would like it to be editable, through a web browser or a GUI
application. With ConfigParser I can read the configuration file and
edit the options, but when I write the result all the comments are lost

Are there modules that work on the same kind of ini files (for the needs
of my application, I prefer this format to XML or YAML) and don't remove
the comments ?

TIA,
Pierre

The latest incarnation of 'tconfpy' I just released will get you close:

http://www.tundraware.com/Software/tconfpy

This program can read a configuration either from memory (a list) or a file.
So you could:

1) Read the file into an in-memory list (including the comments).

2) Pass the list to the parser, which would return a populated symbol
table.

3) Use your application to read the current values of the symbols from
the symbol table.

4) Modify the values in the symbol table as desired.

5) Map the new values in the symbol table back into the original list where
the values were set intitially (this is the part that would take some work).

6) Write the list back to disk.

Note that the semantics of feature of 'tconfpy' are substantially different
than 'ConfigParser', and the languages recognized by each are quite different
as well. It is probably fair to say that 'tconfpy' recognizes a superset
of the language recognized by 'ConfigParser'. But you have to be
careful because the semantics are somewhat different.

--
----------------------------------------------------------------------------
Tim Daneliuk tu****@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.