From 98bfe6e220c797f99017d9aceb759a1672ea6620 Mon Sep 17 00:00:00 2001 From: "Y.H LIEN" <85728908+LIEN-YUHSIANG@users.noreply.github.com> Date: Sat, 22 Jul 2023 17:29:07 +0900 Subject: [PATCH] fix: fix get eval criteria (#306) * fix-get-eval-criteria * fix: fix get-eval-criteria --- src/lambda/get-course/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lambda/get-course/utils.py b/src/lambda/get-course/utils.py index 612a4b1f0..f11d1fe88 100644 --- a/src/lambda/get-course/utils.py +++ b/src/lambda/get-course/utils.py @@ -149,7 +149,7 @@ def to_half_width(s): return "" return unicodedata.normalize('NFKC', s) - +# Fix the problem over here to get the correct evaluation criteria in the waseda time def get_eval_criteria(parsed): """ Get the evaluation criteria from course detail page @@ -171,13 +171,18 @@ def get_eval_criteria(parsed): # Case 2: 2 or more rows for r in rows[1:]: elem = r.getchildren() - kind = elem[0].text + # kind = elem[0].text + # New code to deal with the new line character + kind = elem[0].text.rstrip() percent = elem[1].text.strip()[:-1] or -1 try: percent = int(percent) except ValueError: logging.warning(f"Unable to parse percent: {percent}") - criteria = to_half_width(elem[2].text) + # criteria = to_half_width(elem[2].text) + # New code to deal with the breakline + criteria_elements = elem[2].xpath('.//text()') + criteria = to_half_width(''.join(criteria_elements)) evals.append({ "type": to_enum(eval_type_map)(kind), "percent": percent,