feat(debug): Load inflect to render grammatically correct text

This commit is contained in:
hygienic-books 2022-07-05 19:36:52 +02:00
parent dab22b8c96
commit b6da0efa29

View File

@ -87,6 +87,11 @@ logging.basicConfig(
log = logging.getLogger("rich") log = logging.getLogger("rich")
# Our own code logs with this level # 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) log.setLevel(os.environ.get("LOGLEVEL") if "LOGLEVEL" in [k for k, v in os.environ.items()] else logging.INFO)
{%- endif %}{%- if cookiecutter.use_rich_logging == "no" %}
{% endif %}
{%- if cookiecutter.use_inflect == "yes" %}
p = inflect.engine()
{%- endif %} {%- endif %}
{%- if cookiecutter.use_config_ini == "yes" %} {%- if cookiecutter.use_config_ini == "yes" %}
@ -196,11 +201,11 @@ def validate_config_sections(
unset_options = we_have_unset_options(config_obj, this_section) unset_options = we_have_unset_options(config_obj, this_section)
if unset_options: if unset_options:
{% if cookiecutter.use_rich_logging == "yes" -%}log.error{%- else -%}print{%- endif %}(f"""{p.plural("Option", len(unset_options))} {unset_options} """ {% if cookiecutter.use_rich_logging == "yes" -%}log.error{%- else -%}print{%- endif %}(f"""{% if cookiecutter.use_inflect == "yes" %}{p.plural("Option", len(unset_options))}{% else %}Options{% endif %} {unset_options} """
{% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"""{p.plural("is", len(unset_options))} unset. """ {% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"""{% if cookiecutter.use_inflect == "yes" %}{p.plural("is", len(unset_options))}{% else %}are{% endif %} unset. """
{% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"""{p.singular_noun("They", len(unset_options))} """ {% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"""{% if cookiecutter.use_inflect == "yes" %}{p.singular_noun("They", len(unset_options))}{% else %}They{% endif %} """
{% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"must have a non-null value. " {% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"must have a non-null value. "
{% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"""{p.plural("Default", len(unset_options))} {p.plural("is", len(unset_options))}:""") {% if cookiecutter.use_rich_logging == "yes" %} {% endif %}f"""{% if cookiecutter.use_inflect == "yes" %}{p.plural("Default", len(unset_options))} {p.plural("is", len(unset_options))}{% else %}Defaults are{% endif %}:""")
for unset_option in unset_options: for unset_option in unset_options:
{% if cookiecutter.use_rich_logging == "yes" -%}log.error{%- else -%}print{%- endif %}(f"{unset_option} = {internal_defaults[unset_option]}") {% if cookiecutter.use_rich_logging == "yes" -%}log.error{%- else -%}print{%- endif %}(f"{unset_option} = {internal_defaults[unset_option]}")
{% if cookiecutter.use_rich_logging == "yes" -%}log.error{%- else -%}print{%- endif %}(f"Exiting 7 ...") {% if cookiecutter.use_rich_logging == "yes" -%}log.error{%- else -%}print{%- endif %}(f"Exiting 7 ...")