From deee35fc3294a122cfb5089f1c0f30f6c202dbb1 Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Tue, 5 Jul 2022 19:10:47 +0200 Subject: [PATCH] feat(config): Add list of config options where empty value is okay --- .../{{ cookiecutter.__project_slug }}.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py b/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py index 65174b6..b3529f6 100644 --- a/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py +++ b/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py @@ -112,6 +112,9 @@ class ConfigParser( ini_defaults = [] internal_defaults = {default["key"]: default["value"] for default in CONST.CFG_KNOWN_DEFAULTS} internal_globals = [default["key"] for default in CONST.CFG_KNOWN_DEFAULTS if default["is_global"]] +internal_empty_ok = [default["key"] for default in CONST.CFG_KNOWN_DEFAULTS if default["empty_ok"]] +config = ConfigParser(defaults=internal_defaults, + converters={'list': lambda x: [i.strip() for i in x.split(',') if len(x) > 0]}) config = ConfigParser(defaults=internal_defaults) config.read(CONST.CFG_DEFAULT_ABS_PATH)