@@ -210,16 +210,14 @@ def parse_quarter_info(
210210 dict[str, dict[str, tuple[int, int]]]: The parsed quarter info.
211211 """
212212
213- quarter_info : str = course . get ( "quarter_information" , "" ) # type: ignore
213+ quarter_info : str
214214
215- if term == Term .FA and "quarter_information_fall" in course :
216- quarter_info = course ["quarter_information_fall" ] # type: ignore
217- elif term == Term .JA and "quarter_information_IAP" in course :
218- quarter_info = course ["quarter_information_IAP" ] # type: ignore
219- elif term == Term .SP and "quarter_information_spring" in course :
220- quarter_info = course ["quarter_information_spring" ] # type: ignore
221- elif term == Term .SU and "quarter_information_summer" in course :
222- quarter_info = course ["quarter_information_summer" ] # type: ignore
215+ if any (f"quarter_information_{ t .value } " in course for t in Term ):
216+ # This course has quarter information by term, so look up the one for this term
217+ quarter_info = course .get (f"quarter_information_{ term .value } " , "" )
218+ else :
219+ # Fall back to general quarter information
220+ quarter_info = course .get ("quarter_information" , "" )
223221
224222 if quarter_info :
225223 quarter_info_list = quarter_info .split ("," )
@@ -358,30 +356,26 @@ def get_course_data(
358356 if term .name not in raw_class ["terms" ]: # type: ignore
359357 return False
360358
361- has_schedule = "schedule" in course
359+ has_schedule = True
362360
363361 # tba, sectionKinds, lectureSections, recitationSections, labSections,
364362 # designSections, lectureRawSections, recitationRawSections, labRawSections,
365363 # designRawSections
366- if has_schedule :
367- try :
368- if term == Term .FA and "schedule_fall" in course :
369- raw_class .update (
370- parse_schedule (course ["schedule_fall" ]) # type: ignore
371- )
372- elif term == Term .JA and "schedule_IAP" in course :
373- raw_class .update (parse_schedule (course ["schedule_IAP" ])) # type: ignore
374- elif term == Term .SP and "schedule_spring" in course :
375- raw_class .update (
376- parse_schedule (course ["schedule_spring" ]) # type: ignore
377- )
378- else :
379- raw_class .update (parse_schedule (course ["schedule" ])) # type: ignore
380- except ValueError as val_err :
381- # if we can't parse the schedule, warn
382- # NOTE: parse_schedule will raise a ValueError
383- print (f"Can't parse schedule { course_code } : { val_err !r} " )
384- has_schedule = False
364+ try :
365+ if any (f"schedule_{ t .value } " in course for t in Term ):
366+ # This course has schedule information by term, so look up the one for this term
367+ raw_class .update (parse_schedule (course [f"schedule_{ term .value } " ]))
368+ else :
369+ # Fall back to general quarter information
370+ raw_class .update (parse_schedule (course ["schedule" ]))
371+ except KeyError :
372+ has_schedule = False
373+ except ValueError as val_err :
374+ # if we can't parse the schedule, warn
375+ # NOTE: parse_schedule will raise a ValueError
376+ print (f"Can't parse schedule { course_code } : { val_err !r} " )
377+ has_schedule = False
378+
385379 if not has_schedule :
386380 raw_class .update (
387381 {
0 commit comments