|
2 | 2 | from typing import Any, Dict, List, Tuple, Union |
3 | 3 |
|
4 | 4 | from lchelper.common import * |
| 5 | +from lchelper.logging import log |
5 | 6 |
|
6 | 7 | __all__ = [ |
7 | 8 | "parse_problem", |
@@ -94,9 +95,11 @@ def find_example_section(s: str, cur_tag: str, next_tag: str, colon: str = ":") |
94 | 95 |
|
95 | 96 | functions, input_str = parse_value(input_str) |
96 | 97 | arg_vals, input_str = parse_value(input_str) |
97 | | - assert len(input_str) == 0 |
| 98 | + if len(input_str) > 0: |
| 99 | + log(f"Problem \"{problem.name}\": Extra characters in example input section: {input_str}", "warning") |
98 | 100 | ret_vals, output_str = parse_value(output_str) |
99 | | - assert len(output_str) == 0 |
| 101 | + if len(output_str) > 0: |
| 102 | + log(f"Problem \"{problem.name}\": Extra characters in example output section: {output_str}", "warning") |
100 | 103 |
|
101 | 104 | cur_examples = [ |
102 | 105 | Interaction( |
@@ -127,17 +130,19 @@ def find_example_section(s: str, cur_tag: str, next_tag: str, colon: str = ":") |
127 | 130 | if idx > 0 and input_str.startswith(","): |
128 | 131 | input_str = input_str[1:].strip() |
129 | 132 | if idx == 0: |
130 | | - if input_str.startswith(f"{name} = "): |
131 | | - input_str = input_str[len(f"{name} = "):].strip() |
| 133 | + if input_str.startswith(f"{name} ="): |
| 134 | + input_str = input_str[len(f"{name} ="):].strip() |
132 | 135 | else: |
133 | | - assert input_str.startswith(f"{name} = ") |
134 | | - input_str = input_str[len(f"{name} = "):].strip() |
| 136 | + assert input_str.startswith(f"{name} =") |
| 137 | + input_str = input_str[len(f"{name} ="):].strip() |
135 | 138 | input_val, input_str = parse_value(input_str) |
136 | 139 | input_vals[name] = input_val |
137 | | - assert len(input_str) == 0 |
| 140 | + if len(input_str) > 0: |
| 141 | + log(f"Problem \"{problem.name}\": Extra characters in example input section:\n{input_str}", "warning") |
138 | 142 |
|
139 | 143 | output_val, output_str = parse_value(output_str) |
140 | | - assert len(output_str) == 0 |
| 144 | + if len(output_str) > 0: |
| 145 | + log(f"Problem \"{problem.name}\": Extra characters in example output section:\n{output_str}", "warning") |
141 | 146 |
|
142 | 147 | examples.append(Example(input_vals, output_val)) |
143 | 148 |
|
|
0 commit comments