Skip to content

Commit

Permalink
feat: enabling multi-line evaluation criteria scraping (#291)
Browse files Browse the repository at this point in the history
* feat: adding regex to scrape multiple eval criterias

* feat: enabling multiple line of criteria
  • Loading branch information
JasonNotJson authored May 17, 2023
1 parent 4582b13 commit 69a68b1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lambda/syllabus-scraper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,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_context()
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_context())
cleaned_criteria = remove_format_chars(criteria)
evals.append({
"t": to_enum(eval_type_map)(kind),
"p": percent,
"c": criteria
"c": cleaned_criteria
})
return evals

Expand Down Expand Up @@ -350,3 +351,8 @@ def get_expire_date():
next_dt = cron_schedule[idx + 1].split('-')
next_time = now.replace(month=int(next_dt[0]), day=int(next_dt[1]))
return next_time


def remove_format_chars(line):
cleaned_line = re.sub(r'[\n\r\t]', ' ', line)
return cleaned_line

0 comments on commit 69a68b1

Please sign in to comment.