From: David Garcia Date: Tue, 22 Sep 2020 09:36:48 +0000 (+0200) Subject: Improve Config.get() function X-Git-Tag: release-v9.0-start~13 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=dda20d4e308af1afceb58839e93ccc4210c9f3fc;p=osm%2FMON.git Improve Config.get() function The .get is a bit confusing because apparently has the same behaviour as dict.get(), which returns None when the key doesn't exist. But that's not the case, because Config.get in this case is doing dict["key"], which returns a KeyError when the key does not exist Change-Id: Ief82eb1ae2e2fea60b8be60cae8610bf8605fb6f Signed-off-by: David Garcia --- diff --git a/osm_mon/core/config.py b/osm_mon/core/config.py index c4c3972..cd99ffc 100644 --- a/osm_mon/core/config.py +++ b/osm_mon/core/config.py @@ -48,7 +48,7 @@ class Config: def get(self, section, field=None): if not field: return self.conf[section] - return self.conf[section][field] + return self.conf[section].get(field) def set(self, section, field, value): if section not in self.conf: