Skip to content

Commit 1740f8d

Browse files
committed
[Scripts] Refactor CMS exporter: Extract & use method _get_task_type_parameters
1 parent e9b7f74 commit 1740f8d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

scripts/exporters/CMS.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,7 @@ def copy_file(self, file, relative_dest):
9797
SOLUTION_DIR_NAME = "solutions"
9898

9999

100-
def export_problem_global_data(self):
101-
json_file = "problem.json"
102-
vp.print("Writing '{}'...".format(json_file))
103-
PROBLEM_JSON = os.environ.get('PROBLEM_JSON')
104-
task_data = load_json(PROBLEM_JSON)
105-
106-
task_type = task_data["type"]
107-
vp.print_var("task_type", task_type)
108-
100+
def _get_task_type_parameters(self, task_data, task_type):
109101
task_type_params = task_data.get("type_params", {})
110102

111103
if task_type == "Communication":
@@ -121,6 +113,18 @@ def export_problem_global_data(self):
121113
compilation_type = "alone"
122114
task_type_params["task_type_parameters_Batch_compilation"] = compilation_type
123115

116+
return json.dumps(task_type_params)
117+
118+
119+
def export_problem_global_data(self):
120+
json_file = "problem.json"
121+
vp.print("Writing '{}'...".format(json_file))
122+
PROBLEM_JSON = os.environ.get('PROBLEM_JSON')
123+
task_data = load_json(PROBLEM_JSON)
124+
125+
task_type = task_data["type"]
126+
vp.print_var("task_type", task_type)
127+
124128
problem_data_dict = {
125129
"protocol_version": self.protocol_version,
126130
"code": task_data["name"],
@@ -129,7 +133,7 @@ def export_problem_global_data(self):
129133
"memory_limit": task_data["memory_limit"]*1024*1024,
130134
"score_precision": task_data.get("score_precision", 2),
131135
"task_type": task_type,
132-
"task_type_params": json.dumps(task_type_params),
136+
"task_type_params": self._get_task_type_parameters(task_data, task_type),
133137
}
134138

135139
problem_data_str = json.dumps(problem_data_dict)

0 commit comments

Comments
 (0)