sio3pack.packages.sinolpack¶
Package Contents¶
- class sio3pack.packages.sinolpack.Sinolpack[source]¶
Bases:
sio3pack.packages.package.Package
Represents a OIOIOI’s standard problem package.
- Parameters:
short_name (str) – Short name of the problem.
full_name (str) – Full name of the problem.
lang_titles (dict[str, str]) – A dictionary of problem titles, where keys are language codes and values are titles.
lang_statements (dict[str, File]) – A dictionary of problem statements, where keys are language codes and values are files.
model_solutions (list[dict[str, Any]]) – A list of model solutions, where each element is a dict containing a model solution kind and a file.
additional_files (list[File]) – A list of additional files for the problem.
extra_files (dict[str, File]) – A dictionary of extra files as specified in the config.yml file, where keys are file paths and values are
sio3pack.files.File
objects.attachments (list[File]) – A list of attachments related to the problem.
workflow_manager (SinolpackWorkflowManager) – A workflow manager for the problem.
main_model_solution (File | None) – The main model solution file.
special_files (dict[str, File | None]) – A dictionary of special files, where keys are file names and values are booleans indicating whether the file exists or not.
tests (list[Test]) – A list of tests, where each element is a
sio3pack.Test
object.is_from_db (bool) – A flag indicating whether the package is loaded from the database or not.
workflow_manager – A workflow manager for the problem.
- classmethod identify(file)[source]¶
Identifies whether file is a Sinolpack.
- Parameters:
file (sio3pack.files.LocalFile) – File with package.
- Returns:
True when file is a Sinolpack, otherwise False.
- Return type:
- get_doc_dir()[source]¶
Returns the path to the directory containing the problem’s documents.
- Return type:
- get_in_doc_dir(filename)[source]¶
Returns the path to the input file in the documents’ directory.
- Parameters:
filename (str)
- Return type:
- get_in_root(filename)[source]¶
Returns the path to the input file in the root directory.
- Parameters:
filename (str)
- Return type:
- get_prog_dir()[source]¶
Returns the path to the directory containing the problem’s program files.
- Return type:
- get_in_prog_dir(filename)[source]¶
Returns the path to the input file in the program directory.
- Parameters:
filename (str)
- Return type:
- get_attachments_dir()[source]¶
Returns the path to the directory containing the problem’s attachments.
- Return type:
- get_extra_file(package_path)[source]¶
Returns the extra file with the given package path.
- Parameters:
package_path (str) – The path to the extra file in the package.
- Returns:
The extra file if it exists, otherwise None.
- Return type:
sio3pack.files.File | None
- get_statement(lang=None)[source]¶
Returns the problem statement for a given language code.
- Parameters:
lang (str | None)
- Return type:
sio3pack.files.File | None
- get_test(test_id)[source]¶
Returns the test with the given ID.
- Parameters:
test_id (str)
- Return type:
- get_tests_with_inputs(tests=None)[source]¶
Returns the list of input tests.
- Parameters:
tests (list[sio3pack.test.Test])
- Return type:
- get_corresponding_out_filename(in_test)[source]¶
Returns the corresponding output test for the given input test.
- get_checker_file()[source]¶
Returns the checker file.
- Return type:
sio3pack.files.File | None
- save_to_db(problem_id)[source]¶
Save the package to the database. If sio3pack isn’t installed with Django support, it should raise an ImproperlyConfigured exception.
- Parameters:
problem_id (int)
- get_extra_execution_files()[source]¶
Returns the list of extra execution files specified in the config.yml file. If no such files are specified, an empty list is returned.
- Returns:
List of extra execution files.
- Return type:
- get_extra_compilation_files()[source]¶
Returns the list of extra compilation files specified in the config.yml file. If no such files are specified, an empty list is returned.
- Returns:
List of extra compilation files.
- Return type:
- get_time_limit_for_test(test, language)[source]¶
Returns the time limit for the given test. Read the Sinolpack specification for more details.
- Parameters:
test (sio3pack.test.Test) – The test to get the time limit for.
language (str) – The language of the program.
- Returns:
The time limit for the test in seconds.
- Return type:
- get_memory_limit_for_test(test, language)[source]¶
Returns the memory limit for the given test. Read the Sinolpack specification for more details.
- Parameters:
test (sio3pack.test.Test) – The test to get the memory limit for.
language (str) – The language of the program.
- Returns:
The memory limit for the test in bytes.
- Return type:
- class sio3pack.packages.sinolpack.SinolpackWorkflowManager(package, workflows)[source]¶
Bases:
sio3pack.workflow.WorkflowManager
A workflow manager for Sinolpack packages. It extends the base WorkflowManager and provides additional workflows for ingen, outgen, inwer, and other Sinolpack-specific tasks. It also overrides the get_compile_file_workflow method to add extra compilation files to the workflow.
- Parameters:
- get_compile_file_workflow(file)[source]¶
Creates a workflow that compiles the given file and returns the path to the compiled file. The difference between this function and the base class is that this function adds the extra_compilation_files to the workflow.
- Parameters:
file (sio3pack.files.File | str)
- Return type:
- get_default(name)[source]¶
Get the default workflow for the given name. This method should be overridden by subclasses to provide the default workflow for the given name.
- Parameters:
name (str) – The name of the workflow.
- Returns:
The default workflow for the given name.
- Return type:
- get_unpack_operation(has_ingen, has_outgen, has_inwer, return_func=None)[source]¶
Get the unpack operation for the given data.
- Parameters:
- Return type:
- get_run_operation(program, tests=None, return_func=None)[source]¶
Get the run operation for the given data.
- Parameters:
program (sio3pack.files.File)
tests (list[sio3pack.test.Test] | None)
return_func (callable)
- Return type:
- get_user_out_operation(program, test, return_func=None)[source]¶
Get the workflow for getting the user’s output for a given test.
- Parameters:
program (sio3pack.files.File)
test (sio3pack.test.Test)
return_func (callable)
- Return type:
- get_test_run_operation(program, test, return_func=None)[source]¶
Get the workflow for running a given test on a given program.
- Parameters:
program (sio3pack.files.File)
test (sio3pack.files.File)
return_func (callable)
- Return type: