Skip to content

Commit c65c9ec

Browse files
committed
ensure that yaml_data only contains ruamel like types
1 parent 608aeda commit c65c9ec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/export.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def build_problem_zip(problem: Problem, output: Path) -> bool:
113113
error("zip needs the ruamel.yaml python3 library. Install python[3]-ruamel.yaml.")
114114
return False
115115

116+
from ruamel.yaml.comments import CommentedMap
117+
116118
languages = select_languages([problem])
117119

118120
files = [
@@ -195,7 +197,9 @@ def add_testcase(in_file: Path) -> None:
195197
# handle languages (files and yaml have to be in sync)
196198
yaml_path = export_dir / "problem.yaml"
197199
yaml_data = read_yaml(yaml_path)
198-
yaml_data["name"] = {language: problem.settings.name[language] for language in languages}
200+
yaml_data["name"] = CommentedMap(
201+
{language: problem.settings.name[language] for language in languages}
202+
)
199203
for type in PdfType:
200204
for file in export_dir.glob(str(type.path("*"))):
201205
if file.suffixes[-2][1:] not in languages:
@@ -254,8 +258,6 @@ def add_testcase(in_file: Path) -> None:
254258

255259
# downgrade some parts of the problem to be more legacy like
256260
if config.args.legacy:
257-
from ruamel.yaml.comments import CommentedMap
258-
259261
# drop format version -> legacy
260262
if "problem_format_version" in yaml_data:
261263
ryaml_filter(yaml_data, "problem_format_version")

0 commit comments

Comments
 (0)