def getCourseInfo(course_number, semester): url = "https://ug3.technion.ac.il/rishum/course/" + \ str(course_number) + "/" + str(semester) tag = "div" attrs = {"class": "property"} types = "course" properties = getData(url, tag, attrs, types) strip = str.maketrans({"\n": None, "\r": None, "\t": None, "\xa0": " "}) and_trans = str.maketrans({"ו": None, "-": "&"}) or_trans = str.maketrans({"א": "|", "-": None}) temp_course = Course() for prop in properties: sibling = prop.next_sibling.next_sibling.text.translate(strip) if "שם מקצוע" in prop.text: temp_course.set_name(sibling) if "מספר מקצוע" in prop.text: temp_course.set_number(sibling.strip()) if "נקודות" in prop.text: temp_course.set_points(sibling.strip()) if "מקצועות קדם" in prop.text: temp_course.add_dependencies( cutDependencies( sibling.translate(and_trans).translate(or_trans))) if "מקצועות צמודים" in prop.text: temp_course.add_parallel(sibling.split()) if ":מקצועות ללא זיכוי נוסף" in prop.text: temp_course.add_similarities(sibling.split()) if "מקצועות ללא זיכוי נוסף (מוכלים)" in prop.text: temp_course.add_inclusive(sibling.split()) if temp_course.points == 0: temp_course.set_points(get_points_from_gradute(course_number)) return temp_course
def convertDbEnryToCourse(entry): temp_course = Course() temp_course.set_name(entry[0]) temp_course.set_number(entry[1]) temp_course.set_points(entry[2]) temp_course.add_dependencies(pickle.loads(entry[3])) temp_course.add_parallel(pickle.loads(entry[4])) temp_course.add_similarities(pickle.loads(entry[5])) temp_course.add_inclusive(pickle.loads(entry[6])) return temp_course