mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
修改上传测试用例默认参数为None && 修改当传入dir参数不为空时, 不执行judge_dir函数
This commit is contained in:
parent
95336cd336
commit
ae5b7a6e65
@ -32,13 +32,14 @@ from ..utils import TEMPLATE_BASE, build_problem_template
|
||||
|
||||
|
||||
class TestCaseZipProcessor(object):
|
||||
def process_zip(self, uploaded_zip_file, spj, dir=""):
|
||||
def process_zip(self, uploaded_zip_file, spj, dir=None):
|
||||
try:
|
||||
zip_file = zipfile.ZipFile(uploaded_zip_file, "r")
|
||||
except zipfile.BadZipFile:
|
||||
raise APIError("Bad zip file")
|
||||
name_list = zip_file.namelist()
|
||||
dir = self.judge_dir(name_list, dir)
|
||||
if not dir:
|
||||
dir = self.judge_dir(name_list)
|
||||
test_case_list = self.filter_name_list(name_list, spj=spj, dir=dir)
|
||||
if not test_case_list:
|
||||
raise APIError("Empty file")
|
||||
@ -110,8 +111,8 @@ class TestCaseZipProcessor(object):
|
||||
continue
|
||||
else:
|
||||
return sorted(ret, key=natural_sort_key)
|
||||
|
||||
def judge_dir(self, name_list, dir=""):
|
||||
|
||||
def judge_dir(self, name_list):
|
||||
is_native = True
|
||||
for i, item_i in enumerate(name_list):
|
||||
if "/" not in item_i:
|
||||
@ -129,6 +130,7 @@ class TestCaseZipProcessor(object):
|
||||
dir = name_list[0].split("/")[0]+"/"
|
||||
return dir
|
||||
|
||||
|
||||
class TestCaseAPI(CSRFExemptAPIView, TestCaseZipProcessor):
|
||||
request_parsers = ()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user