def compute_all(self): response.content_type = "application/json" r = json.loads(request.params['json']) term = r['term'] requestSectionFilters = self._request_section_filters(r) catalogFilters = [] searchGroups = [] directCourses = [] for course in r['courses']: query = course["course_query"].strip() if query == "": continue courseFilters = self._course_filters(course["options"]) m = self.directRE.match(query) if m: try: courses = Course.coursesFromCode(m.group(1), m.group(2), term,\ sectionFilters=requestSectionFilters) except CourseMissingException, e: return json.dumps({"error": { "type": "no_query_results", "query": query }}) except UWDataError, e: return json.dumps({"error": { "type": "uwdata", "query": query }}) catalogFilters.extend(self._course_catalog_filters(courses, course["options"])) directCourses.extend([e for e in courses\ if all(courseFilter.passes(e) for courseFilter in courseFilters)])
def compute_all(self): response.content_type = "application/json" r = json.loads(request.params['json']) term = r['term'] requestSectionFilters = self._request_section_filters(r) catalogFilters = [] searchGroups = [] directCourses = [] for course in r['courses']: query = course["course_query"].strip() if query == "": continue courseFilters = self._course_filters(course["options"]) m = self.directRE.match(query) if m: try: courses = Course.coursesFromCode(m.group(1), m.group(2), term,\ sectionFilters=requestSectionFilters) except CourseMissingException, e: return json.dumps({ "error": { "type": "no_query_results", "query": query } }) except UWDataError, e: return json.dumps( {"error": { "type": "uwdata", "query": query }}) catalogFilters.extend( self._course_catalog_filters(courses, course["options"])) directCourses.extend([e for e in courses\ if all(courseFilter.passes(e) for courseFilter in courseFilters)])
"type": "no_query_results", "query": query }}) except UWDataError, e: return json.dumps({"error": { "type": "uwdata", "query": query }}) catalogFilters.extend(self._course_catalog_filters(courses, course["options"])) directCourses.extend([e for e in courses\ if all(courseFilter.passes(e) for courseFilter in courseFilters)]) else: courseGroups = [] try: for courseGroup in Course.courseGroupsFromSearch(query, term, sectionFilters=requestSectionFilters): filteredGroup = [e for e in courseGroup if all(courseFilter.passes(e) for courseFilter in courseFilters)] if len(filteredGroup) > 0: courseGroups.append(filteredGroup) except CourseMissingException, e: return json.dumps({"error": { "type": "no_query_results", "query": query }}) except UWDataError, e: return json.dumps({"error": { "type": "uwdata", "query": query }}) catalogFilters.extend(self._course_catalog_filters(chain(*courseGroups), course["options"]))
}) except UWDataError, e: return json.dumps( {"error": { "type": "uwdata", "query": query }}) catalogFilters.extend( self._course_catalog_filters(courses, course["options"])) directCourses.extend([e for e in courses\ if all(courseFilter.passes(e) for courseFilter in courseFilters)]) else: courseGroups = [] try: for courseGroup in Course.courseGroupsFromSearch( query, term, sectionFilters=requestSectionFilters): filteredGroup = [ e for e in courseGroup if all( courseFilter.passes(e) for courseFilter in courseFilters) ] if len(filteredGroup) > 0: courseGroups.append(filteredGroup) except CourseMissingException, e: return json.dumps({ "error": { "type": "no_query_results", "query": query } }) except UWDataError, e: