From 27d0a133302ffae01fa3d0d6894ba36934c7c1a6 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 10 Jan 2010 17:36:55 +0000 Subject: [PATCH] print more useful errors when the config file format is invalid, and update the configspec generator to know that our undefined default keybindings are now '' instead of None --- terminatorlib/config.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index f5e22b1b..5377f187 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -52,7 +52,7 @@ import platform import os import sys from copy import copy -from configobj.configobj import ConfigObj +from configobj.configobj import ConfigObj, flatten_errors from configobj.validate import Validator from borg import Borg from factory import Factory @@ -317,10 +317,8 @@ class ConfigBase(Borg): section = {} for key in DEFAULTS['keybindings']: value = DEFAULTS['keybindings'][key] - if value is None: + if value is None or value == '': continue - elif isinstance(value, tuple): - value = value[0] section[key] = 'string(default=%s)' % value configspecdata['keybindings'] = section @@ -369,6 +367,11 @@ class ConfigBase(Borg): if result != True: err('ConfigBase::load: config format is not valid') + for (section_list, key, other) in flatten_errors(parser, result): + if key is not None: + print('[%s]: %s is invalid' % (','.join(section_list), key)) + else: + print ('[%s] missing' % ','.join(section_list)) for section_name in self.sections: dbg('ConfigBase::load: Processing section: %s' % section_name)