From a0c01e2a31e6f43560d2cf00933bd0ad2485e51c Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 1 Dec 2024 07:53:37 -0500 Subject: [PATCH] Some style change I made a year ago --- download.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/download.py b/download.py index 6dde19f..84132b9 100644 --- a/download.py +++ b/download.py @@ -76,9 +76,11 @@ def get_puzzle_source(date: PuzzleDate, token: str) -> str: return res.text + def build_cookies(token: str) -> dict[str, str]: return {"session": token} + def extract_sample_inputs(puzzle_source: str) -> List[str]: LOG.debug("Extracting puzzle inputs from puzzle source") souped_puzzle_source = bs4.BeautifulSoup(puzzle_source, "html.parser") @@ -138,7 +140,9 @@ def save_sample_inputs(sample_inputs: Iterable[str], output_dir: pathlib.Path): LOG.info(f"Downloaded {num_inputs} sample input(s) successfully") -def download_sample_inputs(date: PuzzleDate, token: str, output_dir: pathlib.Path, *, interactive): +def download_sample_inputs( + date: PuzzleDate, token: str, output_dir: pathlib.Path, *, interactive +): inputs = find_sample_inputs(date, token) if interactive: inputs = interactively_filter_sample_inputs(inputs) @@ -161,6 +165,7 @@ def download_input(date: PuzzleDate, token: str, output_dir: pathlib.Path): puzzle_input = fetch_input(date, token) data_to_write = ensure_ends_with(puzzle_input, os.linesep) path = output_dir / "input.txt" + with open(path, "w") as input_file: input_file.write(data_to_write) @@ -296,7 +301,9 @@ def main( try: step = "download sample inputs" if not input_only: - download_sample_inputs(date_to_fetch, token, output_dir, interactive=interactive) + download_sample_inputs( + date_to_fetch, token, output_dir, interactive=interactive + ) step = "download input" download_input(date_to_fetch, token, output_dir) except requests.exceptions.HTTPError as err: