supercontest.core.lines
Logic for fetching and parsing matchup lines.
Functions
Wrapper for all line committing functionality. |
|
Main function to fetch lines - controls which implementation to use. |
|
Hits the official Westgate site and returns its line table as an html string, then coerces it into the proper format. |
|
Fetch lines from Westgate's new PDF-based format (2025+). |
|
Hits the official Westgate site and returns its line table as an html string, then coerces it into the proper format. |
- supercontest.core.lines.commit_lines(verify: bool = True, manual_lines: list[LinesFetch] | None = None) bool
Wrapper for all line committing functionality.
- Parameters:
verify – Checks if lines are already in the db and if datetimes are in the future.
manual_lines – Optional list of manually entered lines to use instead of fetching.
- Returns:
Whether or not lines were committed.
- Raises:
ValueError – If the fetched lines are empty or have old dates.
- supercontest.core.lines.fetch_lines() list[LinesFetch]
Main function to fetch lines - controls which implementation to use.
Currently set to use the PDF-based fetcher for 2025+. Can be switched to use fetch_lines_html() or fetch_lines_selenium() as needed.
- Returns:
The fetched line data.
- Raises:
ValueError – If the fetcher fails.
- supercontest.core.lines.fetch_lines_html() list[LinesFetch]
Hits the official Westgate site and returns its line table as an html string, then coerces it into the proper format. Uses requests and BeautifulSoup.
This is the old implementation used before 2025.
- Returns:
The fetched line data.
- Raises:
ValueError – If called when not in a current week (no lines to fetch).
- supercontest.core.lines.fetch_lines_pdf() list[LinesFetch]
Fetch lines from Westgate’s new PDF-based format (2025+).
This function downloads a PDF from the new Westgate website format and parses it. Used starting in 2025 when Westgate switched from HTML tables to PDF downloads. Now looks for the PDF matching the current week number.
- Returns:
The fetched line data.
- Raises:
ValueError – If PDF cannot be found, downloaded, or parsed.
- supercontest.core.lines.fetch_lines_selenium(driver: Any, week: int = 0) list[LinesFetch]
Hits the official Westgate site and returns its line table as an html string, then coerces it into the proper format.
Note the driver arg is ALWAYS passed by the decorator, which injects and changes the function signature. This messes with linters/typecheckers, so we simply default it to a (never used) chromedriver instance.
- Parameters:
driver – The chrome webdriver, always passed by the decorator.
week – Exposed for testing, if you want to fetch lines from a specific week.
- Returns:
The fetched line data.
- Raises:
ValueError – If called when not in a current week (no lines to fetch).