Use bridged checker
This commit is contained in:
parent
253693d1ea
commit
2ee1885880
1 changed files with 13 additions and 28 deletions
|
@ -13,9 +13,6 @@ from django.urls import reverse
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
|
||||||
VALIDATOR_TEMPLATE_PATH = "validator_template/template.py"
|
|
||||||
|
|
||||||
|
|
||||||
if os.altsep:
|
if os.altsep:
|
||||||
|
|
||||||
def split_path_first(
|
def split_path_first(
|
||||||
|
@ -75,30 +72,6 @@ class ProblemDataCompiler(object):
|
||||||
raise ProblemDataError(_("Empty batches not allowed."))
|
raise ProblemDataError(_("Empty batches not allowed."))
|
||||||
cases.append(batch)
|
cases.append(batch)
|
||||||
|
|
||||||
def make_checker_for_validator(case):
|
|
||||||
checker_name = "cppvalidator.py"
|
|
||||||
validator_path = split_path_first(case.custom_validator.name)
|
|
||||||
|
|
||||||
if len(validator_path) != 2:
|
|
||||||
raise ProblemDataError(
|
|
||||||
_("How did you corrupt the custom checker path?")
|
|
||||||
)
|
|
||||||
|
|
||||||
checker = os.path.join(
|
|
||||||
settings.DMOJ_PROBLEM_DATA_ROOT, validator_path[0], checker_name
|
|
||||||
)
|
|
||||||
|
|
||||||
validator_name = validator_path[1]
|
|
||||||
shutil.copy(VALIDATOR_TEMPLATE_PATH, checker)
|
|
||||||
|
|
||||||
# replace {{filecpp}} and {{problemid}} in checker file
|
|
||||||
filedata = open(checker, "r").read()
|
|
||||||
filedata = filedata.replace("{{filecpp}}", "'%s'" % validator_name)
|
|
||||||
filedata = filedata.replace("{{problemid}}", "'%s'" % validator_path[0])
|
|
||||||
open(checker, "w").write(filedata)
|
|
||||||
|
|
||||||
return checker_name
|
|
||||||
|
|
||||||
def make_checker(case):
|
def make_checker(case):
|
||||||
if case.checker == "custom":
|
if case.checker == "custom":
|
||||||
custom_checker_path = split_path_first(case.custom_checker.name)
|
custom_checker_path = split_path_first(case.custom_checker.name)
|
||||||
|
@ -109,7 +82,19 @@ class ProblemDataCompiler(object):
|
||||||
return custom_checker_path[1]
|
return custom_checker_path[1]
|
||||||
|
|
||||||
if case.checker == "customval":
|
if case.checker == "customval":
|
||||||
return make_checker_for_validator(case)
|
custom_checker_path = split_path_first(case.custom_validator.name)
|
||||||
|
if len(custom_checker_path) != 2:
|
||||||
|
raise ProblemDataError(
|
||||||
|
_("How did you corrupt the custom checker path?")
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"name": "bridged",
|
||||||
|
"args": {
|
||||||
|
"files": custom_checker_path[1],
|
||||||
|
"lang": "CPP14",
|
||||||
|
"type": "lqdoj",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
if case.checker_args:
|
if case.checker_args:
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue