<commit_before># -*- coding: utf-8 -*-

import random
import sys


class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
    
option = '['+bcolors.OKBLUE+'x'+bcolors.ENDC+']'
    
project_name = sys.argv[1:][0]
base_dir = sys.argv[1:][1]
dbname = sys.argv[1:][2]
install_mode = sys.argv[1:][3]
project_dir = base_dir+'/'+project_name

if dbname != 'Sqlite':
    msg = 'Database user > '
    dbuser = raw_input(msg)
    while not dbuser:
        print "Please provide a database user"
        dbuser = raw_input(msg)
    msg = 'Database password > '
    dbpwd = raw_input(msg)
    while not dbpwd:
        print "Please provide a database password"
        dbpwd = raw_input(msg)

msg = 'What is the timezone of your project? [UTC] > '
timezone = raw_input(msg)
if not timezone:
    timezone = 'UTC'
    
msg = 'What is the language code for your project? [en] > '
language_code = raw_input(msg)
if not language_code:
    language_code = 'en'

msg = 'Debug: [Y/n] > '
debug_msg = raw_input(msg)
debug = True
if debug_msg == 'n' or debug_msg == 'no':
    debug = False

msg = 'Editing mode: Wysiwig or Code [W/c] > '
edit_mode_msg = raw_input(msg)
edit_mode = 'html'
if edit_mode_msg == 'c':
    edit_mode = 'code'
    print option+" Code mode enabled"
if edit_mode == 'code':
    keymap_msg = raw_input(' |----> Editors keymap: None / Vim / Emacs [ N/v/e ] > ')
    keymap = None
    if keymap_msg == 'e':
        keymap = 'emacs'
    elif keymap_msg == 'v':
        keymap = 'vim'

msg = 'Use reversion [Y/n] > '
reversion_msg = raw_input(msg)
use_reversion = True
if reversion_msg in ['n', 'no']:
    use_reversion = False
    print option+" Reversion is disabled"
    
dev_apps = ''
if install_mode == 'dev':
    dev_apps="    'qcf',\n'"

dbuser = ''
dbpwd = ''
databases = {
            'sqlite':"""DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.sqlite3',
                        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
                    }
                }""",
                'postgresql':"""DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.postgresql_psycopg2',
                        'NAME': '"""+project_name+"""',
                        'USER': '"""+dbuser+"""',
                        'PASSWORD': '"""+<PASSWORD>+"""',
                        'HOST': 'localhost',
                        'PORT': '',
                    }
                }""",
                'mysql':"""DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.mysql',
                        'NAME': '"""+project_name+"""',
                        'USER': '"""+dbuser+"""',
                        'PASSWORD': '"""+<PASSWORD>+"""',
                        'HOST': 'localhost',
                        'PORT': '3306',
                    }
                }""",
             }

if dbname == 'Postgresql':
    database = databases['postgresql']
elif dbname == 'Mysql':
    database = databases['mysql']
else:
    database = databases['sqlite']

def secret_key():
    return ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])

file_content = """# -*- coding: utf-8 -*-

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '"""+secret_key()+"""'

# SECURITY WARNING: don't run with debug turned on in production!\n\n"""
if debug is True:
    file_content += 'DEBUG = True\n'
    file_content += 'DEBUG_TOOLBAR = True\n'
else:
    file_content += 'DEBUG = False\n'
    file_content += 'DEBUG_TOOLBAR = False\n'
    
file_content += """

ALLOWED_HOSTS = ['127.0.0.1','localhost']

INSTALLED_APPS = (
    'filebrowser',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',
    'django_extensions',
    'braces',
    'autofixture',
    'bootstrap3',
    'bootstrapform',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'django_comments',
    'mptt',
    'tagging',
    'zinnia_bootstrap',
    'zinnia',
    'sorl.thumbnail',
    'ckeditor',
    'ckeditor_uploader',
    'codemirror2',
    'dirtyedit',
    'reversion',
    'sysmon',
    'mbase',
    'mqueue',
    'alapage',
    'jssor',
    """+dev_apps+"""
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = '"""+project_name+""".urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'zinnia.context_processors.version', 
            ],<commit_msg>Correction<commit_after># -*- coding: utf-8 -*-

import random
import sys


class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
    
option = '['+bcolors.OKBLUE+'x'+bcolors.ENDC+']'
    
project_name = sys.argv[1:][0]
base_dir = sys.argv[1:][1]
dbname = sys.argv[1:][2]
install_mode = sys.argv[1:][3]
project_dir = base_dir+'/'+project_name

if dbname != 'Sqlite':
    msg = 'Database user > '
    dbuser = raw_input(msg)
    while not dbuser:
        print "Please provide a database user"
        dbuser = raw_input(msg)
    msg = 'Database password > '
    dbpwd = raw_input(msg)
    while not dbpwd:
        print "Please provide a database password"
        dbpwd = raw_input(msg)

msg = 'What is the timezone of your project? [UTC] > '
timezone = raw_input(msg)
if not timezone:
    timezone = 'UTC'
    
msg = 'What is the language code for your project? [en] > '
language_code = raw_input(msg)
if not language_code:
    language_code = 'en'

msg = 'Debug: [Y/n] > '
debug_msg = raw_input(msg)
debug = True
if debug_msg == 'n' or debug_msg == 'no':
    debug = False

msg = 'Editing mode: Wysiwig or Code [W/c] > '
edit_mode_msg = raw_input(msg)
edit_mode = 'html'
if edit_mode_msg == 'c':
    edit_mode = 'code'
    print option+" Code mode enabled"
if edit_mode == 'code':
    keymap_msg = raw_input(' |----> Editors keymap: None / Vim / Emacs [ N/v/e ] > ')
    keymap = None
    if keymap_msg == 'e':
        keymap = 'emacs'
    elif keymap_msg == 'v':
        keymap = 'vim'

msg = 'Use reversion [Y/n] > '
reversion_msg = raw_input(msg)
use_reversion = True
if reversion_msg in ['n', 'no']:
    use_reversion = False
    print option+" Reversion is disabled"
    
dev_apps = []
if install_mode == 'dev':
    dev_apps = ['qcf']
    
def get_dev_apps():
    space = '    '
    print space+'# dev apps'
    for app in dev_apps:
        print space+"'"+app+"',"

dbuser = ''
dbpwd = ''
databases = {
            'sqlite':"""DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.sqlite3',
                        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
                    }
                }""",
                'postgresql':"""DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.postgresql_psycopg2',
                        'NAME': '"""+project_name+"""',
                        'USER': '"""+dbuser+"""',
                        'PASSWORD': '"""+<PASSWORD>+"""',
                        'HOST': 'localhost',
                        'PORT': '',
                    }
                }""",
                'mysql':"""DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.mysql',
                        'NAME': '"""+project_name+"""',
                        'USER': '"""+dbuser+"""',
                        'PASSWORD': '"""+<PASSWORD>+"""',
                        'HOST': 'localhost',
                        'PORT': '3306',
                    }
                }""",
             }

if dbname == 'Postgresql':
    database = databases['postgresql']
elif dbname == 'Mysql':
    database = databases['mysql']
else:
    database = databases['sqlite']

def secret_key():
    return ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])

file_content = """# -*- coding: utf-8 -*-

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '"""+secret_key()+"""'

# SECURITY WARNING: don't run with debug turned on in production!\n\n"""
if debug is True:
    file_content += 'DEBUG = True\n'
    file_content += 'DEBUG_TOOLBAR = True\n'
else:
    file_content += 'DEBUG = False\n'
    file_content += 'DEBUG_TOOLBAR = False\n'
    
file_content += """

ALLOWED_HOSTS = ['127.0.0.1','localhost']

INSTALLED_APPS = (
    'filebrowser',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',
    'django_extensions',
    'braces',
    'autofixture',
    'bootstrap3',
    'bootstrapform',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'django_comments',
    'mptt',
    'tagging',
    'zinnia_bootstrap',
    'zinnia',
    'sorl.thumbnail',
    'ckeditor',
    'ckeditor_uploader',
    'codemirror2',
    'dirtyedit',
    'reversion',
    'sysmon',
    'mbase',
    'mqueue',
    'alapage',
    'jssor',"""+get_dev_apps()+"""
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = '"""+project_name+""".urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'zinnia.context_processors.version', 
            ],
{'fraction_non_alphanumeric': 0.15753938484621155, 'fraction_numerical': 0.012669834125197966, 'mean_word_length': 2.384485190409027, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3076179', 'n_tokens_mistral': 4137, 'n_tokens_neox': 3973, 'n_words': 740}