<commit_before>#!/bin/bash

black='\E[30m'
red='\E[31m'
green='\E[32m'
yellow='\E[33m'
blue='\e[36m'
magenta='\E[35m'
cyan='\E[36m'
white='\E[37m'
normal='\e[0m'
bold='\e[1m'

project_name=$1
base_dir=$2
install_mode=$3
project_dir=$base_dir'/'$project_name
mogo_dir=$base_dir
modpath=$4

title() {
		val=$1$bold$2$normal
		val+=' '
		val+=$3
		echo -e $val
	}

ok() {
		val='[ '$1$bold'Ok'$normal' ] '$2
		echo -e $val
	}

option(	) {
	val='[ '$blue'Option'$normal' ] '$1
	echo -e $val		
	}

check() {
	val='['$blue'x'$normal'] '$1
	echo -e $val		
	}

dot	( ) {
	val=$blue'# '$normal$1
	echo -e $val		
	}

error 	( ) {
	val='['$red' Error '$normal'] '$1
	echo -e $val		
	}

if 	[ $install_mode == 'dev' ] 	
    then
    	check 'Dev mode is enabled'
fi

if [ $install_mode != 'noinstall' ]
	then
		# create virtualenv 
		title $yellow "1." "Create virtualenv"
		echo "Creating virualenv ..."
		virtualenv --no-site-packages . && source bin/activate
		echo "Upgrading pip if necessary ..."
		pip install --upgrade pip
		ok $green "Virtualenv setup"
fi
source bin/activate

# create project
title $yellow "2." "Install Django and create the project"
echo "Installing Django ..."
pip install  "django"
echo -e "Creating the project "$bold$project_name$normal
django-admin startproject $project_name
cd $project_name
ok $green "Project created"

if [ $install_mode != 'noinstall' ]
	then
	# install modules
	title $yellow "3." "Install the python modules"
	dot "Installing Pillow image processing library ..."
	pip install pillow
	dot "Installing content management modules ..."
	pip install django-ckeditor django-jssor django-alapage django-codemirror2 django-filebrowser-no-grappelli
	dot "Installing Zinnia blog"
	pip install django-blog-zinnia
	pip install git+https://github.com/django-blog-zinnia/zinnia-theme-bootstrap.git
	dot "Installing utilities ..."
	pip install sorl-thumbnail ipython python-memcached bleach django-braces django-bootstrap-form django-bootstrap3 django-mptt django-debug-toolbar django-app-namespace-template-loader django-system-monitor django-extensions Werkzeug django-autofixture django-dirtyedit django-mqueue django-allauth django-reversion django-mbase
	# reversion option
else
	if 	[ $install_mode == 'dev' ]
	    then
			option "Install developpement modules"
	       	pip install pytest-django pytest-cov coverage
	        cd $project_dir
			git clone https://github.com/synw/django-qcf.git && mv django-qcf/qcf . && rm -rf django-qcf
	ok $green "Python modules installed"
	fi
fi 

# get static files
title $yellow "4." "Get third party static files"
echo "Creating static directories ..."
mkdir static
cd static && mkdir js && mkdir icons
echo "Getting Jquery ..."
if [ $install_mode != 'noinstall' ]
	then
		cd js && wget http://code.jquery.com/jquery-2.1.4.min.js
fi
ok $green "External static files installed"

