Skip to content

Commit 298dbdb

Browse files
committed
formatted files
1 parent 587e03d commit 298dbdb

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

src/helpers.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66

77
def send_request(
8-
session: Session, url: str, method: str = "GET", json: dict[str, Any] = {}, headers: dict[str, str] = {}
8+
session: Session,
9+
url: str,
10+
method: str = "GET",
11+
json: dict[str, Any] = {},
12+
headers: dict[str, str] = {},
913
) -> Response:
1014
try:
1115
resp = send_request_helper(session, url, method, json, headers)
@@ -42,7 +46,11 @@ def send_request(
4246

4347

4448
def send_request_helper(
45-
session: Session, url: str, method: str, json: dict[str, Any], headers: dict[str, str]
49+
session: Session,
50+
url: str,
51+
method: str,
52+
json: dict[str, Any],
53+
headers: dict[str, str],
4654
) -> Response:
4755
timeout = 2
4856
if method == "GET":

src/parse.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
import re
66
from typing import Any
77

8+
89
def parse_subject_page(
9-
html: str, data: dict[str, dict[str, Any]], include_ratings: bool = False, ratings_cache: dict[str, dict[str, int] | None] = {}
10+
html: str,
11+
data: dict[str, dict[str, Any]],
12+
include_ratings: bool = False,
13+
ratings_cache: dict[str, dict[str, int] | None] = {},
1014
) -> dict[str, str]:
1115
soup = BeautifulSoup(html, "html.parser")
1216
table_rows = soup.find_all("tr", class_=["odd", "even"])
@@ -72,7 +76,9 @@ def parse_crn_page(html: str, data: dict[str, dict[str, Any]]) -> None:
7276

7377

7478
def get_instructors(
75-
instructors_str: str, include_ratings: bool, ratings_cache: dict[str, dict[str, int] | None]
79+
instructors_str: str,
80+
include_ratings: bool,
81+
ratings_cache: dict[str, dict[str, int] | None],
7682
) -> list[dict[str, Any]] | None:
7783
if instructors_str == "STAFF":
7884
return None
@@ -133,7 +139,9 @@ def get_max_enroll(td: Tag) -> str:
133139
span = td.contents[0]
134140

135141
if not isinstance(span, Tag):
136-
raise Exception("Max enrollment HTML span tag inside td not structured as expected")
142+
raise Exception(
143+
"Max enrollment HTML span tag inside td not structured as expected"
144+
)
137145

138146
title_attr = span.attrs["title"]
139147

src/ratings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def search_professors(professor_name: str) -> list[dict[str, dict[str, str]]]:
4040
headers={"Authorization": AUTHORIZATION_HEADER},
4141
)
4242

43-
return cast(list[dict[str, dict[str, str]]], response.json()["data"]["newSearch"]["teachers"]["edges"])
43+
return cast(
44+
list[dict[str, dict[str, str]]],
45+
response.json()["data"]["newSearch"]["teachers"]["edges"],
46+
)
4447

4548

4649
def get_ratings(id: str) -> dict[str, Any]:

src/scrape.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import config
1010

1111

12-
def scrape(include_ratings: bool = False, all_colleges: bool = False) -> dict[str, dict[str, Any]]:
12+
def scrape(
13+
include_ratings: bool = False, all_colleges: bool = False
14+
) -> dict[str, dict[str, Any]]:
1315
session = Session()
1416
data: dict[str, dict[str, Any]] = {}
1517

@@ -46,7 +48,9 @@ def go_to_college_page(session: Session, college_code: str) -> Response:
4648
return send_request(session, config.get_college_page_url(college_code))
4749

4850

49-
def scrape_all_subjects(session: Session, data: dict[str, dict[str, Any]], html: str, include_ratings: bool) -> dict[str, dict[str, Any]]:
51+
def scrape_all_subjects(
52+
session: Session, data: dict[str, dict[str, Any]], html: str, include_ratings: bool
53+
) -> dict[str, dict[str, Any]]:
5054
try:
5155
with open("cache/extra_course_data_cache.json", "r") as f:
5256
extra_course_data_cache = json.load(f)

0 commit comments

Comments
 (0)