This commit is contained in:
Sven Heidemann 2022-12-01 07:29:36 +01:00
parent fe13e2c617
commit ee0d318364
3 changed files with 17 additions and 2 deletions

View File

@ -2,8 +2,14 @@
https://adventofcode.com/2022
Original at: https://git.sh-edraft.de/edraft/adventofcode-2022.git
## Session
Save the session key from https://adventofcode.com/ to .env file in the variable ```session=```
## Execute
First create a venv and install deps with ```pip install -t deps.txt```
First create a venv and install deps with ```pip install -r deps.txt --extra-index-url https://pip.sh-edraft.de```
Then run code easily with ```./run {Number-of-day}```

3
deps.txt Normal file
View File

@ -0,0 +1,3 @@
cpl-cli==2022.10.1
cpl-core==2022.10.0.post9
cpl-query==2022.10.0.post2

View File

@ -1,12 +1,18 @@
import os
import urllib.request
from cpl_core.console import Console
def _get_cookie_headers() -> dict[str, str]:
"""
original code from https://github.com/anthonywritescode/aoc2022/blob/main/support/support.py
"""
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../.env')) as f:
env = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../.env')
if not os.path.exists(env):
Console.error(f'Session key from https://adventofcode.com/ required')
with open(env) as f:
contents = f.read().strip()
return {'Cookie': contents}