Compare commits
2 Commits
00000160c2
...
000001806d
| Author | SHA1 | Date | |
|---|---|---|---|
|
000001806d
|
|||
|
0000017088
|
@@ -1,3 +1,4 @@
|
||||
import datetime
|
||||
import pathlib
|
||||
|
||||
import requests
|
||||
@@ -15,8 +16,21 @@ def download(year: int, day: int, session_token: str | None) -> bytes:
|
||||
response = requests.get(url, cookies=cookies)
|
||||
|
||||
if response.status_code != 200:
|
||||
status = response.status_code
|
||||
|
||||
# https://stackoverflow.com/a/39079819/11286805
|
||||
local_tz = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
|
||||
|
||||
now = datetime.datetime.now(local_tz)
|
||||
release = datetime.datetime(year, 12, day, 5, tzinfo=datetime.UTC)
|
||||
|
||||
if now < release:
|
||||
raise exceptions.AocError(
|
||||
f"failed to fetch input file {year}/{day:02} (http:{response.status_code})"
|
||||
f"unreleased input file {year}/{day:02} (http:{status})"
|
||||
)
|
||||
|
||||
raise exceptions.AocError(
|
||||
f"failed to fetch input file {year}/{day:02} (http:{status})"
|
||||
" - is AOC_SESSION_TOKEN environment variable set?"
|
||||
)
|
||||
|
||||
@@ -92,20 +106,19 @@ from typing import Any
|
||||
|
||||
|
||||
def part_1(input_data: str) -> Any:
|
||||
# your part 1 solution here
|
||||
return None
|
||||
|
||||
|
||||
def part_2(input_data: str) -> Any:
|
||||
# your part 2 solution here
|
||||
return None
|
||||
|
||||
|
||||
# alternatively you can implement a "two in one solution" like this
|
||||
# part_1 and part_2 must be removed or commented out in this case
|
||||
# if tuple or list is returned elements will be printed on separate lines
|
||||
# def part_1_2(input_data) -> Any:
|
||||
# return None
|
||||
def test_part_1(example_data)
|
||||
assert part_1(example_data) == 0
|
||||
|
||||
|
||||
def test_part_2(example_data)
|
||||
assert part_2(example_data) == 0
|
||||
"""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user