Skip to content

Instantly share code, notes, and snippets.

@Ceasar
Created October 31, 2011 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ceasar/1327443 to your computer and use it in GitHub Desktop.
Save Ceasar/1327443 to your computer and use it in GitHub Desktop.
"""A collection of wrappers for API objects in the PennCourseReview API."""
from api import pcr
class CourseHistory(object):
"""A wrapper for coursehistory objects in the PCR API."""
def __init__(self, raw_coursehistory):
self.raw = raw_coursehistory
self.id = raw_coursehistory['id']
self.name = raw_coursehistory['name']
self.aliases = raw_coursehistory['aliases']
@property
def courses(self):
return [Course(pcr('course', raw_course['id'])) for raw_course in self.raw['courses']] #this will need a Course object to work
@property
def subtitle(self):
return self.aliases[0]
def __eq__(self, other):
return self.id == other.id
@property
def instructors(self):
return set([instructor for course in self.courses for instructor in course.instructors]) #you'll need to implement course.instructors
def __hash__(self):
return hash(self.id)
def __repr__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment