Compare commits

...

3 Commits

Author SHA1 Message Date
powe97 0f3652d8cc
Lint 2024-03-06 16:16:36 -06:00
powe97 7c87221256
Fix typo 2024-03-06 16:16:23 -06:00
powe97 69d8946f37
Improve credit count parsing 2024-03-06 16:13:13 -06:00
1 changed files with 6 additions and 3 deletions

View File

@ -232,9 +232,12 @@ def parse_course_td(td, note=None):
cr_delim = (
len(course_info)
- 1
- list(bool(re.search(r"\(", s)) for s in course_info[::-1]).index(True)
- list(
bool(re.search(r"^\([0-9]", s.strip())) for s in course_info[::-1]
).index(True)
)
except ValueError:
assert bool(re.search(r"[0-9]\)", course_info[-1]))
except (ValueError, AssertionError):
cr_delim = len(course_info)
# note serves as a credit count override, since the RPI-side credit counts
@ -245,7 +248,7 @@ def parse_course_td(td, note=None):
"catalog": td.find_element(By.TAG_NAME, "span").text,
}
if note is None:
out.update({"credits": str(" ".join(course_info[cr_delim:])[1:-1])}),
out.update({"credits": str(" ".join(course_info[cr_delim:])[1:-1]).strip()}),
return out
else:
out.update({"note": note})