-
Notifications
You must be signed in to change notification settings - Fork 3
/
examtimetable.py
executable file
·46 lines (33 loc) · 1.23 KB
/
examtimetable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import json
import examtimetable
DESC = "Generates a feasible examination timetable given examination data"
def getArgs():
parser = argparse.ArgumentParser(description=DESC)
parser.add_argument("file")
return parser.parse_args()
def main():
args = getArgs()
with open(args.file) as f:
data = json.load(f)
exams = {}
for exam in data['exams']:
temp = examtimetable.Exam(exam['id'], exam['name'], exam['faculty'],
exam['professor'], exam['room_type'],
exam['students'],
availabilities=exam['availabilities'],
dependencies=exam['dependencies'])
exams[exam['id']] = temp
rooms = {}
for room in data['rooms']:
temp = examtimetable.Room(room['id'], room['name'],
room['faculty'], room['capacity'],
room['room_type'])
rooms[room['id']] = temp
timetable = examtimetable.Timetable(data['timeslots'], exams, rooms)
timetable.schedule()
timetable.print_timetable()
if __name__ == '__main__':
main()