-
Notifications
You must be signed in to change notification settings - Fork 3
/
format_html_schedule.py
executable file
·30 lines (26 loc) · 1.18 KB
/
format_html_schedule.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
#!/usr/bin/env python
# Reformat an old-style schedule as HTML.
# Provided under the terms of the MIT License as stated in LICENSE.txt.
from course_selection import Preferences, Schedule, read_combined_file
from solve_schedule import format_schedules_html
from optparse import OptionParser
if __name__=="__main__":
usage = "%prog <offerings> <schedule>\n%prog -p <preference file> <schedule>"
parser = OptionParser(usage=usage)
parser.add_option('-p', '--preferences', dest="preference_file", default="",
help="obtain student preferences from single file")
(opts, args) = parser.parse_args()
if opts.preference_file != "":
if len(args) != 1:
parser.error("one argument required with option '-p': schedule")
selection_file = args[0]
offering, preferences = read_combined_file(opts.preference_file)
schedule = Schedule(selection_file, lenient=True)
else:
if len(args) != 2:
parser.error("two arguments required: course offering, and schedule")
data_dir, selection_file = args[0], args[1]
offering = Preferences(data_dir)
schedule = Schedule(selection_file, lenient=True)
solutions = [(schedule, 0)]
format_schedules_html(offering, schedule, -1, None, opts)