From 6fea75022f787689a1ae43a1803c2c3431544436 Mon Sep 17 00:00:00 2001 From: Blallo Date: Sat, 29 Aug 2020 20:06:08 +0200 Subject: [PATCH] Refactor config logic for bools If a config paramenter is a boolean, the resulting configuration is the logic and of all those given (including defaults). BEWARE in future config implementations! --- config.yml | 3 +-- src/phi/config.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.yml b/config.yml index 100a0f6..64793c5 100644 --- a/config.yml +++ b/config.yml @@ -11,7 +11,7 @@ ldap: encryption: TLSv1.2 # Can either be None or TLSv1.2. Default: None ciphers: "HIGH" - validate: True # Can either be True or False. Default: False + validate: False # Can either be True or False. Default: False ca_certs: openldap/cert.pem username: uid=phi,ou=Services,dc=unit,dc=macaomilano,dc=org @@ -19,7 +19,6 @@ ldap: base_dn: dc=unit,dc=macaomilano,dc=org attribute_id: uid - attribute_mail: mail logging: diff --git a/src/phi/config.py b/src/phi/config.py index f967e51..b1d1acb 100644 --- a/src/phi/config.py +++ b/src/phi/config.py @@ -125,6 +125,8 @@ def recursive_merge(main_config, aux_config): if aux is not None: _main.extend(aux) _ret_config[key] = list(set(_main)) + elif isinstance(default, bool): + _ret_config[key] = default and aux and main else: if main is not None: _ret_config[key] = main