Restore print statements in pre/post-generation hooks

This commit is contained in:
Bruno Alla 2024-12-31 11:41:24 +00:00
parent 304acaea72
commit 972a072b12
3 changed files with 17 additions and 3 deletions

View File

@ -284,6 +284,10 @@ def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs):
if value is None:
random_string = generate_random_string(*args, **kwargs)
if random_string is None:
print(
"We couldn't find a secure pseudo-random number generator on your "
f"system. Please, make sure to manually {flag} later.",
)
random_string = flag
if formatted is not None:
random_string = formatted.format(random_string)
@ -451,7 +455,11 @@ def main(): # noqa: C901, PLR0912, PLR0915
if "{{ cookiecutter.use_docker }}".lower() == "n" and "{{ cookiecutter.use_heroku }}".lower() == "n":
if "{{ cookiecutter.keep_local_envs_in_vcs }}".lower() == "y":
pass
print(
INFO + ".env(s) are only utilized when Docker Compose and/or "
"Heroku support is enabled so keeping them does not make sense "
"given your current setup." + TERMINATOR,
)
remove_envs_and_associated_files()
else:
append_to_gitignore_file(".env")
@ -475,7 +483,10 @@ def main(): # noqa: C901, PLR0912, PLR0915
)
if "{{ cookiecutter.cloud_provider }}" == "None" and "{{ cookiecutter.use_docker }}".lower() == "n": # noqa: PLR0133
pass
print(
WARNING + "You chose to not use any cloud providers nor Docker, "
"media files won't be served in production." + TERMINATOR,
)
if "{{ cookiecutter.use_celery }}".lower() == "n":
remove_celery_files()
@ -500,6 +511,8 @@ def main(): # noqa: C901, PLR0912, PLR0915
if "{{ cookiecutter.use_async }}".lower() == "n":
remove_async_files()
print(SUCCESS + "Project initialized, keep up the good work!" + TERMINATOR)
if __name__ == "__main__":
main()

View File

@ -23,7 +23,9 @@ assert project_slug == project_slug.lower(), f"'{project_slug}' project slug sho
assert "\\" not in "{{ cookiecutter.author_name }}", "Don't include backslashes in author name." # noqa: PLR0133
if "{{ cookiecutter.use_whitenoise }}".lower() == "n" and "{{ cookiecutter.cloud_provider }}" == "None": # noqa: PLR0133
print("You should either use Whitenoise or select a Cloud Provider to serve static files")
sys.exit(1)
if "{{ cookiecutter.mail_service }}" == "Amazon SES" and "{{ cookiecutter.cloud_provider }}" != "AWS": # noqa: PLR0133
print("You should either use AWS or select a different Mail Service for sending emails.")
sys.exit(1)

View File

@ -111,7 +111,6 @@ lint.select = [
"SLF",
"SLOT",
"T10",
"T20",
"TCH",
"TID",
"TRY",