From 7231030991cd07d6c18403f42e0bd4a04c6e475b Mon Sep 17 00:00:00 2001 From: Valentin Schneider Date: Fri, 8 Jun 2018 18:15:10 +0100 Subject: [PATCH] target: Add strict option to KernelConfig.get() Defaults to False. If True, will raise an exception when a requested config name is not exposed in the config instance. --- devlib/target.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index edbac44..58015a6 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -1645,8 +1645,14 @@ class KernelConfig(object): name, value = line.split('=', 1) self._config[name.strip()] = value.strip() - def get(self, name): - return self._config.get(self.get_config_name(name)) + def get(self, name, strict=False): + name = self.get_config_name(name) + res = self._config.get(name) + + if not res and strict: + raise IndexError("{} is not exposed in target's config") + + return self._config.get(name) def like(self, name): regex = re.compile(name, re.I)