oioioi.problems.package
¶
This module contains a problem package backend interface. You should
create a package.py
file in your new app and implement your package
backend (inheriting from
ProblemPackageBackend
)
whenever you introduce a new problem package format.
Module Contents¶
Classes¶
A class which manages problem packages. |
Functions¶
|
Finds a backend suitable for unpacking the given package and returns |
Attributes¶
- exception oioioi.problems.package.ProblemPackageError[source]¶
Bases:
Exception
A generic exception to be used by or subclassed by backends.
- exception oioioi.problems.package.PackageProcessingError(func_name, func_doc)[source]¶
Bases:
ProblemPackageError
A generic exception to be used by or subclassed by backends.
- class oioioi.problems.package.ProblemPackageBackend[source]¶
Bases:
oioioi.base.utils.RegisteredSubclassesBase
,oioioi.base.utils.ObjectWithMixins
A class which manages problem packages.
The main functionality is extracting archives with problem statements, data, model solutions etc. and building
Problem
instances.- abstract identify(path, original_filename=None)[source]¶
Checks if the backend is suitable for processing the specified problem package.
- Parameters
path – a path to the processed problem package
original_filename – the name of the package specified by the
uploading user.
Returns
True
if the backend can handle the specified problem package file.
- abstract get_short_name(path, original_filename=None)[source]¶
Returns the problem’s short name.
- Parameters
path – a path to the processed problem package
original_filename – the name of the package specified by the
uploading user.
- abstract unpack(env)[source]¶
Processes a package, creating a new
Problem
or updating an existing one.This function will be called either from
unpackmgr_job()
(Celery task) or fromsimple_unpack()
(e.g. when a problem is added from a command line).- Used
env
keys: package_id
: an id of theProblemPackage
instance with the package file to unpack.- Produced
env
keys: problem_id
: an id of theProblem
instance representing the created or modified problem.
- Used
- exception oioioi.problems.package.NoBackend[source]¶
Bases:
NotImplementedError
Method or function hasn’t been implemented yet.
- oioioi.problems.package.backend_for_package(filename, original_filename=None)[source]¶
Finds a backend suitable for unpacking the given package and returns its dotted name.
- Parameters
filename – a path to the processed problem package
original_filename – the name of the package specified by the
uploading user.