more linux compatible good practice stuff?

This commit is contained in:
SowinskiBraeden committed 2022-10-26 10:15:42 -07:00
1 parent 337dbac2db
commit bf09b095f3
7 files changed
+33 -22

No files matched your search

Regular → Executable
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3.11
import json import json
with open('./output/students.json') as f: students = json.load(f) with open('./output/students.json') as f: students = json.load(f)
Regular → Executable
+5 -2
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3.11
import json import json
import random import random
from inspect import currentframe from inspect import currentframe
@@ -589,7 +589,7 @@ def generateScheduleV3(
return running return running
if __name__ == '__main__': def main():
print("Processing...") print("Processing...")
sampleStudents = getSampleStudents(True) sampleStudents = getSampleStudents(True)
@@ -602,3 +602,6 @@ if __name__ == '__main__':
json.dump(timetable, outfile, indent=2) json.dump(timetable, outfile, indent=2)
print("Done") print("Done")
if __name__ == '__main__':
main()
Regular → Executable
+5 -4
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3.113.11
from os.path import exists as file_exists from os.path import exists as file_exists
from prettytable import PrettyTable from prettytable import PrettyTable
from typing import Tuple from typing import Tuple
@@ -53,15 +53,14 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
return t, conflicts["Critical"], conflicts["Acceptable"] return t, conflicts["Critical"], conflicts["Acceptable"]
if __name__ == '__main__': def main():
showError = False showError = False
noAnim = False noAnim = False
for e in sys.argv: for e in sys.argv:
if e.lower().replace('_', '') == 'showerror': showError = True if e.lower().replace('_', '') == 'showerror': showError = True
if e.lower().replace('_', '') == 'noanim': noAnim = True if e.lower().replace('_', '') == 'noanim': noAnim = True
if len(sys.argv) in (1, 2) and sys.argv[1].lower() not in ('no_refresh', 'errors'): if (len(sys.argv) > 1 and sys.argv[1] not in ('no_refresh', 'errors')) or len(sys.argv) == 1:
print() print()
st = time() # Start time st = time() # Start time
@@ -185,3 +184,5 @@ if __name__ == '__main__':
print("Invalid argument") print("Invalid argument")
exit() exit()
if __name__ == '__main__':
main()
Regular → Executable
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3.11
# Define global debug function # Define global debug function
debug = lambda data : print(f'>> Debug: {data}') if type(data) == str else print('>> Debug: ', data) debug = lambda data : print(f'>> Debug: {data}') if type(data) == str else print('>> Debug: ', data)
Regular → Executable
+11 -8
View File
@@ -1,12 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python3.11
import json import json
# Get students
try:
with open("../output/students.json", 'r') as studentFile: students = json.load(studentFile)
except FileNotFoundError:
with open("./output/students.json", 'r') as studentFile: students = json.load(studentFile)
flex = ("XAT--12A-S", "XAT--12B-S") flex = ("XAT--12A-S", "XAT--12B-S")
most_frequent = lambda l : max(set(l), key = l.count) most_frequent = lambda l : max(set(l), key = l.count)
@@ -23,7 +17,13 @@ def getEstimatedGrade(pupil: dict) -> int:
return None if len(grades) == 0 else most_frequent(grades) # Final estimate of grade return None if len(grades) == 0 else most_frequent(grades) # Final estimate of grade
if __name__ == '__main__': def main():
# Get students
try:
with open("../output/students.json", 'r') as studentFile: students = json.load(studentFile)
except FileNotFoundError:
with open("./output/students.json", 'r') as studentFile: students = json.load(studentFile)
# Define students grade level # Define students grade level
for student in students: for student in students:
student["gradelevel"] = getEstimatedGrade(student) student["gradelevel"] = getEstimatedGrade(student)
@@ -33,3 +33,6 @@ if __name__ == '__main__':
except FileNotFoundError: except FileNotFoundError:
with open('./output/students/json', 'w') as studnetFile: with open('./output/students/json', 'w') as studnetFile:
json.dump(students, studentFile, indent=2) json.dump(students, studentFile, indent=2)
if __name__ == '__main__':
main()
Regular → Executable
+5 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3.11
import json import json
import csv import csv
@@ -28,9 +28,11 @@ def getSampleCourses(data_dir, log=False) -> dict:
return realCourses return realCourses
def main():
if __name__ == '__main__':
courseSet: dict = getSampleCourses("../sample_data/course_selection_data.csv") courseSet: dict = getSampleCourses("../sample_data/course_selection_data.csv")
with open("../output/courses.json", "w") as outfile: with open("../output/courses.json", "w") as outfile:
json.dump(courseSet, outfile, indent=2) json.dump(courseSet, outfile, indent=2)
if __name__ == '__main__':
main()
Regular → Executable
+5 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3.11
import json import json
import csv import csv
from util.estimateGrade import getEstimatedGrade from util.estimateGrade import getEstimatedGrade
@@ -63,11 +63,13 @@ def getSampleStudents(data_dir: str, log: bool = False) -> list[dict]:
return mockStudents return mockStudents
def main():
if __name__ == '__main__':
studentRequests: list[dict] = getSampleStudents("../sample_data/course_selection_data.csv") studentRequests: list[dict] = getSampleStudents("../sample_data/course_selection_data.csv")
with open("../output/students.json", "w") as outfile: with open("../output/students.json", "w") as outfile:
json.dump(studentRequests, outfile, indent=2) json.dump(studentRequests, outfile, indent=2)
print("done") print("done")
if __name__ == '__main__':
main()