Skip to content

Commit

Permalink
fix: 'parse_race' raising exception instead of returning None
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocanalejas committed Apr 3, 2024
1 parent 9612e04 commit 2ca64c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rscraping/parsers/html/abe.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def parse_race(self, selector: Selector, *, race_id: str, **_) -> Race | None:
t_date = find_date(name)

if not t_date:
raise ValueError(f"{self.DATASOURCE}: no date found for {name=}")
logger.error(f"{self.DATASOURCE}: no date found for {name=}")
return None

normalized_names = normalize_name_parts(normalize_race_name(name))
if len(normalized_names) == 0:
Expand Down
3 changes: 2 additions & 1 deletion rscraping/parsers/html/act.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def parse_race(self, selector: Selector, *, race_id: str, is_female: bool, **_)

t_date = find_date(name)
if not t_date:
raise ValueError(f"{self.DATASOURCE}: no date found for {name=}")
logger.error(f"{self.DATASOURCE}: no date found for {name=}")
return None

gender = GENDER_FEMALE if is_female else GENDER_MALE

Expand Down
3 changes: 2 additions & 1 deletion rscraping/parsers/html/traineras.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def parse_race(self, selector: Selector, *, race_id: str, table: int | None = No
distance = self.get_distance(selector)

if not t_date:
raise ValueError(f"{self.DATASOURCE}: no date found for {name=}")
logger.error(f"{self.DATASOURCE}: no date found for {name=}")
return None

if not name:
logger.error(f"{self.DATASOURCE}: no race found for {race_id=}")
Expand Down

0 comments on commit 2ca64c5

Please sign in to comment.