forked from dgarana/cookiecutter-falcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_gen_project.py
44 lines (35 loc) · 1.06 KB
/
post_gen_project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""
Does the following:
1. Remove docker files if docker won't be used.
"""
# System imports
from subprocess import call
import os
import shutil
# Third-party imports
from cookiecutter.main import cookiecutter
# Root project directory
PROJECT_DIRECTORY = os.path.realpath(os.path.curdir)
def remove_docker_files(project_directory):
""" Removes the files if docker isn't going to be used """
docker_folder_location = os.path.join(
project_directory,
'docker'
)
shutil.rmtree(docker_folder_location)
docker_compose_file_location = os.path.join(
project_directory,
'docker-compose.yml'
)
os.remove(docker_compose_file_location)
docker_settings_file_location = os.path.join(
project_directory,
'{{ cookiecutter.project_slug }}/settings/docker.py'
)
os.remove(docker_settings_file_location)
# 1. Remove docker files
if '{{ cookiecutter.use_docker }}'.lower() == 'n':
remove_docker_files(PROJECT_DIRECTORY)
# 2. Initialize git repository
call(["git", "init"])