Skip to content

Commit c5adbcf

Browse files
committed
contest.yaml: Rename key testsession to test_session
1 parent abb49f8 commit c5adbcf

File tree

12 files changed

+46
-26
lines changed

12 files changed

+46
-26
lines changed

bin/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def update_problems_yaml(problems: list[Problem], colors: Optional[list[str]] =
560560
if data != sorted_data:
561561
change = True
562562
data = sorted_data
563-
label = "X" if contest_yaml().get("testsession") else "A"
563+
label = "X" if contest_yaml().get("test_session") else "A"
564564
for d in data:
565565
d["label"] = label
566566
label = inc_label(label)

bin/latex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,13 @@ def build_contest_pdf(
459459
"subtitle": "",
460460
"year": "YEAR",
461461
"author": "AUTHOR",
462-
"testsession": "",
462+
"test_session": "",
463463
}
464464
config_data = contest_yaml()
465465
for x in default_config_data:
466466
if x not in config_data:
467467
config_data[x] = default_config_data[x]
468-
config_data["testsession"] = "\\testsession" if config_data.get("testsession") else ""
468+
config_data["test_session"] = "\\testsession" if config_data.get("test_session") else ""
469469
config_data["logofile"] = find_logo().as_posix()
470470

471471
local_contest_data = Path("contest_data.tex")

bin/skel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def new_contest() -> None:
3636
subtitle = ask_variable_string("subtitle", "", True).replace("_", "-")
3737
dirname = ask_variable_string("dirname", _alpha_num(title))
3838
author = ask_variable_string("author", f"The {title} Jury").replace("_", "-")
39-
testsession = ask_variable_bool("testsession", False)
39+
test_session = ask_variable_bool("test session", False)
4040
year = ask_variable_string("year", str(datetime.datetime.now().year))
4141
source_url = ask_variable_string("source url", "", True)
4242
license = ask_variable_choice("license", config.KNOWN_LICENSES)
@@ -165,7 +165,7 @@ def new_problem() -> None:
165165
data = read_yaml(problems_yaml) or []
166166
prev_label = data[-1]["label"] if data else None
167167
next_label = (
168-
("X" if contest.contest_yaml().get("testsession") else "A")
168+
("X" if contest.contest_yaml().get("test_session") else "A")
169169
if prev_label is None
170170
else inc_label(prev_label)
171171
)

bin/tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def parse_problems_yaml(problemlist):
137137

138138
def fallback_problems():
139139
problem_paths = list(filter(is_problem_directory, glob(Path("."), "*/")))
140-
label = chr(ord("Z") - len(problem_paths) + 1) if contest_yaml().get("testsession") else "A"
140+
label = (
141+
chr(ord("Z") - len(problem_paths) + 1) if contest_yaml().get("test_session") else "A"
142+
)
141143
problems = []
142144
for path in problem_paths:
143145
problems.append((path, label))

bin/upgrade.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ def movetree(src: Path, dst: Path) -> None:
7171
movetree(src_base, dst_base)
7272

7373

74+
def upgrade_contest_yaml(contest_yaml_path: Path, bar: ProgressBar) -> None:
75+
yaml_data = read_yaml(contest_yaml_path)
76+
if "testsession" in yaml_data:
77+
ryaml_replace(yaml_data, "testsession", "test_session")
78+
write_yaml(yaml_data, contest_yaml_path)
79+
bar.log("renaming 'testsession' to 'test_session'")
80+
81+
7482
def upgrade_data(problem_path: Path, bar: ProgressBar) -> None:
7583
rename = [
7684
("data/invalid_inputs", "data/invalid_input"),
@@ -514,7 +522,14 @@ def is_problem_directory(path: Path) -> bool:
514522
else:
515523
paths = [p for p in cwd.iterdir() if is_problem_directory(p)]
516524

517-
bar = ProgressBar("upgrade", items=paths)
525+
bar = ProgressBar("upgrade", items=["contest.yaml", *paths])
526+
527+
bar.start("contest.yaml")
528+
if (cwd / "contest.yaml").is_file():
529+
upgrade_contest_yaml(cwd / "contest.yaml", bar)
530+
bar.done()
531+
518532
for path in paths:
519533
_upgrade(path, bar)
534+
520535
bar.finalize()

doc/commands.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,14 @@ Settings for this contest will be asked for interactively. The following files a
347347
```
348348
/tmp/tmp % bt new_contest
349349
name: NWERC 2020
350-
subtitle []: The Northwestern European Programming Contest 2020
351-
dirname [nwerc2020]:
352-
author [The NWERC 2020 jury]:
353-
testsession? [n (y/n)]: n
354-
year [2020]:
355-
source [NWERC 2020]:
356-
source url []: 2020.nwerc.eu
357-
license [cc by-sa]:
358-
rights owner [author]:
350+
subtitle: The Northwestern European Programming Contest 2020
351+
dirname (nwerc2020):
352+
author (The NWERC 2020 jury):
353+
test session? (y/N): n
354+
year (2020):
355+
source url: 2020.nwerc.eu
356+
license (cc by-sa):
357+
rights owner (if left empty, defaults to problem author):
359358
```
360359

361360
## `new_problem`
@@ -365,9 +364,13 @@ Create a new problem directory and fill it with skel files. If `problems.yaml` i
365364
```
366365
~nwerc2020 % bt new_problem
367366
problem name (en): Test Problem
368-
dirname [testproblem]:
367+
dirname (testproblem):
369368
author: Ragnar Groot Koerkamp
370-
validation (default/custom/custom interactive) [default]:
369+
type (pass-fail):
370+
source (NWERC 2020):
371+
source url (2020.nwerc.eu):
372+
license (cc by-sa):
373+
rights owner (if left empty, defaults to problem author):
371374
LOG: Copying /home/philae/git/bapc/BAPCtools/skel/problem to testproblem.
372375
```
373376

@@ -629,7 +632,7 @@ This file should contain a list of problems, with for every problem the keys `id
629632

630633
- `--colors`: Apply the given list of colors to the list of problems, in the same order as in `problems.yaml`.
631634
Should be a comma-separated list of colors (hash-sign is optional), e.g.: `--colors ff0000,00ff00,0000ff`.
632-
- `--sort`: Sort the problems in `problems.yaml` and re-label them starting from `A` (or `X` if `contest.yaml` contains `testsession: True`).
635+
- `--sort`: Sort the problems in `problems.yaml` and re-label them starting from `A` (or `X` if `contest.yaml` contains `test_session: True`).
633636

634637
## `tmp`
635638

doc/implementation_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ The following placeholders are automatically substituted in the `contest_data.te
154154
{%subtitle%}
155155
{%year%}
156156
{%author%}
157-
{%testsession%}
157+
{%test_session%}
158158
{%logofile%}
159159
...
160160
<any entry in the contest.yaml>

latex/contest-web.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
\input{./contest-problems.tex}
6363
\makeatletter
6464

65-
% An empty page at the end for non-testsession.
65+
% An empty page at the end if the contest is not a test session.
6666
\if\@testsession0
6767
\clearpage
6868
\pagestyle{empty}

latex/contest.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
\input{./contest-problems.tex}
6363
\makeatletter
6464

65-
% An empty page at the end for non-testsession.
65+
% An empty page at the end if the contest is not a test session.
6666
\if\@testsession0
6767
\clearpage
6868
\pagestyle{empty}

latex/contest_data.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
\copyrightyear{{%year%}}
44
\author{{%author%}}
55
\newcommand{\logofile}{{%logofile%}}
6-
{%testsession%}
6+
{%test_session%}

0 commit comments

Comments
 (0)