Changeset - 06ae370ffaa3
[Not reviewed]
default
0 1 0
Mads Kiilerich - 8 years ago 2018-03-11 15:24:47
mads@kiilerich.com
Grafted from: 856ac96f3f9a
ini: only keep default value as comment if the custom value actually is different
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/inifile.py
Show inline comments
 
@@ -109,14 +109,16 @@ def expand(template, mako_variable_value
 

	
 
            def process_line(m):
 
                """process a section line and update value if necessary"""
 
                key, value = m.groups()
 
                line = m.group(0)
 
                if key in section_settings:
 
                    # keep old entry as example - comments might refer to it
 
                    line = '#%s\n%s = %s' % (line, key, section_settings.pop(key))
 
                    new_line = '%s = %s' % (key, section_settings.pop(key))
 
                    if new_line != line:
 
                        # keep old entry as example - comments might refer to it
 
                        line = '#%s\n%s' % (line, new_line)
 
                return line.rstrip()
 

	
 
            # process lines that not are comments or empty and look like name=value
 
            lines = re.sub(r'^([^#\n\s]*)[ \t]*=[ \t]*(.*)$', process_line, lines, flags=re.MULTILINE)
 
            # add unused section settings
 
            if section_settings:
0 comments (0 inline, 0 general)