Comments in the config file

Asked by Martin J.H.

Is there a way to add comments to the config file? I made my config file manually by using one of the examples given in "/usr/share/doc/backintime/examples" and by looking up what the lines mean in "man backintime-config". But I'm sure I'll forget most of my reasoning in a few days, unless I include some comments in the config file.

Question information

Language:
English Edit question
Status:
Answered
For:
Back In Time Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Martin J.H. (martinhoecker) said :
#1

After looking at the code for the function "append" in the file "common/configfile.py", my guess is that any line that does not contain exactly one '=' will be discarded:

        for line in lines:
            items = line.split( '=', maxsplit )
            if len( items ) == 2:
                self.dict[ items[ 0 ] ] = items[ 1 ][ : -1 ]

So I guess a comment could be any line that starts with '=='. However, then the whole line is discarded, whereas the user might expect he could add a comment to the end of a (valid) line.
Maybe inserting a "line = line.split('#', 1)[0]" into the loop might help:

        for line in lines:
            items = line.split( '=', maxsplit )
            line = line.split('#', 1)[0]
            if len( items ) == 2:
                self.dict[ items[ 0 ] ] = items[ 1 ][ : -1 ]

Then everything after a '#' is ignored. But I neither know enough python nor enough about the rest of the program to be sure that this doesn't break anything...

Revision history for this message
Germar (germar) said :
#2

Sorry, that wont work. BIT automatically rewrites the config file and you will loose all comments.
I'll have a look if there is a solution for this.

Can you help with this problem?

Provide an answer of your own, or ask Martin J.H. for more information if necessary.

To post a message you must log in.