Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (30 sloc) 1.6 KB
from uwaterlooapi import UWaterlooAPI
from pprint import pprint
import requests
import json
courseCodes = ['AFM', 'ACTSC', 'ANTH', 'AHS', 'APPLS', 'AMATH', 'ARCH', 'ARTS', 'ARBUS',
'AVIA', 'BASE', 'BIOL', 'BME', 'BUS', 'BET', 'CHE', 'CHEM', 'CHINA',
'CMW', 'CIVE', 'CLAS', 'COGSCI', 'CO', 'COMM', 'CS', 'COOP', 'CROAT',
'DAC', 'DRAMA', 'DUTCH', 'EARTH', 'EASIA', 'ECON', 'ECE', 'ENGL', 'EFAS',
'EMLS', 'ENBUS', 'ERS', 'ENVE', 'ENVS', 'FINE', 'FR', 'GENE', 'GEOG', 'GEOE',
'GER', 'GERON', 'GBDA', 'GRK', 'HLTH', 'HIST', 'HRM', 'HUMSC', 'IS', 'INDEV',
'INTST', 'INTTS', 'ITAL', 'ITALST', 'JAPAN', 'JS', 'KIN', 'INTEG', 'KOREA',
'LAT', 'LS', 'MATBUS', 'MSCI', 'MNS', 'MATH', 'MTHEL', 'ME', 'MTE', 'MEDVL',
'MUSIC', 'NE', 'NATST', 'OPTOM', 'PACS', 'PHARM', 'PHIL', 'PHYS', 'PLAN',
'POLSH', 'PSCI', 'PORT', 'PD', 'PDARCH', 'PDPHRM', 'PSCYH', 'PMATH', 'REC',
'RS', 'RUSS', 'REES', 'SCI', 'SCBUS', 'SMF', 'SDS', 'SOCKWK', 'SWREN', 'STV',
'SOC', 'SE', 'SPAN', 'SPCOM', 'STAT', 'SI', 'SYDE', 'UNIV', 'VCULT', 'WS', 'WKRPT']
inputCourse = raw_input("Enter course (e.g. CS135): ")
coursesCanTake = "Your course is a prerequisite to:"
for i in range(0, len(courseCodes)):
for j in range(100, 499):
url = "https://api.uwaterloo.ca/v2/courses/%s/%d/prerequisites.json?key=cf928632b66e3b96622f19a93a0fbdd8" %(courseCodes[i], j)
resp = requests.get(url=url)
data = json.loads(resp.text)
try:
prereqData = data[u'data'][u'prerequisites_parsed']
if inputCourse in prereqData:
coursesCanTake += " %s %d, " %(courseCodes[i], j)
except KeyError:
pass
print coursesCanTake