|
15 | 15 | import sys |
16 | 16 | import copy |
17 | 17 | import random |
| 18 | +import traceback |
| 19 | + |
18 | 20 | import argparse |
19 | 21 | import shlex |
20 | 22 |
|
@@ -398,6 +400,10 @@ def get_subgroups(self) -> list[TestCaseGroup]: |
398 | 400 | return [child for child in self._items if isinstance(child, TestCaseGroup)] |
399 | 401 |
|
400 | 402 |
|
| 403 | + def get_subgroup(self, name): |
| 404 | + return next((child for child in self._items if isinstance(child, TestCaseGroup) and os.path.basename(child._datadir) == name), None) |
| 405 | + |
| 406 | + |
401 | 407 | def has_custom_groups(self) -> bool: |
402 | 408 | return any(group.get_subgroups() for group in self.get_subgroups()) |
403 | 409 |
|
@@ -1076,16 +1082,26 @@ def check(self, args: argparse.Namespace) -> bool: |
1076 | 1082 |
|
1077 | 1083 | for lang in self.languages: |
1078 | 1084 | try: |
1079 | | - if not problem2pdf.convert([self._problem.probdir, '--language', lang, '--no-pdf', '--quiet']): |
| 1085 | + options = problem2pdf.get_parser().parse_args([None]) |
| 1086 | + options.problem = self._problem.probdir |
| 1087 | + options.language = lang |
| 1088 | + options.nopdf = True |
| 1089 | + options.quiet = True |
| 1090 | + if not problem2pdf.convert(options): |
1080 | 1091 | langparam = f' --language {lang}' if lang != '' else '' |
1081 | 1092 | self.error(f'Could not compile problem statement for language "{lang}". Run problem2pdf{langparam} on the problem to diagnose.') |
1082 | 1093 | except Exception as e: |
1083 | | - self.error(f'Error raised when checking problem statement for language {lang}:\n{e}') |
| 1094 | + self.error(f'Error raised when checking problem statement for language {lang}:\n{e}\n{traceback.format_exc()}') |
1084 | 1095 | try: |
1085 | | - problem2html.convert([self._problem.probdir, '--dest-dir', os.path.join(self._problem.tmpdir, 'html'), '--language', lang, '--quiet']) |
1086 | | - except Exception: |
| 1096 | + options = problem2html.get_parser().parse_args([None]) |
| 1097 | + options.problem = self._problem.probdir |
| 1098 | + options.destdir = os.path.join(self._problem.tmpdir, 'html') |
| 1099 | + options.language = lang |
| 1100 | + options.quiet = True |
| 1101 | + problem2html.convert(options) |
| 1102 | + except Exception as e: |
1087 | 1103 | langparam = f' --language {lang}' if lang != '' else '' |
1088 | | - self.error(f'Could not convert problem statement to html for language "{lang}". Run problem2html{langparam} on the problem to diagnose.') |
| 1104 | + self.error(f'Could not convert problem statement to html for language "{lang}". Run problem2html{langparam} on the problem to diagnose.\n{e}\n{traceback.format_exc()}') |
1089 | 1105 | return self._check_res |
1090 | 1106 |
|
1091 | 1107 | def __str__(self) -> str: |
@@ -1138,6 +1154,11 @@ def check(self, args: argparse.Namespace) -> bool: |
1138 | 1154 |
|
1139 | 1155 | return self._check_res |
1140 | 1156 |
|
| 1157 | + |
| 1158 | + def get_attachment_paths(self): |
| 1159 | + return self.attachments |
| 1160 | + |
| 1161 | + |
1141 | 1162 | def __str__(self) -> str: |
1142 | 1163 | return 'attachments' |
1143 | 1164 |
|
|
0 commit comments