summaryrefslogtreecommitdiff
path: root/check_checkers.py
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-03-02 07:13:19 +0100
committerMartin Fischer <martin@push-f.com>2022-03-02 07:13:19 +0100
commit060bf54f3cce2b72f7bc0a951a0dc6ab02b18f14 (patch)
treed341d06cd13d30308333d4c9c2f67678a742bfbe /check_checkers.py
parent80c24905262130fa95ff37a424998f40f094c739 (diff)
add puzzles/mod_relative_import/HEADmaster
Diffstat (limited to 'check_checkers.py')
-rwxr-xr-xcheck_checkers.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/check_checkers.py b/check_checkers.py
index 769adba..42415f0 100755
--- a/check_checkers.py
+++ b/check_checkers.py
@@ -227,10 +227,20 @@ def run(
for puzzle in puzzles:
print(puzzle)
- with open(puzzle, 'rb') as f:
- code = f.read()
- puzzle_hash = hashlib.sha256(code).hexdigest()
+ codes: Dict[str, bytes] = {}
+
+ if puzzle.is_dir():
+ for file in sorted(puzzle.iterdir()):
+ with file.open('rb') as f:
+ codes[file.name] = f.read()
+ else:
+ with puzzle.open('rb') as f:
+ codes[puzzle.name] = f.read()
+
+ puzzle_hash = '-'.join(
+ hashlib.sha256(code).hexdigest() for code in codes.values()
+ )
if str(puzzle) in cache and puzzle_hash == cache[str(puzzle)]['puzzle_hash']:
checker_results = cache[str(puzzle)]['checker_results']
else:
@@ -241,11 +251,22 @@ def run(
}
anchor = html.escape(puzzle.name).replace('.py', '').replace('_', '-')
- out.write('<tr><td id="{0}"><a href="#{0}">{0}</a>'.format(anchor))
- code = code.decode('utf-8')
- out.write(highlight(code, python_lexer, html_formatter))
- error_ok = '# error' in code or '# maybe error' in code
- no_error_ok = '# error' not in code
+ out.write('<tr><td id="{0}"><a href="#{0}">{0}</a><br>'.format(anchor))
+
+ error_ok = False
+ no_error_ok = True
+
+ for fname, code in codes.items():
+ code = code.decode('utf-8')
+ if len(codes) > 1:
+ out.write(html.escape(fname))
+ out.write(highlight(code, python_lexer, html_formatter))
+
+ if '# error' in code:
+ error_ok = True
+ no_error_ok = False
+ elif '# maybe error' in code:
+ error_ok = True
results = [
(checker, checker_results[checker.__class__.__name__])