Created
October 31, 2011 13:00
-
-
Save Ceasar/1327443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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