47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
|
|
from Ui_手动统计结果导入 import Ui_Form
|
|
from database_tools_2 import *
|
|
|
|
class MyWindow(QWidget,Ui_Form):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setupUi(self)
|
|
self.bind()
|
|
def bind(self):
|
|
self.pushButton_exec.clicked.connect(self.exec)
|
|
def exec(self):
|
|
handmadeusagedatafilepath = r"临时文件/手动统计结果.txt" #手动统计文件的位置
|
|
metadatafilepath = r"文本文件/metadata.txt" #输出的metadata文件的位置
|
|
raw_data = ReadTextFile(handmadeusagedatafilepath)
|
|
data_list = [d.strip() for d in re.findall(r"\[BEGIN\]([\s\S]*?)\[END\]",raw_data)]
|
|
output = "usages\n\n"
|
|
for item in data_list:
|
|
lines = item.split("\n")
|
|
for line in lines:
|
|
if line.startswith("##"):
|
|
date = line.replace("##","").strip()
|
|
elif line.startswith("**"):
|
|
classname = line.replace("**","").strip()
|
|
else:
|
|
linedata = re.sub(r"\s+","\t",line)
|
|
usage = linedata.split("\t")
|
|
id = usage.pop(0)
|
|
usagestr = "\t".join([f"{float(u):.3f}" for u in usage])
|
|
output += "%s\n%s\t%s\t%s\n\n"%(id.zfill(6),date,classname,usagestr)
|
|
SaveTextFile(output,metadatafilepath)
|
|
os.system(f"code {metadatafilepath}")
|
|
self.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app = QApplication([])
|
|
windows = MyWindow()
|
|
windows.show()
|
|
app.exec()
|
|
|