Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

增强上传测试样例时的功能,使通过压缩文件夹方式也可以成功上传 #276

wants to merge 2 commits into from

Conversation

ayang818
Copy link

#275 细节见issue

@@ -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=""):
Copy link
Contributor

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?)

Copy link
Author

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"]

Copy link
Author

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。

Copy link
Author

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

Copy link
Author

@ayang818 ayang818 Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那我再拉一个PR?你再review一下

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我周末先考虑下~

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,大佬你先忙:sparkles:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants