Skip to content

Commit 98db142

Browse files
authored
Merge branch 'draft' into absolute2
2 parents 2a05dc7 + baae8d8 commit 98db142

File tree

42 files changed

+950
-586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+950
-586
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ jobs:
5151
texlive-science
5252
latexmk
5353
texlive-lang-german
54+
asymptote
5455
- shell: wsl-bash {0}
5556
run: pytest

bin/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
"jobs": (os.cpu_count() or 1) // 2,
109109
"time": 600, # Used for `bt fuzz`
110110
"verbose": 0,
111+
"action": None,
112+
"no_visualizer": True,
111113
}
112114

113115

bin/contest.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ def contest_yaml() -> dict[str, Any]:
1414
if _contest_yaml is not None:
1515
return _contest_yaml
1616

17-
# TODO: Do we need both here?
18-
for p in [Path("contest.yaml"), Path("../contest.yaml")]:
19-
if p.is_file():
20-
_contest_yaml = read_yaml_settings(p)
21-
return _contest_yaml
17+
contest_yaml_path = Path("contest.yaml")
18+
if contest_yaml_path.is_file():
19+
_contest_yaml = read_yaml_settings(contest_yaml_path)
20+
return _contest_yaml
2221
_contest_yaml = {}
2322
return _contest_yaml
2423

@@ -42,7 +41,7 @@ def problems_yaml() -> Optional[list[dict[str, Any]]]:
4241

4342

4443
def get_api() -> str:
45-
api = config.args.api or contest_yaml().get("api")
44+
api = config.args.api or cast(str, contest_yaml().get("api"))
4645
if not api:
4746
fatal(
4847
"Could not find key `api` in contest.yaml and it was not specified on the command line."

bin/export.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from latex import PdfType
1414
from problem import Problem
1515
from validate import InputValidator, AnswerValidator, OutputValidator
16+
from visualize import TestCaseVisualizer, OutputVisualizer
1617

1718

1819
def select_languages(problems: list[Problem]) -> list[str]:
@@ -125,6 +126,8 @@ def build_problem_zip(problem: Problem, output: Path) -> bool:
125126
("submissions/accepted/**/*", True),
126127
("submissions/*/**/*", False),
127128
("attachments/**/*", problem.interactive or problem.multi_pass),
129+
(f"{TestCaseVisualizer.source_dir}/**/*", False),
130+
(f"{OutputVisualizer.source_dir}/**/*", False),
128131
]
129132

130133
# Do not include PDFs for kattis.
@@ -212,6 +215,8 @@ def add_testcase(in_file: Path) -> None:
212215
f"{OutputValidator.source_dir}/**/*",
213216
# "statement/*", "solution/*", "problem_slide/*", use \constant{} commands
214217
# "submissions/*/**/*", removed support?
218+
f"{TestCaseVisualizer.source_dir}/**/*",
219+
f"{OutputVisualizer.source_dir}/**/*",
215220
]
216221
for pattern in constants_supported:
217222
for f in export_dir.glob(pattern):
@@ -292,7 +297,7 @@ def add_testcase(in_file: Path) -> None:
292297
validator_flags = " ".join(
293298
problem.get_testdata_yaml(
294299
problem.path / "data",
295-
"output_validator_args",
300+
OutputValidator.args_key,
296301
PrintBar("Getting validator_flags for legacy export"),
297302
)
298303
)
@@ -476,9 +481,7 @@ def export_contest(cid: Optional[str]) -> str:
476481
new_cid = yaml.load(r.text, Loader=yaml.SafeLoader)
477482
log(f"Uploaded the contest to contest_id {new_cid}.")
478483
if new_cid != cid:
479-
log("Update contest_id in contest.yaml automatically? [Y/n]")
480-
a = input().lower()
481-
if a == "" or a[0] == "y":
484+
if ask_variable_bool("Update contest_id in contest.yaml automatically"):
482485
update_contest_id(new_cid)
483486
log(f"Updated contest_id to {new_cid}")
484487

@@ -558,12 +561,9 @@ def update_problems_yaml(problems: list[Problem], colors: Optional[list[str]] =
558561
label = inc_label(label)
559562

560563
if change:
561-
if config.args.action in ["update_problems_yaml"]:
562-
a = "y"
563-
else:
564-
log("Update problems.yaml with latest values? [Y/n]")
565-
a = input().lower()
566-
if a == "" or a[0] == "y":
564+
if config.args.action in ["update_problems_yaml"] or ask_variable_bool(
565+
"Update problems.yaml with latest values"
566+
):
567567
write_yaml(data, path)
568568
log("Updated problems.yaml")
569569
else:
@@ -686,7 +686,5 @@ def check_if_user_has_team() -> None:
686686
if not any(user["username"] == config.args.username and user["team"] for user in users):
687687
warn(f'User "{config.args.username}" is not associated with a team.')
688688
warn("Therefore, the jury submissions will not be run by the judgehosts.")
689-
log("Continue export to DOMjudge? [N/y]")
690-
a = input().lower()
691-
if not a or a[0] != "y":
689+
if ask_variable_bool("Continue export to DOMjudge", False):
692690
fatal("Aborted.")

0 commit comments

Comments
 (0)