Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combined loops making jsons, added extra json linking crn to title,python shell for looping crn lookup with keyboard input #2

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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)

Expand Down
32 changes: 32 additions & 0 deletions crnsearch.py
Original file line number Diff line number Diff line change
@@ -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

Loading