Fix runner for day 1
This commit is contained in:
parent
e01cc08f72
commit
f62396323a
1 changed files with 7 additions and 3 deletions
10
run
10
run
|
@ -34,6 +34,10 @@ def convert_to_camel_case(inp: str) -> str:
|
|||
return "".join(parts)
|
||||
|
||||
|
||||
def filter_for_filename(inp: str) -> str:
|
||||
return "".join(filter(lambda x: x.isalpha() or x.isdigit() or x == "-", inp))
|
||||
|
||||
|
||||
def load_credentials() -> dict[str, str]:
|
||||
with open("credentials.json") as f:
|
||||
return json.load(f)
|
||||
|
@ -86,10 +90,10 @@ class CLI(object):
|
|||
if page_resp.status_code == 404:
|
||||
print("Challenge page not found: has that day been released yet?", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
page_resp.raise_for_status()
|
||||
|
||||
matches = re.findall(r"--- Day \d{1,2}: ([\w ]+) ---", page_resp.content.decode())
|
||||
matches = re.findall(r"--- Day \d{1,2}: ([\w \?!]+) ---", page_resp.content.decode())
|
||||
assert len(matches) >= 1, "must be able to discover at least one day title"
|
||||
day_title = matches[0]
|
||||
|
||||
|
@ -97,7 +101,7 @@ class CLI(object):
|
|||
|
||||
p = Path(CHALLENGES_DIR)
|
||||
p /= str(year)
|
||||
p /= str(day).zfill(2) + "-" + convert_to_camel_case(day_title)
|
||||
p /= str(day).zfill(2) + "-" + filter_for_filename(convert_to_camel_case(day_title))
|
||||
|
||||
os.makedirs(p)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue