-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
增强上传测试样例时的功能,使通过压缩文件夹方式也可以成功上传 #276
base: master
Are you sure you want to change the base?
增强上传测试样例时的功能,使通过压缩文件夹方式也可以成功上传 #276
Conversation
problem/views/admin.py
Outdated
@@ -109,7 +110,24 @@ def filter_name_list(self, name_list, spj, dir=""): | |||
continue | |||
else: | |||
return sorted(ret, key=natural_sort_key) | |||
|
|||
|
|||
def judge_dir(self, name_list, dir=""): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
逻辑看了你的 issue 大概懂了,但是感觉这代码有两个问题
- 这个函数有返回值,但是实际没有用,而是修改了传入的参数
- 下面还有一个
filter_name_list
函数,感觉两个函数应该合并
逻辑上,感觉你这有点复杂了,因为 process_zip
filter_name_list
是支持 dir 参数的,在指定的目录中找测试用例,适用于同时导入导出多个题目的时候使用的,所以你直接看下 1.in
在不在 list 中就可以了,不在的话,就找第一个文件夹然后作为 dir 参数就行。(注意下 process_zip
的默认参数问题,可能得改为 None?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数的返回值dir
是有用的,对于这发PR针对的以压缩文件夹上传测试用例的形式,在原来的代码filter_name_list
中,传入的dir默认为“”,但是这个时候list中的每个元素都是带有前缀文件夹目录的,例如
["folder_name/1.in", "folder_name/1.out"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
而传入的dir默认为空, 所以这个时候在下面的循环中用”1.in“ in name_list
判断就不会把这个添加到ret
中,最后会导致Empty File。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以在这之前,我使用了judge_dir
函数来获得dir的路径,这个时候{dir}{in_name}.in
的值就是folder_name/1.in
,使用这个判断就会把这个添加到ret
中。这是我的一个逻辑,但是确实可能比较麻烦,因为不同压缩zip文件夹的出来的目录可能会不一样,这是我在issue提到的坑 #275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那我再拉一个PR?你再review一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我周末先考虑下~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,大佬你先忙:sparkles:
#275 细节见issue