GetValidTexFiles函数添加列表排序功能

This commit is contained in:
wangweiye7840 2023-07-02 19:11:49 +08:00
parent bdc5ab9602
commit 311db87ad6
1 changed files with 4 additions and 3 deletions

View File

@ -782,7 +782,7 @@ def GenerateTeacherBodyString(problems,sectiontitles,prodict,objdict,consecutive
bodystring += sectionstring bodystring += sectionstring
return bodystring #返回主题内容字符串 return bodystring #返回主题内容字符串
def GetValidTexFiles(path): #获取有题号的.tex文件列表 及 有题号的.tex文件所在的路径列表 def GetValidTexFiles(path): #获取 有题号的.tex文件列表 及 有题号的.tex文件所在的路径列表
texlist = [] texlist = []
pathlist = [] pathlist = []
for root,folders,files in os.walk(path): for root,folders,files in os.walk(path):
@ -793,9 +793,10 @@ def GetValidTexFiles(path): #获取有题号的.tex文件列表 及 有题号的
if len(ids) > 0: if len(ids) > 0:
pathlist = pathlist + [root] pathlist = pathlist + [root]
texlist = texlist + [os.path.join(root,file)] texlist = texlist + [os.path.join(root,file)]
texlist = list(set(texlist)) texlist = sorted(list(set(texlist)))
pathlist = list(set(pathlist)) pathlist = sorted(list(set(pathlist)))
return (texlist,pathlist) # 返回 有题号的.tex文件列表 与 所在路径列表 组成的二元组 return (texlist,pathlist) # 返回 有题号的.tex文件列表 与 所在路径列表 组成的二元组
if __name__ == "__main__": if __name__ == "__main__":
print("数据库工具, import用.") print("数据库工具, import用.")