From 5d21a3648d4e00ed3da8c6bc222ffd6656567262 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Tue, 10 Nov 2026 11:51:00 +0100 Subject: [PATCH] aoc_run: filter output --- adventofcode/helper.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/adventofcode/helper.py b/adventofcode/helper.py index 510fe09..41f4f68 100644 --- a/adventofcode/helper.py +++ b/adventofcode/helper.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import os +import re import subprocess import sys import time @@ -153,7 +154,7 @@ def run(year, day): res = get_input_file(year, day) f.write(res.read()) - run_day(script_path, input_path) + run_day(script_path, input_path, print_full_output=True) else: for day in range(1, get_max_day(year) + 1): script_path, input_path = resolve_paths(year, day) @@ -167,7 +168,7 @@ def run(year, day): run_day(script_path, input_path) -def run_day(script_path, input_path): +def run_day(script_path, input_path, print_full_output=False): try: print(f"> running {script_path}\n") start = time.time() @@ -184,7 +185,12 @@ def run_day(script_path, input_path): file=sys.stderr, ) else: - print(res.stdout.decode()) + if print_full_output: + print(res.stdout.decode()) + else: + res = re.findall(rb"Part [12].*\n", res.stdout) + for item in res: + print(item.decode(), end="") print(f"\n> ran {script_path} in {elapsed:.3f}s") except subprocess.TimeoutExpired: print(f"> timeout {script_path} after 30s", file=sys.stderr)