mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-09-13 07:22:35 +03:00
* Move template linting and formatting to ruff The generated project already uses that, let's be consistent and use it everywhere * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove comments as they're wrongly placed * Tweak multi-line comment * Remove a couple of commented out Ruff rules * Fix extend-exclude in Ruff config * Adjust Ruff line length * Run Ruff pre-commit hook * Run Ruff with --unsafe-fixes * Run Ruff with --add-noqa * Run Ruff formatter * Drop Python 2 in pre/post generation hooks * Restore print statements in pre/post-generation hooks * Restore print statements in scripts * Indent toml with 2 spaces * Exclude docs and revert most changes from Ruff * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix Ruff issue * Disable PLR0133 in pre/post commit hooks We seem to compare 2 constants but seem strings are in fact interpolated in Jinja. https://docs.astral.sh/ruff/rules/comparison-of-constant/ * Migrate post-generation hook to pathlib * Migrate post-generation hook to pathlib * Fix typo in folder name * Migrate test generation to pathlib * Fix typo in folder name * Format comment better * Update pyproject.toml * Disable TRY003 * Update Ruff version pre-commit config * Apply suggestions from code review * Remove env from tox envlist * Align ruff in pre-commit config * Update .pre-commit-config.yaml * Bump Ruff version * Bump ruff pre-commit version * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove isort tests as it's no longer used --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
# ruff: noqa: PLR0133
|
|
import sys
|
|
|
|
TERMINATOR = "\x1b[0m"
|
|
WARNING = "\x1b[1;33m [WARNING]: "
|
|
INFO = "\x1b[1;33m [INFO]: "
|
|
HINT = "\x1b[3;33m"
|
|
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
|
|
|
# The content of this string is evaluated by Jinja, and plays an important role.
|
|
# It updates the cookiecutter context to trim leading and trailing spaces
|
|
# from domain/email values
|
|
"""
|
|
{{ cookiecutter.update({ "domain_name": cookiecutter.domain_name | trim }) }}
|
|
{{ cookiecutter.update({ "email": cookiecutter.email | trim }) }}
|
|
"""
|
|
|
|
project_slug = "{{ cookiecutter.project_slug }}"
|
|
if hasattr(project_slug, "isidentifier"):
|
|
assert project_slug.isidentifier(), f"'{project_slug}' project slug is not a valid Python identifier."
|
|
|
|
assert project_slug == project_slug.lower(), f"'{project_slug}' project slug should be all lowercase"
|
|
|
|
assert "\\" not in "{{ cookiecutter.author_name }}", "Don't include backslashes in author name."
|
|
|
|
if "{{ cookiecutter.use_whitenoise }}".lower() == "n" and "{{ cookiecutter.cloud_provider }}" == "None":
|
|
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":
|
|
print("You should either use AWS or select a different Mail Service for sending emails.")
|
|
sys.exit(1)
|