코드 리뷰, .lownload 파일 작성 함수 추가

This commit is contained in:
2026-08-29 02:47:37 +09:00
parent 321b1c03a0
commit a56d443e80
3 changed files with 53 additions and 17 deletions
+35 -1
View File
@@ -1,5 +1,6 @@
import sys
import os
import json
import shutil
import UtilPack as util
import DataClass_Pupil as pupil
@@ -580,7 +581,40 @@ class MyApp(QMainWindow):
#
def on_btn_MakeDownList_clicked(self):
pass
itemCount = self.tableWidget_Src.rowCount()
if itemCount <= 0:
util.DbgOut("파싱된 만화가 없습니다.", True)
return
pathSave = QFileDialog.getSaveFileName(self, '다운로드 리스트 저장', 'download.json', 'JSON Files (*.json)')[0]
if util.IsEmptyStr(pathSave):
return
dictDownload: dict[str, str] = {}
for idx in range(itemCount):
itemID = self.tableWidget_Src.item(idx, 2)
itemTitle = self.tableWidget_Src.item(idx, 1)
if itemID is None or itemTitle is None:
continue
strID = itemID.text()
strTitle = itemTitle.text()
if util.IsEmptyStr(strID) or util.IsEmptyStr(strTitle):
continue
dictDownload[strID] = f"[{strID}] {strTitle}"
if 0 >= len(dictDownload):
util.DbgOut("작성할 다운로드 리스트 항목이 없습니다.", True)
return
try:
with open(pathSave, "w", encoding="utf-8") as file:
json.dump(dictDownload, file, ensure_ascii=False, indent=2)
util.DbgOut(f"다운로드 리스트 저장 완료: {pathSave}", True)
except Exception as e:
util.DbgOut(f"다운로드 리스트 저장 중 오류 발생: {e}", True)
QMessageBox.critical(self, "Error", str(e))
"""
if __name__ == '__main__':