Comments in configuration files

P

Pierre Quentel

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
 
T

Tim Daneliuk

Pierre said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top