mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 17:47:08 +03:00
3f8aa26d0f
* Update generated project's .gitignore * Post-gen gitignore .env/ and .env * Fix linesep between gitignored entries * Persist `.env/**/*` files into cookiecutter-django's VCS * Rename .env/ to .envs/ * Reference the newly created .envs/**/.* files in local.yml * Reference the newly created .envs/**/.* files in production.yml * Delete .env.example * Refactor post-gen-project.py Closes #1299. * Implement production-dotenv-files-to-dotenv-file merge script * Create shared PyCharm Run Configuration for the automation script * Randomize POSTGRES_PASSWORD in ./envs/(.local|.production)/.postgres * Default POSTGRES_PASSWORD and POSTGRES_USER to random values * Fix jinja linebreaks in local.yml * Spaces in production.yml * Fix post-merge leftovers & set DJANGO_ADMIN_URL automatically * Prettify here and there * Fix FileNotFoundError * Leave a TODO in post_gen_hook.py * Introduce keep_local_envs_in_vcs option * Remove envs when not opted for * Inline pre_gen_project.py if-condition * Get rid of PROJECT_DIR_PATH in post_gen_project.py * Clean up the docs * Match copyright notices * Document envs ins and outs
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
"""
|
|
NOTE:
|
|
the below code is to be maintained Python 2.x-compatible
|
|
as the whole Cookiecutter Django project initialization
|
|
can potentially be run in Python 2.x environment.
|
|
|
|
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
|
"""
|
|
from __future__ import print_function
|
|
|
|
import sys
|
|
|
|
TERMINATOR = "\x1b[0m"
|
|
WARNING = "\x1b[1;33m [WARNING]: "
|
|
INFO = "\x1b[1;33m [INFO]: "
|
|
HINT = "\x1b[3;33m"
|
|
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
|
|
|
project_slug = '{{ cookiecutter.project_slug }}'
|
|
if hasattr(project_slug, 'isidentifier'):
|
|
assert project_slug.isidentifier(), "'{}' project slug is not a valid Python identifier.".format(project_slug)
|
|
|
|
assert "\\" not in "{{ cookiecutter.author_name }}", "Don't include backslashes in author name."
|
|
|
|
if '{{ cookiecutter.use_docker }}'.lower() == 'n':
|
|
python_major_version = sys.version_info[0]
|
|
if python_major_version == 2:
|
|
print(
|
|
WARNING +
|
|
"Cookiecutter Django does not support Python 2. "
|
|
"Stability is guaranteed with Python 3.6+ only, "
|
|
"are you sure you want to proceed (y/n)? " +
|
|
TERMINATOR
|
|
)
|
|
yes_options, no_options = frozenset(['y']), frozenset(['n'])
|
|
while True:
|
|
choice = raw_input().lower()
|
|
if choice in yes_options:
|
|
break
|
|
elif choice in no_options:
|
|
print(
|
|
INFO +
|
|
"Generation process stopped as requested." +
|
|
TERMINATOR
|
|
)
|
|
sys.exit(1)
|
|
else:
|
|
print(
|
|
HINT +
|
|
"Please respond with {} or {}: ".format(
|
|
', '.join(["'{}'".format(o) for o in yes_options if not o == '']),
|
|
', '.join(["'{}'".format(o) for o in no_options if not o == ''])
|
|
) +
|
|
TERMINATOR
|
|
)
|