Updated to use functions from gradaudit.py

parent df5a74b3
......@@ -5,8 +5,6 @@ Pass in a transcript in the specified csv format as a command line argument.
"""
from __future__ import print_function
import csv
import re
import sys
import gradaudit
......@@ -28,48 +26,15 @@ def main():
except IOError:
print("transcript not found", file=sys.stderr)
sys.exit(1)
csvr = list(csv.reader(transcript))
student = csvr[0][0]
(degree, major, year, spec) = csvr[1]
try:
req = gradaudit.get_required_courses(degree, major, year)
except IOError:
print('requirements file not found', file=sys.stderr)
sys.exit(1)
student_data = gradaudit.parse_transcript(transcript)
valid_courses = gradaudit.get_courses()
main_contents = gradaudit.gen_main(*student_data)
with open('main.lp', 'w') as main_file:
main_file.write("student(%s,%s).\n" % (student, major))
courses = csvr[2] # list of courses student has taken
taken = '_taken(%s,[' % student
has_taken = str()
for course in courses:
if not course in valid_courses:
print('Warning: %s is not in course.lp' % course)
# include only those courses that could possibly
# counted as electives in the 'taken list' i.e.
# those that are not required.
if not '_req(%s,required).' % course in req:
taken += "%s," % course
has_taken += '_hasTaken(%s,%s).\n' % (student, course)
main_file.write('\n')
taken = taken[:-1]
taken += ']).\n'
main_file.write(has_taken + '\n')
main_file.write(taken + '\n')
# write the student's specialization as a fact if it is
# declared in the transcript
if spec != 'none':
main_file.write('_specialization(%s,%s).\n' % (student, spec))
main_file.write("#include 'counting.lp'.\n")
main_file.write("#include '{0}/{1}/{2}/{1}{2}rules.lp'.\n".format(degree, major, year))
main_file.write('?- _main(%s).\n' % student)
main_file.write(main_contents)
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment