cleaner
This commit is contained in:
2 files changed
+32
-20
No files matched your search
@@ -1,6 +1,9 @@
|
||||
#! python
|
||||
from prettytable import PrettyTable
|
||||
from typing import Tuple
|
||||
from time import time, sleep
|
||||
import itertools
|
||||
import threading
|
||||
import json
|
||||
import sys
|
||||
|
||||
@@ -11,6 +14,15 @@ from util.generateCourses import getSampleCourses
|
||||
# Import Algorithm
|
||||
from scheduleGenerator.generator import generateScheduleV3
|
||||
|
||||
done = False
|
||||
|
||||
def processing():
|
||||
for c in itertools.cycle(['|', '/', '-', '\\']):
|
||||
if done: break
|
||||
sys.stdout.write(f'\rProcessing {c}')
|
||||
sys.stdout.flush()
|
||||
sleep(0.1)
|
||||
|
||||
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
||||
# Error Table calulation / output
|
||||
f = open('./output/conflicts.json')
|
||||
@@ -34,14 +46,23 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
||||
if __name__ == '__main__':
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print("Processing...\n")
|
||||
|
||||
print()
|
||||
|
||||
st = time() # Start time
|
||||
t = threading.Thread(target=processing)
|
||||
t.start() # Start animation
|
||||
|
||||
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
|
||||
samplemockCourses = getSampleCourses("./sample_data/course_selection_data.csv", True)
|
||||
timetable = {}
|
||||
timetable["Version"] = 3
|
||||
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
|
||||
|
||||
done = True # End Animation
|
||||
et = time() # End time
|
||||
elapsed_time = round((et - st), 3) # Execution time
|
||||
print(f'\n\nDone - Finished in {elapsed_time} seconds\n')
|
||||
|
||||
errors, _, _ = errorOutput(sampleStudents)
|
||||
print(errors)
|
||||
|
||||
@@ -69,5 +90,3 @@ if __name__ == '__main__':
|
||||
|
||||
with open("./output/timetable.json", "w") as outfile:
|
||||
json.dump(timetable, outfile, indent=2)
|
||||
|
||||
print("\nDone")
|
||||
Reference in new issue
Block a user