sio3pack.packages.package

Package Contents

class sio3pack.packages.package.CompilerConfig(name, full_name, path, flags)[source]

Configuration class for a compiler. It holds the name, full name, path, and flags of the compiler.

Parameters:
  • name (str) – The name of the compiler.

  • full_name (str) – The full name of the compiler, including version.

  • path (str) – The path to the compiler executable.

  • flags (list[str]) – The flags to use when compiling with this compiler.

classmethod detect()[source]

Detect the installed compilers and return them as the configuration.

Return type:

dict[str, CompilerConfig]

class sio3pack.packages.package.SIO3PackConfig(django_settings=None, compilers_config=None, extensions_config=None, allow_unrecognized_files=False)[source]

Configuration class for SIO3Pack. It holds the configuration for compilers and file extensions. It can be initialized with Django settings or detected automatically.

Parameters:
  • django_settings – Django settings object.

  • compilers_config (dict[str, CompilerConfig]) – Dictionary of compiler configurations. The keys are the compiler names, and the values are CompilerConfig objects.

  • extensions_config (dict[str, str]) – Dictionary of language configurations. The keys are the file extensions, and the values are the corresponding languages.

  • allow_unrecognized_files (bool)

classmethod detect()[source]

Detect the installed compilers and return them as the configuration.

Return type:

SIO3PackConfig

class sio3pack.packages.package.Package[source]

Bases: sio3pack.utils.classinit.RegisteredSubclassesBase

Base class for all packages.

Parameters:
  • short_name (str) – Short name of the problem.

  • full_name (str) – Full name of the problem.

  • is_from_db (bool) – If True, the package is created from the database.

  • 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.

  • config (dict[str, Any]) – Configuration of the problem.

  • model_solutions (list[tuple[ModelSolutionKind, File]]) – A list of model solutions, where each element is a tuple containing a model solution kind and a file.

  • additional_files (list[File]) – A list of additional files for the problem.

  • attachments (list[File]) – A list of attachments related to the problem.

  • workflow_manager (WorkflowManager) – A workflow manager for the problem.

classmethod identify(file)[source]
Abstractmethod:

Parameters:

file (sio3pack.files.LocalFile)

Identify if the package is of this type.

classmethod from_file(file, configuration=None)[source]

Create a package from a file.

Parameters:

file (sio3pack.files.LocalFile)

classmethod identify_db(problem_id)[source]
Abstractmethod:

Parameters:

problem_id (int)

Identify if the package is of this type. Should check if there is a package of this type in the database with the given problem_id.

classmethod from_db(problem_id, configuration=None)[source]

Create a package from the database. If sio3pack isn’t installed with Django support, it should raise an ImproperlyConfigured exception. If there is no package with the given problem_id, it should raise an UnknownPackageType exception.

Parameters:
  • problem_id (int)

  • configuration (sio3pack.packages.package.configuration.SIO3PackConfig)

reload_config()[source]
abstractmethod get_title(lang=None)[source]
Parameters:

lang (str | None)

Return type:

str

abstractmethod get_statement(lang=None)[source]
Parameters:

lang (str | None)

Return type:

sio3pack.files.File | None

reload_tests()[source]
abstractmethod get_test(test_id)[source]
Parameters:

test_id (str)

Return type:

sio3pack.test.Test

has_test_gen()[source]

Check if the package has test generation.

Return type:

bool

has_verify()[source]

Check if the package has verification.

Return type:

bool

get_unpack_operation(return_func=None)[source]
Parameters:

return_func (callable)

Return type:

sio3pack.workflow.WorkflowOperation | None

get_run_operation(program, tests=None, return_func=None)[source]

Get the run graph for the package. If the package doesn’t have a run graph, it should return None.

Parameters:
Return type:

sio3pack.workflow.WorkflowOperation | None

get_user_out_operation(program, test, return_func=None)[source]

Get the workflow for getting the user’s output for a given test.

Parameters:
Return type:

sio3pack.workflow.WorkflowOperation | None

get_test_run_operation(program, test, return_func=None)[source]

Get the workflow for running a test run. This means that the user can provide a test and the program, and the workflow will run the program with the test.

Parameters:
Return type:

sio3pack.workflow.WorkflowOperation | None

get_executable_path(program)[source]

Get the executable path for a given program.

Parameters:

program (sio3pack.files.File | str)

Return type:

str | None

get_cpp_compiler_full_name()[source]

Get the C++ compiler for the package.

Return type:

str

get_cpp_compiler_path()[source]

Get the C++ compiler path for the package.

Return type:

str

get_cpp_compiler_flags()[source]

Get the C++ compiler flags for the package.

Return type:

list[str]

get_python_compiler_full_name()[source]

Get the Python compiler for the package.

Return type:

str

get_python_compiler_path()[source]

Get the Python compiler path for the package.

Return type:

str

get_python_compiler_flags()[source]

Get the Python compiler flags for the package.

Return type:

list[str]

get_file_language(file)[source]

Returns the language of the given file.

Parameters:

file (sio3pack.files.File | str)

Return type:

str

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)

abstractmethod get_time_limit_for_test(test)[source]

Get the time limit for a given test.

Parameters:

test (sio3pack.test.Test)

Return type:

int

abstractmethod get_memory_limit_for_test(test)[source]

Get the memory limit for a given test.

Parameters:

test (sio3pack.test.Test)

Return type:

int