diff options
author | Marko Kreen | 2010-09-14 09:44:31 +0000 |
---|---|---|
committer | Marko Kreen | 2010-09-14 10:15:47 +0000 |
commit | 351daf94ffdc4f6b4f0f5dd58fc8c60ea333e9a9 (patch) | |
tree | 3b07d4d8a950632b4f7f5147c914d1c65dc867cf /python/skytools | |
parent | 6899e3692d63f09ba29d33309f64ca68fd765ee8 (diff) |
skytools.config: always check main section
Patch by Martin Otto
Diffstat (limited to 'python/skytools')
-rw-r--r-- | python/skytools/config.py | 11 |
1 files changed, 5 insertions, 6 deletions
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.""" |