'''
Does the following:

1. Inits git if used
2. Deletes dockerfiles if not going to be used
3. Deletes config utils if not needed
'''
from __future__ import print_function
import os
import shutil
from subprocess import Popen

# Get the root project directory
PROJECT_DIRECTORY = os.path.realpath(os.path.curdir)


def remove_file(filename):
    '''
    generic remove file from project dir
    '''
    fullpath = os.path.join(PROJECT_DIRECTORY, filename)
    if os.path.exists(fullpath):
        os.remove(fullpath)

def init_git():
    '''
    Initialises git on the new project folder
    '''
    GIT_COMMANDS = [
        ['git', 'init'],
        ['git', 'add', '.'],
        ['git', 'commit', '-a', '-m', 'Initial Commit.']
    ]

    for command in GIT_COMMANDS:
        git = Popen(command, cwd=PROJECT_DIRECTORY)
        git.wait()


def remove_config_files():
    '''
    Removes files needed for viper config utils
    '''
    remove_file(os.path.join(
        '{{ cookiecutter.package_name }}', 'config.py'
    ))

# 1. Remove viper config if not seleted
if '{{ cookiecutter.use_config }}'.lower() != 'y':
    remove_config_files()

# 2. Initialize Git (should be run after all file have been modified or deleted)
if '{{ cookiecutter.use_git }}'.lower() == 'y':
    init_git()
else:
    remove_file('.gitignore')

'''
Does the following:

1. Inits git if used
2. Deletes dockerfiles if not going to be used
3. Deletes config utils if not needed
'''
from __future__ import print_function
import os
import shutil
from subprocess import Popen

# Get the root project directory
PROJECT_DIRECTORY = os.path.realpath(os.path.curdir)


def remove_file(filename):
    '''
    generic remove file from project dir
    '''
    fullpath = os.path.join(PROJECT_DIRECTORY, filename)
    if os.path.exists(fullpath):
        os.remove(fullpath)

def init_git():
    '''
    Initialises git on the new project folder
    '''
    GIT_COMMANDS = [
        ['git', 'init'],
        ['git', 'add', '.'],
        ['git', 'commit', '-a', '-m', 'Initial Commit.']
    ]

    for command in GIT_COMMANDS:
        git = Popen(command, cwd=PROJECT_DIRECTORY)
        git.wait()


def remove_config_files():
    '''
    Removes files needed for viper config utils
    '''
    remove_file(os.path.join(
        '{{ cookiecutter.package_name }}', 'config.py'
    ))

# 1. Remove viper config if not seleted
if '{{ cookiecutter.use_config }}'.lower() != 'y':
    remove_config_files()

# 2. Initialize Git (should be run after all file have been modified or deleted)
if '{{ cookiecutter.use_git }}'.lower() == 'y':
    init_git()
else:
    remove_file('.gitignore')

Does the following:
 
 1. Inits git if used
 2. Deletes dockerfiles if not going to be used
 3. Deletes config utils if not needed # Get the root project directory generic remove file from project dir Initialises git on the new project folder Removes files needed for viper config utils # 1. Remove viper config if not seleted # 2. Initialize Git (should be run after all file have been modified or deleted)