refactor(config): Clearer Cookiecutter variable names
This commit is contained in:
		| @@ -1,16 +1,21 @@ | ||||
| {% if cookiecutter.uses_config_ini == "yes" -%} | ||||
| {% if cookiecutter.use_config_ini == "yes" -%} | ||||
| # Path and env manipulation | ||||
| import os | ||||
| # Use a config file | ||||
| import configparser | ||||
| # Exit with various exit codes | ||||
| import sys | ||||
| {%- endif %} | ||||
| {%- if cookiecutter.use_rich_logging == "yes" %} | ||||
| # Manipulate style and content of logs | ||||
| import logging | ||||
| from rich.logging import RichHandler | ||||
| {%- endif %} | ||||
| {%- if cookiecutter.uses_inflect == "yes" %} | ||||
| {%- if cookiecutter.use_inflect == "yes" %} | ||||
| # Correctly generate plurals, singular nouns etc. | ||||
| import inflect | ||||
| {%- endif %} | ||||
| {%- if cookiecutter.use_rich_logging == "yes" or cookiecutter.uses_config_ini == "yes" %} | ||||
| {%- if cookiecutter.use_rich_logging == "yes" or cookiecutter.use_config_ini == "yes" %} | ||||
|  | ||||
|  | ||||
| # Exit codes | ||||
| @@ -24,7 +29,7 @@ class CONST(object): | ||||
|     {%- if cookiecutter.use_rich_logging == "yes" %} | ||||
|     LOG_FORMAT = "%(message)s" | ||||
|     {%- endif %} | ||||
|     {%- if cookiecutter.uses_config_ini == "yes" %} | ||||
|     {%- if cookiecutter.use_config_ini == "yes" %} | ||||
|     # How to find a config file | ||||
|     CFG_THIS_FILE_DIRNAME = os.path.dirname(__file__) | ||||
|     CFG_DEFAULT_FILENAME = "config.ini" | ||||
| @@ -82,7 +87,7 @@ log = logging.getLogger("rich") | ||||
| # Our own code logs with this level | ||||
| log.setLevel(os.environ.get("LOGLEVEL") if "LOGLEVEL" in [k for k, v in os.environ.items()] else logging.INFO) | ||||
| {%- endif %} | ||||
| {%- if cookiecutter.uses_config_ini == "yes" %} | ||||
| {%- if cookiecutter.use_config_ini == "yes" %} | ||||
|  | ||||
|  | ||||
| # Use this version of class ConfigParser to {% if cookiecutter.use_rich_logging == "yes" -%}log.debug{%- else -%}print{%- endif %} contents of our config file. When parsing sections other than | ||||
| @@ -193,11 +198,11 @@ def validate_config_sections( | ||||
|  | ||||
| def an_important_function( | ||||
|         section_name: str, | ||||
| {%- if cookiecutter.uses_config_ini == "yes" %} | ||||
| {%- if cookiecutter.use_config_ini == "yes" %} | ||||
|         config_obj: configparser.ConfigParser(), | ||||
| {%- endif %} | ||||
|         whatever: str) -> list: | ||||
|     {%- if cookiecutter.uses_config_ini == "yes" %} | ||||
|     {%- if cookiecutter.use_config_ini == "yes" %} | ||||
|     min_duration = config_obj.getint(section_name, "min_duration") | ||||
|     max_duration = config_obj.getint(section_name, "max_duration") | ||||
|     {%- else %} | ||||
| @@ -208,7 +213,7 @@ def an_important_function( | ||||
|  | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     {% if cookiecutter.uses_config_ini == "yes" -%} | ||||
|     {% if cookiecutter.use_config_ini == "yes" -%} | ||||
|     validate_default_section(config) | ||||
|     if config_has_valid_section(config): | ||||
|         validate_config_sections(config) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user