diff options
Diffstat (limited to 'check_checkers.py')
-rwxr-xr-x | check_checkers.py | 37 |
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__]) |