mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-08 14:04:52 +03:00
Get rid of PROJECT_DIR_PATH in post_gen_project.py
This commit is contained in:
parent
15836bf662
commit
2f1e230e3d
|
@ -28,15 +28,13 @@ INFO = "\x1b[1;33m [INFO]: "
|
||||||
HINT = "\x1b[3;33m"
|
HINT = "\x1b[3;33m"
|
||||||
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
||||||
|
|
||||||
PROJECT_DIR_PATH = os.path.realpath(os.path.curdir) # TODO: ? I doubt even need that
|
|
||||||
|
|
||||||
|
def remove_open_source_files():
|
||||||
def remove_open_source_project_only_files():
|
|
||||||
file_names = [
|
file_names = [
|
||||||
'CONTRIBUTORS.txt',
|
'CONTRIBUTORS.txt',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_gplv3_files():
|
def remove_gplv3_files():
|
||||||
|
@ -44,21 +42,21 @@ def remove_gplv3_files():
|
||||||
'COPYING',
|
'COPYING',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_pycharm_files():
|
def remove_pycharm_files():
|
||||||
idea_dir_path = os.path.join(PROJECT_DIR_PATH, '.idea')
|
idea_dir_path = '.idea'
|
||||||
if os.path.exists(idea_dir_path):
|
if os.path.exists(idea_dir_path):
|
||||||
shutil.rmtree(idea_dir_path)
|
shutil.rmtree(idea_dir_path)
|
||||||
|
|
||||||
docs_dir_path = os.path.join(PROJECT_DIR_PATH, 'docs', 'pycharm')
|
docs_dir_path = os.path.join('docs', 'pycharm')
|
||||||
if os.path.exists(docs_dir_path):
|
if os.path.exists(docs_dir_path):
|
||||||
shutil.rmtree(docs_dir_path)
|
shutil.rmtree(docs_dir_path)
|
||||||
|
|
||||||
|
|
||||||
def remove_docker_files():
|
def remove_docker_files():
|
||||||
shutil.rmtree(os.path.join(PROJECT_DIR_PATH, 'compose'))
|
shutil.rmtree('compose')
|
||||||
|
|
||||||
file_names = [
|
file_names = [
|
||||||
'local.yml',
|
'local.yml',
|
||||||
|
@ -66,7 +64,7 @@ def remove_docker_files():
|
||||||
'.dockerignore',
|
'.dockerignore',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_heroku_files():
|
def remove_heroku_files():
|
||||||
|
@ -76,7 +74,7 @@ def remove_heroku_files():
|
||||||
'requirements.txt',
|
'requirements.txt',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_grunt_files():
|
def remove_grunt_files():
|
||||||
|
@ -84,7 +82,7 @@ def remove_grunt_files():
|
||||||
'Gruntfile.js',
|
'Gruntfile.js',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_gulp_files():
|
def remove_gulp_files():
|
||||||
|
@ -92,7 +90,7 @@ def remove_gulp_files():
|
||||||
'gulpfile.js',
|
'gulpfile.js',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_packagejson_file():
|
def remove_packagejson_file():
|
||||||
|
@ -100,19 +98,19 @@ def remove_packagejson_file():
|
||||||
'package.json',
|
'package.json',
|
||||||
]
|
]
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
os.remove(file_name)
|
||||||
|
|
||||||
|
|
||||||
def remove_celery_app():
|
def remove_celery_app():
|
||||||
shutil.rmtree(os.path.join(PROJECT_DIR_PATH, '{{ cookiecutter.project_slug }}', 'taskapp'))
|
shutil.rmtree(os.path.join('{{ cookiecutter.project_slug }}', 'taskapp'))
|
||||||
|
|
||||||
|
|
||||||
def remove_dottravisyml_file():
|
def remove_dottravisyml_file():
|
||||||
os.remove(os.path.join(PROJECT_DIR_PATH, '.travis.yml'))
|
os.remove('.travis.yml')
|
||||||
|
|
||||||
|
|
||||||
def append_to_project_gitignore(path):
|
def append_to_project_gitignore(path):
|
||||||
gitignore_file_path = os.path.join(PROJECT_DIR_PATH, '.gitignore')
|
gitignore_file_path = '.gitignore'
|
||||||
with open(gitignore_file_path, 'a') as gitignore_file:
|
with open(gitignore_file_path, 'a') as gitignore_file:
|
||||||
gitignore_file.write(path)
|
gitignore_file.write(path)
|
||||||
gitignore_file.write(os.linesep)
|
gitignore_file.write(os.linesep)
|
||||||
|
@ -222,28 +220,28 @@ def set_postgres_password(file_path):
|
||||||
|
|
||||||
|
|
||||||
def append_to_gitignore_file(s):
|
def append_to_gitignore_file(s):
|
||||||
with open(os.path.join(PROJECT_DIR_PATH, '.gitignore'), 'a') as gitignore_file:
|
with open('.gitignore', 'a') as gitignore_file:
|
||||||
gitignore_file.write(s)
|
gitignore_file.write(s)
|
||||||
gitignore_file.write(os.linesep)
|
gitignore_file.write(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
def set_flags_in_envs(postgres_user):
|
def set_flags_in_envs(postgres_user):
|
||||||
local_postgres_envs_path = os.path.join(PROJECT_DIR_PATH, '.envs', '.local', '.postgres')
|
local_postgres_envs_path = os.path.join('.envs', '.local', '.postgres')
|
||||||
set_postgres_user(local_postgres_envs_path, value=postgres_user)
|
set_postgres_user(local_postgres_envs_path, value=postgres_user)
|
||||||
set_postgres_password(local_postgres_envs_path)
|
set_postgres_password(local_postgres_envs_path)
|
||||||
|
|
||||||
production_django_envs_path = os.path.join(PROJECT_DIR_PATH, '.envs', '.production', '.django')
|
production_django_envs_path = os.path.join('.envs', '.production', '.django')
|
||||||
set_django_secret_key(production_django_envs_path)
|
set_django_secret_key(production_django_envs_path)
|
||||||
set_django_admin_url(production_django_envs_path)
|
set_django_admin_url(production_django_envs_path)
|
||||||
|
|
||||||
production_postgres_envs_path = os.path.join(PROJECT_DIR_PATH, '.envs', '.production', '.postgres')
|
production_postgres_envs_path = os.path.join('.envs', '.production', '.postgres')
|
||||||
set_postgres_user(production_postgres_envs_path, value=postgres_user)
|
set_postgres_user(production_postgres_envs_path, value=postgres_user)
|
||||||
set_postgres_password(production_postgres_envs_path)
|
set_postgres_password(production_postgres_envs_path)
|
||||||
|
|
||||||
|
|
||||||
def set_flags_in_settings_files():
|
def set_flags_in_settings_files():
|
||||||
set_django_secret_key(os.path.join(PROJECT_DIR_PATH, 'config', 'settings', 'local.py'))
|
set_django_secret_key(os.path.join('config', 'settings', 'local.py'))
|
||||||
set_django_secret_key(os.path.join(PROJECT_DIR_PATH, 'config', 'settings', 'test.py'))
|
set_django_secret_key(os.path.join('config', 'settings', 'test.py'))
|
||||||
|
|
||||||
|
|
||||||
def remove_envs_and_associated_files():
|
def remove_envs_and_associated_files():
|
||||||
|
@ -257,7 +255,7 @@ def main():
|
||||||
set_flags_in_settings_files()
|
set_flags_in_settings_files()
|
||||||
|
|
||||||
if '{{ cookiecutter.open_source_license }}' == 'Not open source':
|
if '{{ cookiecutter.open_source_license }}' == 'Not open source':
|
||||||
remove_open_source_project_only_files()
|
remove_open_source_files()
|
||||||
if '{{ cookiecutter.open_source_license}}' != 'GPLv3':
|
if '{{ cookiecutter.open_source_license}}' != 'GPLv3':
|
||||||
remove_gplv3_files()
|
remove_gplv3_files()
|
||||||
|
|
||||||
|
@ -270,9 +268,7 @@ def main():
|
||||||
if '{{ cookiecutter.use_heroku }}'.lower() == 'n':
|
if '{{ cookiecutter.use_heroku }}'.lower() == 'n':
|
||||||
remove_heroku_files()
|
remove_heroku_files()
|
||||||
|
|
||||||
envs_make_sense = '{{ cookiecutter.use_docker }}'.lower() == 'n' \
|
if '{{ cookiecutter.use_docker }}'.lower() == 'n' and '{{ cookiecutter.use_heroku }}'.lower() == 'n':
|
||||||
and '{{ cookiecutter.use_heroku }}'.lower() == 'n'
|
|
||||||
if envs_make_sense:
|
|
||||||
if '{{ cookiecutter.keep_local_envs_in_vcs }}'.lower() == 'y':
|
if '{{ cookiecutter.keep_local_envs_in_vcs }}'.lower() == 'y':
|
||||||
print(
|
print(
|
||||||
INFO +
|
INFO +
|
||||||
|
|
Loading…
Reference in New Issue
Block a user