1
1
import os
2
2
import re
3
3
import tempfile
4
+ from typing import Any
4
5
5
6
import yaml
6
7
@@ -27,8 +28,8 @@ class Sinolpack(Package):
27
28
:param dict[str, File] lang_statements: A dictionary of problem
28
29
statements, where keys are language codes and values are files.
29
30
:param dict[str, Any] config: Configuration of the problem.
30
- :param list[tuple[ModelSolutionKind, File ]] model_solutions: A list
31
- of model solutions, where each element is a tuple containing
31
+ :param list[dict[str, Any ]] model_solutions: A list
32
+ of model solutions, where each element is a dict containing
32
33
a model solution kind and a file.
33
34
:param list[File] additional_files: A list of additional files for
34
35
the problem.
@@ -253,9 +254,9 @@ def main_model_solution_regex(self):
253
254
extensions = self .get_submittable_extensions ()
254
255
return rf"^{ self .short_name } \.({ '|' .join (extensions )} )"
255
256
256
- def _get_model_solutions (self ) -> list [tuple [ ModelSolutionKind , File ]]:
257
+ def _get_model_solutions (self ) -> list [dict [ str , Any ]]:
257
258
"""
258
- Returns a list of model solutions, where each element is a tuple of model solution kind and filename.
259
+ Returns a list of model solutions, where each element is a dict of model solution kind and filename.
259
260
"""
260
261
if not os .path .exists (self .get_prog_dir ()):
261
262
return []
@@ -268,22 +269,23 @@ def _get_model_solutions(self) -> list[tuple[ModelSolutionKind, File]]:
268
269
match = re .match (regex , file )
269
270
if match and os .path .isfile (os .path .join (self .get_prog_dir (), file )):
270
271
file = LocalFile (os .path .join (self .get_prog_dir (), file ))
271
- model_solutions .append (( ModelSolutionKind .from_regex (match .group (1 )), file ) )
272
+ model_solutions .append ({ "file" : file , "kind" : ModelSolutionKind .from_regex (match .group (1 ))} )
272
273
if re .match (main_regex , file .filename ):
273
274
main_solution = file
274
275
275
276
self .main_model_solution = main_solution
276
277
return model_solutions
277
278
278
279
def sort_model_solutions (
279
- self , model_solutions : list [tuple [ ModelSolutionKind , File ]]
280
- ) -> list [tuple [ ModelSolutionKind , File ]]:
280
+ self , model_solutions : list [dict [ str , Any ]]
281
+ ) -> list [dict [ str , Any ]]:
281
282
"""
282
283
Sorts model solutions by kind.
283
284
"""
284
285
285
286
def sort_key (model_solution ):
286
- kind , file = model_solution
287
+ kind : ModelSolutionKind = model_solution ['kind' ]
288
+ file : LocalFile = model_solution ['file' ]
287
289
return kind .value , naturalsort_key (file .filename [: file .filename .index ("." )])
288
290
289
291
return list (sorted (model_solutions , key = sort_key ))
0 commit comments