From: Ondrej Lichtner <olichtne(a)redhat.com>
This method returns all the option values in a specific section.
Previously we just had the get_section method which returns the internal
dict structure of the Config class which is not very usable in the
application.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Config.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 97a82e4..de7ba4a 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -155,6 +155,16 @@ class Config():
raise ConfigError(msg)
return self._options[section]
+ def get_section_values(self, section):
+ if section not in self._options:
+ msg = 'Unknow section: %s' % section
+ raise ConfigError(msg)
+
+ res = {}
+ for opt_name, opt in self._options[section].items():
+ res[opt_name] = opt["value"]
+ return res
+
def get_option(self, section, option):
sect = self.get_section(section)
if option not in sect:
--
2.7.2
Show replies by date