From 351daf94ffdc4f6b4f0f5dd58fc8c60ea333e9a9 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Tue, 14 Sep 2010 12:44:31 +0300 Subject: skytools.config: always check main section Patch by Martin Otto --- python/skytools/config.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'python/skytools/config.py') diff --git a/python/skytools/config.py b/python/skytools/config.py index 047ae258..11a6ae82 100644 --- a/python/skytools/config.py +++ b/python/skytools/config.py @@ -42,18 +42,17 @@ class Config(object): if filename is None: self.cf.add_section(main_section) - return - - if not os.path.isfile(filename): + elif not os.path.isfile(filename): raise Exception('Config file not found: '+filename) - self.cf.read(filename) - if not self.cf.has_section(main_section): - raise Exception("Wrong config file, no section '%s'"%main_section) + + self.reload() def reload(self): """Re-reads config file.""" if self.filename: self.cf.read(self.filename) + if not self.cf.has_section(self.main_section): + raise Exception("Wrong config file, no section '%s'" % self.main_section) def get(self, key, default=None): """Reads string value, if not set then default.""" -- cgit v1.2.3