day 1
This commit is contained in:
parent
fe13e2c617
commit
ee0d318364
@ -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
3
deps.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cpl-cli==2022.10.1
|
||||
cpl-core==2022.10.0.post9
|
||||
cpl-query==2022.10.0.post2
|
@ -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}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user