From 3e2a550f12b9b230550942a89634a649116126ae Mon Sep 17 00:00:00 2001 From: Gabor Mezei Date: Fri, 28 Jun 2024 17:27:19 +0200 Subject: [PATCH] Pass `ConfigFile` object as parameter for `MultiConfig` constructor Signed-off-by: Gabor Mezei --- scripts/config.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/config.py b/scripts/config.py index 839e26a726..518badbce0 100755 --- a/scripts/config.py +++ b/scripts/config.py @@ -631,10 +631,16 @@ class MultiConfig(Config): and modify the configuration. """ - def __init__(self, mbedtls_filename=None, crypto__filename=None): + def __init__(self, *configs): super().__init__() - self.mbedtls_configfile = MbedTLSConfigFile(mbedtls_filename) - self.crypto_configfile = CryptoConfigFile(crypto__filename) + for config in configs: + if isinstance(config, MbedTLSConfigFile): + self.mbedtls_configfile = config + elif isinstance(config, CryptoConfigFile): + self.crypto_configfile = config + else: + raise ValueError(f'Invalid configfile: {config}') + self.settings.update({name: Setting(active, name, value, section, configfile) for configfile in [self.mbedtls_configfile, self.crypto_configfile] for (active, name, value, section) in configfile.parse_file()}) @@ -823,7 +829,7 @@ if __name__ == '__main__': excluding X.509 and TLS.""") args = parser.parse_args() - config = MultiConfig(args.file, args.cryptofile) + config = MultiConfig(MbedTLSConfigFile(args.file), CryptoConfigFile(args.cryptofile)) if args.command is None: parser.print_help() return 1