From 04deaca6688e1b657c9de7c89f1274d6234ddcb0 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 4 Dec 2022 13:49:01 +0100 Subject: [PATCH] [py] Set up similar to rust --- py/.gitignore | 3 +++ py/aoc/__init__.py | 27 +++++++++++++++++++++++++++ py/pyproject.toml | 10 ++++++++++ 3 files changed, 40 insertions(+) create mode 100644 py/.gitignore create mode 100644 py/aoc/__init__.py create mode 100644 py/pyproject.toml diff --git a/py/.gitignore b/py/.gitignore new file mode 100644 index 0000000..586a0a0 --- /dev/null +++ b/py/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +/.venv +*.egg-info diff --git a/py/aoc/__init__.py b/py/aoc/__init__.py new file mode 100644 index 0000000..9f19f4b --- /dev/null +++ b/py/aoc/__init__.py @@ -0,0 +1,27 @@ +import sys +import argparse +from pathlib import Path + +DAYS = {} + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("files", type=Path, nargs="+") + args = parser.parse_args() + + first_day = True + for file in args.files: + if not first_day: + print() + first_day = False + + day = DAYS.get(file.stem) + if day is None: + print(f"### Could not determine day: {file}", file=sys.stderr) + continue + + print(f"### Solving day {file.stem}") + with open(file) as f: + inputstr = f.read() + day(inputstr) diff --git a/py/pyproject.toml b/py/pyproject.toml new file mode 100644 index 0000000..2302577 --- /dev/null +++ b/py/pyproject.toml @@ -0,0 +1,10 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "aoc-py" +version = "0.0.0" + +[project.scripts] +aoc-py = "aoc:main"