From 87d5a5bf045669f3ec093779da2d838126e7c03f Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Tue, 5 Jul 2022 18:32:12 +0200 Subject: [PATCH] feat(config): CFG_KNOWN_DEFAULTS can now be empty and still valid --- .../{{ cookiecutter.__project_slug }}.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py b/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py index 67df9ac..6f5e8f3 100644 --- a/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py +++ b/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py @@ -33,15 +33,18 @@ class CONST(object): # an empty string. An example config.ini file may give a sane config example value here, removing that value # still results in a valid file. CFG_KNOWN_DEFAULTS = [ - {"key": "self_name", "value": "{{ cookiecutter.__project_slug }}"}, - {"key": "tmp_base_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/tmp/%(self_name)s")}, - {"key": "state_base_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/var/lib/%(self_name)s")}, - {"key": "state_files_dir", "value": "%(state_base_dir)s/state", "is_global": False}, - {"key": "state_file_retention", "value": "50", "is_global": False}, - {"key": "state_file_name_prefix", "value": "state-", "is_global": False}, - {"key": "state_file_name_suffix", "value": ".log", "is_global": False}, - {"key": "{{ cookiecutter.__project_slug_under }}_some_option", "value": "http://localhost:8000/api/query", "is_global": True}, - {"key": "another_option", "value": "first", "is_global": True} + {"key": "self_name", "value": "{{ cookiecutter.__project_slug }}", "empty_ok": False}, + {"key": "tmp_base_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/tmp/%(self_name)s"), + "empty_ok": False}, + {"key": "state_base_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/var/lib/%(self_name)s"), + "empty_ok": False}, + {"key": "state_files_dir", "value": "%(state_base_dir)s/state", "is_global": False, "empty_ok": False}, + {"key": "state_file_retention", "value": "50", "is_global": False, "empty_ok": True}, + {"key": "state_file_name_prefix", "value": "state-", "is_global": False, "empty_ok": True}, + {"key": "state_file_name_suffix", "value": ".log", "is_global": False, "empty_ok": True}, + {"key": "{{ cookiecutter.__project_slug_under }}_some_option", "value": "http://localhost:8000/api/query", "is_global": True, + "empty_ok": False}, + {"key": "another_option", "value": "first", "is_global": True, "empty_ok": True} ] # In all sections other than 'default' the following settings are known and accepted. We ignore other settings. # Per CFG_KNOWN_DEFAULTS above most '[DEFAULT]' options are accepted by virtue of being defaults and overridable.