# install Mogo files
title $yellow "5." "Install Mogo staticfiles and templates"
cd $modpath
echo "Copying staticfiles ..."
cp -r static/* $project_dir"/static"
echo "Creating media directories ..."
cd $project_dir
mkdir media
mkdir media/uploads #~ for filebrowser
mkdir media/jssor
mkdir media/jssor/thumbnails
echo "Copying templates ..."
cd $modpath
cp -r  templates $project_dir
cd $base_dir
ok $green "Static files and templates installed"

# leave the rest to the python script and finish up
title $yellow "6." "Generate settings"
settings=$project_dir'/'$project_name'/settings.py'
rm $settings
sp=$modpath
# prompt for db
PS3='Database to use > '
options=("Sqlite" "Postgresql" "Mysql")
select dbname in "${options[@]}"
do
    case $dbname in
        "Sqlite")
            check "Sqlite database selected"
            break
            ;;
        "Postgresql")
            check "Postgresql database selected, installing python drivers ..."
            pip install psycopg2
            break
            ;;
        "Mysql")
            check "Mysql database selected, installing python drivers ..."
            pip install mysql-python
            break
            ;;
        *) error "Please select a database to use (1/2/3)";;
    esac
done

# generate settings
sp=$modpath'/create_settings.py'
python  $sp $project_name $base_dir $dbname
echo "Generating settings ..."
echo "Copying urls ..."
cd $modpath
cp urls.py $project_dir'/'$project_name
ok $green "Settings and urls generated for project "$project_name

# final steps
title $yellow "7." "Final step"
read -n 1 -p "Collect staticfiles (Y/n)? " answer
echo ""
[ -z "$answer" ] && answer="default"
if 	[ $answer == 'default' ]
    then
    	settings=$project_dir'/'$project_name'/settings.py'
    	python $modpath'/statics.py' $settings 'collectstatic'
    	cd $project_dir
    	python manage.py collectstatic
    	python $modpath'/statics.py' $settings 'normal'
    else:
    	echo ""
fi
read -n 1 -p "Make the migrations and init site (Y/n)? " answer
[ -z "$answer" ] && answer="default"
if 	[ $answer == 'default' ]
    then
    	python manage.py makemigrations
    	python manage.py migrate
    	python manage.py createsuperuser
   		python manage.py create_homepage
   	else
   		echo ""
fi

# end
endit='[ '
endit+=$bold$yellow"Done"$normal 
endit+=' ]'
endit+=" Install completed"
echo -e $endit



<commit_msg>Corrections<commit_after>#!/bin/bash

black='\E[30m'
red='\E[31m'
green='\E[32m'
yellow='\E[33m'
blue='\e[36m'
magenta='\E[35m'
cyan='\E[36m'
white='\E[37m'
normal='\e[0m'
bold='\e[1m'

project_name=$1
base_dir=$2
install_mode=$3
project_dir=$base_dir'/'$project_name
mogo_dir=$base_dir
modpath=$4

title() {
		val=$1$bold$2$normal
		val+=' '
		val+=$3
		echo -e $val
	}

ok() {
		val='[ '$1$bold'Ok'$normal' ] '$2
		echo -e $val
	}

option(	) {
	val='[ '$blue'Option'$normal' ] '$1
	echo -e $val		
	}

check() {
	val='['$blue'x'$normal'] '$1
	echo -e $val		
	}

dot	( ) {
	val=$blue'# '$normal$1
	echo -e $val		
	}

error 	( ) {
	val='['$red' Error '$normal'] '$1
	echo -e $val		
	}

if 	[ $install_mode == 'dev' ] 	
    then
    	check 'Dev mode is enabled'
fi

if [ $install_mode != 'noinstall' ]
	then
		# create virtualenv 
		title $yellow "1." "Create virtualenv"
		echo "Creating virualenv ..."
		virtualenv --no-site-packages . && source bin/activate
		echo "Upgrading pip if necessary ..."
		pip install --upgrade pip
		ok $green "Virtualenv setup"
fi
source bin/activate

# create project
title $yellow "2." "Install Django and create the project"
echo "Installing Django ..."
pip install  "django"
echo -e "Creating the project "$bold$project_name$normal
django-admin startproject $project_name
cd $project_name
ok $green "Project created"

if [ $install_mode != 'noinstall' ]
	then
	# install modules
	title $yellow "3." "Install the python modules"
	dot "Installing Pillow image processing library ..."
	pip install pillow
	dot "Installing content management modules ..."
	pip install django-ckeditor django-jssor django-alapage django-codemirror2 django-filebrowser-no-grappelli
	dot "Installing Zinnia blog"
	pip install django-blog-zinnia
	pip install git+https://github.com/django-blog-zinnia/zinnia-theme-bootstrap.git
	dot "Installing utilities ..."
	pip install sorl-thumbnail ipython python-memcached bleach django-braces django-bootstrap-form django-bootstrap3 django-mptt django-debug-toolbar django-app-namespace-template-loader django-system-monitor django-extensions Werkzeug django-autofixture django-dirtyedit django-mqueue django-allauth django-reversion django-mbase
	# reversion option
else
	if 	[ $install_mode == 'dev' ]
	    then
			option "Install developpement modules"
	       	pip install pytest-django pytest-cov coverage
	        cd $project_dir
			git clone https://github.com/synw/django-qcf.git && mv django-qcf/qcf . && rm -rf django-qcf
	ok $green "Python modules installed"
	fi
fi 

# get static files
title $yellow "4." "Get third party static files"
echo "Creating static directories ..."
mkdir static
cd static && mkdir js && mkdir icons
echo "Getting Jquery ..."
if [ $install_mode != 'noinstall' ]
	then
		cd js && wget http://code.jquery.com/jquery-2.1.4.min.js
fi
ok $green "External static files installed"

# install Mogo files
title $yellow "5." "Install Mogo staticfiles and templates"
cd $modpath
echo "Copying staticfiles ..."
cp -r static/* $project_dir"/static"
echo "Creating media directories ..."
cd $project_dir
mkdir media
mkdir media/uploads #~ for filebrowser
mkdir media/jssor
mkdir media/jssor/thumbnails
echo "Copying templates ..."
cd $modpath
cp -r  templates $project_dir
cd $base_dir
ok $green "Static files and templates installed"

# leave the rest to the python script and finish up
title $yellow "6." "Generate settings"
settings=$project_dir'/'$project_name'/settings.py'
rm $settings
sp=$modpath
# prompt for db
PS3='Database to use > '
options=("Sqlite" "Postgresql" "Mysql")
select dbname in "${options[@]}"
do
    case $dbname in
        "Sqlite")
            check "Sqlite database selected"
            break
            ;;
        "Postgresql")
            check "Postgresql database selected, installing python drivers ..."
            pip install psycopg2
            break
            ;;
        "Mysql")
            check "Mysql database selected, installing python drivers ..."
            pip install mysql-python
            break
            ;;
        *) error "Please select a database to use (1/2/3)";;
    esac
done

# generate settings
sp=$modpath'/create_settings.py'
python  $sp $project_name $base_dir $dbname
echo "Generating settings ..."
echo "Copying urls ..."
cd $modpath
cp urls.py $project_dir'/'$project_name
ok $green "Settings and urls generated for project "$project_name

# final steps
title $yellow "7." "Final step"
read -n 1 -p "Collect staticfiles (Y/n)? " answer
echo ""
[ -z "$answer" ] && answer="default"
if 	[ $answer == 'default' ]
    then
    	settings=$project_dir'/'$project_name'/settings.py'
    	python $modpath'/statics.py' $settings 'collectstatic'
    	cd $project_dir
    	python manage.py collectstatic
    	python $modpath'/statics.py' $settings 'normal'
    else
    	echo ""
fi
read -n 1 -p "Make the migrations and init site (Y/n)? " answer
[ -z "$answer" ] && answer="default"
if 	[ $answer == 'default' ]
    then
    	python manage.py makemigrations
    	python manage.py migrate
    	python manage.py createsuperuser
   		python manage.py create_homepage
   	else
   		echo ""
fi

# end
endit='[ '
endit+=$bold$yellow"Done"$normal 
endit+=' ]'
endit+=" Install completed"
echo -e $endit




{'fraction_non_alphanumeric': 0.1299532130239664, 'fraction_numerical': 0.009548362455838824, 'mean_word_length': 3.4287526427061312, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5771117', 'n_tokens_mistral': 3688, 'n_tokens_neox': 3475, 'n_words': 1036}