From de4fabb00e9737aa68135426875318d2bbda186f Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Thu, 21 Mar 2024 07:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B0=8F=E9=97=B2=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AEnew,=20=E6=9C=AA=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/获取小闲平台使用数据new.py | 80 ++++++++++++++++--------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/工具v2/获取小闲平台使用数据new.py b/工具v2/获取小闲平台使用数据new.py index 8e3426a4..c0b4ffc6 100644 --- a/工具v2/获取小闲平台使用数据new.py +++ b/工具v2/获取小闲平台使用数据new.py @@ -1,4 +1,5 @@ from PySide6.QtWidgets import QWidget, QApplication, QFileDialog, QTableWidgetItem +from PySide6.QtGui import QColor from Ui_获取小闲平台使用数据new import Ui_Form from database_tools import * @@ -63,8 +64,7 @@ class MyWindow(QWidget,Ui_Form): self.execmultifile() def execmultifile(self): #待修改 - directory = self.label_filepath.text() - files = [f for f in os.listdir(directory) if ".zip" in f] + files = self.filelist datedfiles = [] tempdir = "临时文件/zips" statsfilename = "小题分_按学号(数学).xlsx" @@ -113,51 +113,53 @@ class MyWindow(QWidget,Ui_Form): def execsinglefile(self): #待修改 - date = self.lineEdit_date.text() + self.tableWidget.clearSelection() + self.tableWidget.item(0,2).setBackground(QColor("transparent")) + date = self.tableWidget.item(0,2).text() threshold = float(self.lineEdit_threshold.text()) if not len(date.strip()) == 8: - self.lineEdit_date.setText("日期格式有误") + self.tableWidget.item(0,2).setBackground(QColor("red")) elif not threshold >= 0 or not threshold <= 1: self.lineEdit_threshold.setText("阈值有误") - else: - tempdir = "临时文件/zips" - statsfilename = "小题分_按学号(数学).xlsx" - answersheetseekingpath = "../备课组" - try: - shutil.rmtree(tempdir) - except: - pass - makedir(tempdir) - xiaoxianpid = ParseZipname(self.zipfilepath) - paperinfo = FindPaper(xiaoxianpid, answersheetseekingpath) - gradename = paperinfo[1] - idlist = paperinfo[2] + # else: + # tempdir = "临时文件/zips" + # statsfilename = "小题分_按学号(数学).xlsx" + # answersheetseekingpath = "../备课组" + # try: + # shutil.rmtree(tempdir) + # except: + # pass + # makedir(tempdir) + # xiaoxianpid = ParseZipname(self.zipfilepath) + # paperinfo = FindPaper(xiaoxianpid, answersheetseekingpath) + # gradename = paperinfo[1] + # idlist = paperinfo[2] - zf = zipfile.ZipFile(self.zipfilepath) - zf.extractall(tempdir) #解压zip文件中的所有内容到tempdir + # zf = zipfile.ZipFile(self.zipfilepath) + # zf.extractall(tempdir) #解压zip文件中的所有内容到tempdir - # papertype = CheckPaperType(tempdir,statsfilename) - statsfilepathlist = FindFile(tempdir,statsfilename) - validcols,marks = generateColIndexandMarks(statsfilepathlist,statsfilename,paperinfo) - dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],statsfilename)) - correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols]) - output = CalculateUsages(statsfilepathlist,statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date) - if CheckUsagesValidity(output) == 0: - if not self.checkBox_appendflag.isChecked(): - SaveTextFile(output,"文本文件/metadata.txt") - print("数据文件已输出至metadata.txt") - self.label_filepath.setText("数据文件已输出至metadata.txt") - os.system("code 文本文件/metadata.txt") - else: - AppendTextFile("\n\n"+output,"文本文件/metadata.txt") - print("数据文件已添加至metadata.txt") - self.label_filepath.setText("数据文件已添加至metadata.txt") - os.system("code 文本文件/metadata.txt") + # # papertype = CheckPaperType(tempdir,statsfilename) + # statsfilepathlist = FindFile(tempdir,statsfilename) + # validcols,marks = generateColIndexandMarks(statsfilepathlist,statsfilename,paperinfo) + # dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],statsfilename)) + # correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols]) + # output = CalculateUsages(statsfilepathlist,statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date) + # if CheckUsagesValidity(output) == 0: + # if not self.checkBox_appendflag.isChecked(): + # SaveTextFile(output,"文本文件/metadata.txt") + # print("数据文件已输出至metadata.txt") + # self.label_filepath.setText("数据文件已输出至metadata.txt") + # os.system("code 文本文件/metadata.txt") + # else: + # AppendTextFile("\n\n"+output,"文本文件/metadata.txt") + # print("数据文件已添加至metadata.txt") + # self.label_filepath.setText("数据文件已添加至metadata.txt") + # os.system("code 文本文件/metadata.txt") - else: - print("数据有误, 可能需要检查每一题的满分数据") - self.label_filepath.setText("数据有误, 可能需要检查每一题的满分数据") + # else: + # print("数据有误, 可能需要检查每一题的满分数据") + # self.label_filepath.setText("数据有误, 可能需要检查每一题的满分数据")