From 94b577484bf7fece70f74d41db5803273b720f58 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Tue, 1 Sep 2015 23:01:16 +0200 Subject: [PATCH] (trunk-1614) Sort entries in config file, so they don't jump around every time config is saved for easier troubleshooting --- terminatorlib/configobj/configobj.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/terminatorlib/configobj/configobj.py b/terminatorlib/configobj/configobj.py index fd1a2fc7..3ad65b4f 100644 --- a/terminatorlib/configobj/configobj.py +++ b/terminatorlib/configobj/configobj.py @@ -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