<commit_before># Copyright 2017 <NAME>
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
from flask import *
from werkzeug.utils import *
from Core import *
app = Flask(__name__)
DATABASE = 'database.db'
db = SqliteDatabase(DATABASE)
UPLOAD_FOLDER = ''
ALLOWED_EXTENSIONS = {'csv'}
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER


def allowed_file(filename):
	return '.' in filename and \
		   filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS


@app.route('/export', methods=['GET','POST'])
def docustomexport():
	if request.method == 'POST':
		selector = request.form.get('Select')
		export_file(selector)
		name = selector+'.csv'
		return send_file(name,mimetype=None,as_attachment=True)
	return render_template('export.html')


@app.route('/import', methods=['GET', 'POST'])
def docustomimport():
	if request.method == 'POST':
		selector = request.form.get('Select')
		import_file(selector)
	return render_template('import.html')


@app.route('/favicon.ico')
def favicon():
	return send_from_directory(os.path.join(app.root_path, 'static'),
							   'favicon.ico', mimetype='image/vnd.microsoft.icon')


@app.route("/course/<id>", methods=['GET', 'POST'])
def Coursehist(id):
	list2 = []
	course = Course.get(Course.id==id)
	generation = (CourseGeneration.select().join(Course).where(Course.id == id))
	list1 = informationXchange(generation, list2)
	return render_template("course.html", course=course, generation=generation, list1=list1)


@app.route("/c/<id>", methods=['GET', 'POST'])
def Courseh(id):
	list2 = []
	course = Course.get(Course.code==id)
	generation = (CourseGeneration.select().join(Course).where(Course.code == id))
	list1 = informationXchange(generation, list2)
	return render_template("course.html", course=course, generation=generation, list1=list1)


@app.route("/gen/<id>", methods=['GET', 'POST'])
def gen(id):
	list2 = []
	gen = CourseGeneration.get(CourseGeneration.id == id)
	course = Course.get(Course.code == gen.course.code)
	generation = (CourseGeneration.select().join(Course).where(Course.code == gen.course.code))
	list1 = informationXchange(generation, list2)
	return render_template("course.html", course=course, generation=generation, list1=list1)


@app.route("/profile/<prof_id>/", methods=['GET', 'POST'])
def Profile(prof_id):
	person = Person.get(Person.id == prof_id)
	supervision = (Supervision
				   .select()
				   .join(Mastermany)
				   .where(Mastermany.instructor == prof_id)
				   .order_by(Supervision.semester.desc()))
	projectsupervision = (ProjectSupervision
						  .select()
						  .join(Mastermany)
						  .where(Mastermany.instructor == prof_id)
						  .order_by(ProjectSupervision.semester.desc()))
	offering = (Mastermany
				.select()
				.join(Offering)
				.where(Mastermany.instructor == prof_id)
				.order_by(Offering.semester.desc()))
	list_offering_id = list()
	for x in offering:
		list_offering_id.append(x.oid.id)
		list_offering_id.sort()
	adjustment = (Adjustment
				  .select()
				  .join(Person)
				  .where(Person.id == prof_id)
				  .order_by(Adjustment.id.desc()))
	Stotal = 0
	Atotal = 0
	Ptotal = 0
	Ototal = 0
	Snum = (Supervision
				  .select()
				  .join(Mastermany)
				  .where(Mastermany.instructor == prof_id))
	list_supervision_date = list()
	list_supervision_value = list()
	for num in Snum:
		Ssum = Mastermany.select().where(Mastermany.sid==num.id).get()
		Stotal += num.supervision_class_id.weight*Ssum.split
		list_supervision_date.append(Ssum.sid.semester.year)
		list_supervision_date.append(Ssum.sid.semester.session)
		list_supervision_value.append(num.supervision_class_id.weight * Ssum.split)
	Onum = (Offering
				  .select()
				  .join(Mastermany)
				  .where(Mastermany.instructor == prof_id))
	list_forviewer = dict()
	list_split = dict()
	offering_value_date=list()
	counter =- 1
	for num in Onum:
		counter += 1
		Osum = Mastermany.select().where(Mastermany.oid==num.id).get()
		var1 = weight_calc(Osum.oid.id)
		Ototal += var1*Osum.split
		list_forviewer[Osum.oid.id] = var1
		list_split[Osum.oid.id] = Osum.split
		offering_value_date.append((str(Osum.oid.semester.year)+'0'+str(Osum.oid.semester.session)))
		offering_value_date.append(var1*Osum.split)
	list_project_supervision_date = list()
	list_project_supervision_value = list()
	Pnum = (ProjectSupervision
				  .select()
				  .join(Mastermany)
				  .where(Mastermany.instructor == prof_id))
	for num in Pnum:
		Psum = Mastermany.select().where(Mastermany.pid == num.id).get()
		Ptotal += num.project_class_id.weight*Psum.split
		list_project_supervision_date.append(Psum.pid.semester.year)
		list_project_supervision_date.append(Psum.pid.semester.session)
		list_project_supervision_value.append(num.project_class_id.weight * Psum.split)<commit_msg>Code cleanup PERP-8<commit_after># Copyright 2017 <NAME>
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
from flask import *
from werkzeug.utils import *
from Core import *
app = Flask(__name__)
DATABASE = 'database.db'
db = SqliteDatabase(DATABASE)
UPLOAD_FOLDER = ''
ALLOWED_EXTENSIONS = {'csv'}
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER


def allowed_file(filename):
	return '.' in filename and \
		   filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS


@app.route('/export', methods=['GET','POST'])
def docustomexport():
	if request.method == 'POST':
		selector = request.form.get('Select')
		export_file(selector)
		name = selector+'.csv'
		return send_file(name,mimetype=None,as_attachment=True)
	return render_template('export.html')


@app.route('/import', methods=['GET', 'POST'])
def docustomimport():
	if request.method == 'POST':
		selector = request.form.get('Select')
		import_file(selector)
	return render_template('import.html')


@app.route('/favicon.ico')
def favicon():
	return send_from_directory(os.path.join(app.root_path, 'static'),
							   'favicon.ico', mimetype='image/vnd.microsoft.icon')


@app.route("/course/<id>", methods=['GET', 'POST'])
def Coursehist(id):
	list2 = []
	course = Course.get(Course.id==id)
	generation = (CourseGeneration.select().join(Course).where(Course.id == id))
	list1 = informationXchange(generation, list2)
	return render_template("course.html", course=course, generation=generation, list1=list1)


@app.route("/c/<id>", methods=['GET', 'POST'])
def Courseh(id):
	list2 = []
	course = Course.get(Course.code==id)
	generation = (CourseGeneration.select().join(Course).where(Course.code == id))
	list1 = informationXchange(generation, list2)
	return render_template("course.html", course=course, generation=generation, list1=list1)


@app.route("/gen/<id>", methods=['GET', 'POST'])
def gen(id):
	list2 = []
	gen = CourseGeneration.get(CourseGeneration.id == id)
	course = Course.get(Course.code == gen.course.code)
	generation = (CourseGeneration.select().join(Course).where(Course.code == gen.course.code))
	list1 = informationXchange(generation, list2)
	return render_template("course.html", course=course, generation=generation, list1=list1)


@app.route("/profile/<prof_id>/", methods=['GET', 'POST'])
def Profile(prof_id):
	person = Person.get(Person.id == prof_id)
	supervision = (Supervision
				   .select()
				   .join(Mastermany)
				   .where(Mastermany.instructor == prof_id)
				   .order_by(Supervision.semester.desc()))
	projectsupervision = (ProjectSupervision
						  .select()
						  .join(Mastermany)
						  .where(Mastermany.instructor == prof_id)
						  .order_by(ProjectSupervision.semester.desc()))
	offering = (Mastermany
				.select()
				.join(Offering)
				.where(Mastermany.instructor == prof_id)
				.order_by(Offering.semester.desc()))
	list_offering_id = list()
	for x in offering:
		list_offering_id.append(x.oid.id)
		list_offering_id.sort()
	adjustment = (Adjustment
				  .select()
				  .join(Person)
				  .where(Person.id == prof_id)
				  .order_by(Adjustment.id.desc()))
	Stotal = 0
	Atotal = 0
	Ptotal = 0
	Ototal = 0
	Snum = (Supervision
				  .select()
				  .join(Mastermany)
				  .where(Mastermany.instructor == prof_id))
	list_supervision_date = list()
	list_supervision_value = list()
	for num in Snum:
		Ssum = Mastermany.select().where(Mastermany.sid==num.id).get()
		Stotal += num.supervision_class_id.weight*Ssum.split
		list_supervision_date.append(Ssum.sid.semester.year)
		list_supervision_date.append(Ssum.sid.semester.session)
		list_supervision_value.append(num.supervision_class_id.weight * Ssum.split)
	Onum = (Offering
				  .select()
				  .join(Mastermany)
				  .where(Mastermany.instructor == prof_id))
	list_forviewer = dict()
	list_split = dict()
	offering_value_date = list()
	counter =- 1
	for num in Onum:
		counter += 1
		Osum = Mastermany.select().where(Mastermany.oid==num.id).get()
		var1 = weight_calc(Osum.oid.id)
		Ototal += var1*Osum.split
		list_forviewer[Osum.oid.id] = var1
		list_split[Osum.oid.id] = Osum.split
		offering_value_date.append((str(Osum.oid.semester.year)+'0'+str(Osum.oid.semester.session)))
		offering_value_date.append(var1*Osum.split)
	list_project_supervision_date = list()
	list_project_supervision_value = list()
	Pnum = (ProjectSupervision
				  .select()
				  .join(Mastermany)
				  .where(Mastermany.instructor == prof_id))
	for num in Pnum:
		Psum = Mastermany.select().where(Mastermany.pid == num.id).get()
		Ptotal += num.project_class_id.weight*Psum.split
		list_project_supervision_date.append(Psum.pid.semester.year)
		list_project_supervision_date.append(Psum.pid.semester.session)
		list_project_supervision_value.append(num.project_class_id.weight * Psum.split)
{'fraction_non_alphanumeric': 0.1424368950464984, 'fraction_numerical': 0.006927310685139495, 'mean_word_length': 4.617803837953092, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6829457', 'n_tokens_mistral': 3922, 'n_tokens_neox': 3544, 'n_words': 678}