From 4d662af20d2518f39b98b07f76e370f3587791a4 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Thu, 13 Aug 2015 22:16:35 +0200 Subject: [PATCH] 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