From 283a5360ad71fe616f86f2f1520e7a320f921c37 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 23 Feb 2010 20:37:16 +0100 Subject: [PATCH] Config.get() method --- weboob/config.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/weboob/config.py b/weboob/config.py index 581e35b7df..186c6ebf60 100644 --- a/weboob/config.py +++ b/weboob/config.py @@ -43,6 +43,25 @@ def __init__(self, path): self.path = path self.sections = {} + def get(self, *args): + s = None + path = '' + for a in args: + if path: path += '.' + path += a + if not s: + try: + s = self.sections[a] + except KeyError: + s = self.sections[a] = Section(path) + else: + try: + s = s.values[a] + except KeyError: + s = s.values[a] = Section(path) + + return s + def load(self): parser = SafeConfigParser() parser.read(self.path) -- GitLab