(trunk-1614) Sort entries in config file, so they don't jump around every time config is saved for easier troubleshooting

This commit is contained in:
Stephen Boddy 2015-09-01 23:01:16 +02:00
parent b7b8888745
commit 94b577484b
1 changed files with 12 additions and 0 deletions

View File

@ -2031,6 +2031,18 @@ class ConfigObj(Section):
out.append(line)
indent_string = self.indent_type * section.depth
# Do a little sorting for convenience
section.scalars = sorted(section.scalars)
section.sections = sorted(section.sections)
if 'default' in section.scalars:
# pop it and move to front
section.scalars.remove('default')
section.scalars.insert(0, 'default')
if 'default' in section.sections:
section.sections.remove('default')
section.sections.insert(0, 'default')
for entry in (section.scalars + section.sections):
if entry in section.defaults:
# don't write out default values