Skip to content

Commit

Permalink
Python: add logic to dump parser stats
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacG committed Dec 15, 2024
1 parent 5e64e30 commit cb67a4e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions pylib/aoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ def raw_data(self, filename: Optional[str]) -> str:

@functools.cache
def _parser(self) -> parsers.BaseParser:
# print("Code defined" if self.INPUT_PARSER is not None else "Heuristic determined")
if self.INPUT_PARSER is not None:
if not isinstance(self.INPUT_PARSER, BaseParser):
raise ValueError(f"{self.INPUT_PARSER!r} is a class and not an instance!")
Expand Down
20 changes: 20 additions & 0 deletions runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,26 @@ def update_solutions(self, day: int, solutions: Optional[dict[int, int | str]] =
self.solution_path.write_text("\n".join(lines) + "\n")


def show_parsers():
for year_dir in pathlib.Path(__file__).parent.glob("20*"):
sys.path.append(str(year_dir))
days = sorted(int(p.stem.removeprefix("d")) for p in year_dir.glob("d[0-2][0-9].py"))
year = year_dir.name
for day in days:
try:
c = ChallengeRunner(year, day)
p = c.challenge()._parser()
try:
print(p.__class__.__name__)
except Exception:
print(p)
except Exception:
pass
sys.path.remove(str(year_dir))
return



@click.command()
@click.option("--date", "-d", type=str, required=False, help="YYYY/dd")
@click.option("--day", type=int, required=False, help="AoC day")
Expand Down

0 comments on commit cb67a4e

Please sign in to comment.