diff --git a/convert.py b/convert.py index 728ea11..a1b4b61 100644 --- a/convert.py +++ b/convert.py @@ -86,11 +86,18 @@ # courses.json is sorted by dept > course > sec > time block # build data (to be rooms.json) sorted by building > room > class + +#crnlist.json: +#{CRN: [{Building: .., Time:.., RoomNum:..},{Building: .., Time:.., RoomNum:..}]} +crnlist = {} +crnToTitleList = {} for dept in input: for course in dept['courses']: numSecs = len(course['sections']) hasSecs = True if numSecs > 1 else False for sec in course['sections']: + crnlist[sec['crn']] = sec['timeslots'] + crnToTitleList[sec['crn']] = sec['title'] for block in sec['timeslots']: roomName = block['location'] # room name act, cap = sec['act'], sec['cap'] @@ -113,6 +120,9 @@ # Adding sections... beware duplicates and crosslisted! if hasSecs and secNum not in room[time][2]: room[time][2].append(secNum) +with open("crnlist.json", 'w') as file: json.dump(crnlist, file) +with open("crntotitle.json", 'w') as file: json.dump(crnToTitleList, file) + with open("access.json", 'r') as f: access = json.load(f) with open("printers.json", 'r') as f: printers = json.load(f) diff --git a/crnsearch.py b/crnsearch.py new file mode 100644 index 0000000..b317748 --- /dev/null +++ b/crnsearch.py @@ -0,0 +1,32 @@ +import json + +with open("crnlist.json", 'r') as f: + crndata = json.load(f) + +with open("crntotitle.json", 'r') as f: + titles = json.load(f) + +flag = True +while(flag): + crn = input("Enter CRN:") + dataDict = crndata[crn][0] + title = titles[crn] + + print("Course Title: " + title) + print("Instructor: " + dataDict['instructor']) + print(title + " runs " + dataDict['dateStart'] + " to " + dataDict['dateEnd']) + print(title + " meets on " + str(dataDict['days']) + " from " + str(dataDict['timeStart']) + " to " + str(dataDict['timeEnd'])) + print(title + " is held at " + dataDict['location']) + print() + + resFlag = False + while(resFlag == False): + askAgain = input("Search another course? (Y or N)") + if(askAgain == 'Y' or askAgain == 'y'): + print("----------------------------------------") + resFlag = True + elif(askAgain == 'N' or askAgain == 'n'): + print("Thank you for using CRN Search Shell") + resFlag = True + flag = False +