neat format all functions

This commit is contained in:
SowinskiBraeden committed 2022-11-30 10:26:30 -08:00
1 parent f215a3a147
commit c58d18ed64
4 files changed
+33 -11

No files matched your search

+16 -7
View File
@@ -8,7 +8,14 @@ from app.util.estimateGrade import getGrade
# Takes in information to create or add a new conflict # Takes in information to create or add a new conflict
# Returns if the particular student has a previous error # Returns if the particular student has a previous error
def newConflict(pupilNum: str, email: str, conflictType: str, code: str, description: str, logs: dict) -> bool: def newConflict(
pupilNum: str,
email: str,
conflictType: str,
code: str,
description: str,
logs: dict
) -> bool:
exists = True if pupilNum in logs else False exists = True if pupilNum in logs else False
log = { log = {
"Pupil #": pupilNum, "Pupil #": pupilNum,
@@ -17,18 +24,20 @@ def newConflict(pupilNum: str, email: str, conflictType: str, code: str, descrip
"Code": code, "Code": code,
"Conflict": description "Conflict": description
} }
if exists: logs[pupilNum].append(log) logs[pupilNum] = [log] if not exists else logs[pupilNum].append(log)
else: logs[pupilNum] = [log]
return exists if conflictType == "Critical" else False return exists if conflictType == "Critical" else False
def insertConflictSolutions(pupilNum: str, logs: dict, data: dict) -> None: def insertConflictSolutions(
log = logs[pupilNum] pupilNum: str,
for conflict in log: logs: dict,
data: dict
) -> None:
for conflict in logs[pupilNum]:
if conflict["Type"] == "Critical": if conflict["Type"] == "Critical":
conflict["Missing"] = data conflict["Missing"] = data
break break
# V3 differs a lot by V1/2 as it does not focus on fitting the classes # V3 diffelogrs a lot by V1/2 as it does not focus on fitting the classes
# into the time table first. # into the time table first.
# It starts by trying to get all classes full and give all students a full class list. # It starts by trying to get all classes full and give all students a full class list.
# Then it starts to attempt to fit all classes into a timetable, making corretions along # Then it starts to attempt to fit all classes into a timetable, making corretions along
+9 -2
View File
@@ -4,7 +4,10 @@ from app.util.globals import flex
import xlsxwriter import xlsxwriter
import docx import docx
def putMasterTimetable(table: dict, output_dir: str='./output/final') -> None: def putMasterTimetable(
table: dict,
output_dir: str = './output/final'
) -> None:
workbook = xlsxwriter.Workbook(f'{output_dir}/master_timetable.xlsx') workbook = xlsxwriter.Workbook(f'{output_dir}/master_timetable.xlsx')
worksheet = workbook.add_worksheet() worksheet = workbook.add_worksheet()
@@ -32,7 +35,11 @@ def putMasterTimetable(table: dict, output_dir: str='./output/final') -> None:
workbook.close() workbook.close()
def putScheduleToWord(courses: dict, student: dict, output_dir: str='./output/final/student_schedules') -> None: def putScheduleToWord(
courses: dict,
student: dict,
output_dir: str = './output/final/student_schedules'
) -> None:
# create an instance of a word doc. # create an instance of a word doc.
doc = docx.Document() doc = docx.Document()
+4 -1
View File
@@ -40,7 +40,10 @@ def getCourses(
return courses return courses
# Writes all course data to csv file # Writes all course data to csv file
def writeCoursesToCSV(courses: dict, output_dir: str='./output/raw/csv/courses.csv') -> None: def writeCoursesToCSV(
courses: dict,
output_dir: str = './output/raw/csv/courses.csv'
) -> None:
with open(output_dir, 'w') as file: with open(output_dir, 'w') as file:
writer = csv.writer(file) writer = csv.writer(file)
# Write header # Write header
+4 -1
View File
@@ -60,7 +60,10 @@ def getStudents(
return students return students
# Writes all students data to csv file # Writes all students data to csv file
def writeStudentsToCSV(students: dict, output_dir: str='./output/raw/csv/students.csv') -> None: def writeStudentsToCSV(
students: dict,
output_dir: str = './output/raw/csv/students.csv'
) -> None:
with open(output_dir, 'w') as file: with open(output_dir, 'w') as file:
writer = csv.writer(file) writer = csv.writer(file)
# Write header # Write header