增强上传测试样例时的功能,使通过压缩文件夹方式也可以成功上传 - #276
Open
ayang818 wants to merge 2 commits into
Open
Conversation
virusdefender
requested changes
Oct 18, 2019
| return sorted(ret, key=natural_sort_key) | ||
|
|
||
|
|
||
| def judge_dir(self, name_list, dir=""): |
Contributor
There was a problem hiding this comment.
逻辑看了你的 issue 大概懂了,但是感觉这代码有两个问题
- 这个函数有返回值,但是实际没有用,而是修改了传入的参数
- 下面还有一个
filter_name_list函数,感觉两个函数应该合并
逻辑上,感觉你这有点复杂了,因为 process_zip filter_name_list 是支持 dir 参数的,在指定的目录中找测试用例,适用于同时导入导出多个题目的时候使用的,所以你直接看下 1.in 在不在 list 中就可以了,不在的话,就找第一个文件夹然后作为 dir 参数就行。(注意下 process_zip 的默认参数问题,可能得改为 None?)
Author
There was a problem hiding this comment.
函数的返回值dir是有用的,对于这发PR针对的以压缩文件夹上传测试用例的形式,在原来的代码filter_name_list中,传入的dir默认为“”,但是这个时候list中的每个元素都是带有前缀文件夹目录的,例如
["folder_name/1.in", "folder_name/1.out"]
Author
There was a problem hiding this comment.
而传入的dir默认为空, 所以这个时候在下面的循环中用”1.in“ in name_list判断就不会把这个添加到ret中,最后会导致Empty File。
Author
There was a problem hiding this comment.
所以在这之前,我使用了judge_dir函数来获得dir的路径,这个时候{dir}{in_name}.in 的值就是folder_name/1.in,使用这个判断就会把这个添加到ret中。这是我的一个逻辑,但是确实可能比较麻烦,因为不同压缩zip文件夹的出来的目录可能会不一样,这是我在issue提到的坑 #275
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#275 细节见issue