summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartinko2011-08-22 11:49:50 +0000
committermartinko2011-08-22 11:49:50 +0000
commit3945fc5baacb52653017481ab9b4966c86cf357f (patch)
treedd0a21d454ff9ec6259768bca2cd758ffca9ec26
parent498c0175fba4eb50d1dff159270a78aeb2be2b01 (diff)
config.py: added items() and has_section() methods to simplify certain usecases
-rw-r--r--python/skytools/config.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/python/skytools/config.py b/python/skytools/config.py
index 9ec90168..c276a5d1 100644
--- a/python/skytools/config.py
+++ b/python/skytools/config.py
@@ -186,11 +186,14 @@ class Config(object):
"""Returns list of sections in config file, excluding DEFAULT."""
return self.cf.sections()
+ def has_section(self, section):
+ """Checks if section is present in config file, excluding DEFAULT."""
+ return self.cf.has_section(section)
+
def clone(self, main_section):
"""Return new Config() instance with new main section on same config file."""
return Config(main_section, self.filename, self.sane_config)
-
def options(self):
"""Return list of options in main section."""
return self.cf.options(self.main_section)
@@ -198,3 +201,7 @@ class Config(object):
def has_option(self, opt):
"""Checks if option exists in main section."""
return self.cf.has_option(self.main_section, opt)
+
+ def items(self):
+ """Returns list of (name, value) for each option in main section."""
+ return self.cf.items(self.main_section)