From 5f0527f0c3b2c1bf2ec13318c63053d8e39bff44 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 27 May 2022 15:15:34 +0200 Subject: [PATCH] config: add get_option() method --- mylib/config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mylib/config.py b/mylib/config.py index b592232..34e1b08 100644 --- a/mylib/config.py +++ b/mylib/config.py @@ -649,6 +649,12 @@ class Config: # pylint: disable=too-many-instance-attributes log.debug('get(%s, %s): %s (%s)', section, option, value, type(value)) return value + def get_option(self, option, default=None): + """ Get an argument parser option value """ + if self.options and hasattr(self.options, option): + return getattr(self.options, option) + return default + def set(self, section, option, value): """ Set option value """ assert self.config_parser, 'Unconfigured options parser'