Skip to content

Commit cf3c241

Browse files
committed
keep languages in sync
1 parent fc07fed commit cf3c241

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

bin/export.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,19 @@ def add_testcase(in_file: Path) -> None:
187187
else:
188188
util.warn(f"No answer file found for {f}, skipping.")
189189

190+
# handle languages (files and yaml have to be in sync)
191+
yaml_path = export_dir / "problem.yaml"
192+
yaml_data = read_yaml(yaml_path)
193+
yaml_data["name"] = {language: problem.settings.name[language] for language in languages}
194+
for type in PdfType:
195+
for file in export_dir.glob(str(type.path("*"))):
196+
if file.suffixes[-2] not in languages:
197+
file.unlink()
198+
190199
# drop explicit timelimit for kattis
191200
if config.args.kattis:
192-
yaml_path = export_dir / "problem.yaml"
193-
yaml_data = read_yaml(yaml_path)
194201
if "limits" in yaml_data and "time_limit" in yaml_data["limits"]:
195202
ryaml_filter(yaml_data["limits"], "time_limit")
196-
yaml_path.unlink()
197-
write_yaml(yaml_data, yaml_path)
198203

199204
# substitute constants.
200205
if problem.settings.constants:
@@ -243,9 +248,6 @@ def add_testcase(in_file: Path) -> None:
243248
if config.args.legacy:
244249
from ruamel.yaml.comments import CommentedMap
245250

246-
# handle problem.yaml
247-
yaml_path = export_dir / "problem.yaml"
248-
yaml_data = read_yaml(yaml_path)
249251
# drop format version -> legacy
250252
if "problem_format_version" in yaml_data:
251253
ryaml_filter(yaml_data, "problem_format_version")
@@ -294,9 +296,6 @@ def add_testcase(in_file: Path) -> None:
294296
)
295297
if validator_flags:
296298
yaml_data["validator_flags"] = validator_flags
297-
# write legacy style yaml
298-
yaml_path.unlink()
299-
write_yaml(yaml_data, yaml_path)
300299

301300
# handle time limit
302301
if not config.args.kattis:
@@ -341,6 +340,10 @@ def add_testcase(in_file: Path) -> None:
341340
add_file(out, f)
342341
shutil.rmtree(export_dir / d)
343342

343+
# handle yaml updates
344+
yaml_path.unlink()
345+
write_yaml(yaml_data, yaml_path)
346+
344347
# Build .ZIP file.
345348
message("writing zip file", "Zip", output, color_type=MessageType.LOG)
346349
try:

0 commit comments

Comments
 (0)