summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck_checkers.py37
-rw-r--r--puzzles/mod_relative_import/__init__.py3
-rw-r--r--puzzles/mod_relative_import/foo.py1
3 files changed, 33 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__])
diff --git a/puzzles/mod_relative_import/__init__.py b/puzzles/mod_relative_import/__init__.py
new file mode 100644
index 0000000..ff97bdb
--- /dev/null
+++ b/puzzles/mod_relative_import/__init__.py
@@ -0,0 +1,3 @@
+from .foo import x
+
+print(foo.x + x)
diff --git a/puzzles/mod_relative_import/foo.py b/puzzles/mod_relative_import/foo.py
new file mode 100644
index 0000000..b95c23a
--- /dev/null
+++ b/puzzles/mod_relative_import/foo.py
@@ -0,0 +1 @@
+x = 3