feat(config): CFG_KNOWN_DEFAULTS can now be empty and still valid

This commit is contained in:
hygienic-books 2022-07-05 18:32:12 +02:00
parent 71d68a47ed
commit 87d5a5bf04

View File

@ -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 # 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. # still results in a valid file.
CFG_KNOWN_DEFAULTS = [ CFG_KNOWN_DEFAULTS = [
{"key": "self_name", "value": "{{ cookiecutter.__project_slug }}"}, {"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")}, {"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")}, "empty_ok": False},
{"key": "state_files_dir", "value": "%(state_base_dir)s/state", "is_global": False}, {"key": "state_base_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/var/lib/%(self_name)s"),
{"key": "state_file_retention", "value": "50", "is_global": False}, "empty_ok": False},
{"key": "state_file_name_prefix", "value": "state-", "is_global": False}, {"key": "state_files_dir", "value": "%(state_base_dir)s/state", "is_global": False, "empty_ok": False},
{"key": "state_file_name_suffix", "value": ".log", "is_global": False}, {"key": "state_file_retention", "value": "50", "is_global": False, "empty_ok": True},
{"key": "{{ cookiecutter.__project_slug_under }}_some_option", "value": "http://localhost:8000/api/query", "is_global": True}, {"key": "state_file_name_prefix", "value": "state-", "is_global": False, "empty_ok": True},
{"key": "another_option", "value": "first", "is_global": 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. # 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. # Per CFG_KNOWN_DEFAULTS above most '[DEFAULT]' options are accepted by virtue of being defaults and overridable.