Update MgrCalibreDB.py, UI.py, and 4 more files...

This commit is contained in:
2025-01-07 02:41:54 +09:00
parent 7587da53b3
commit 6fe1cf8da0
6 changed files with 116 additions and 21 deletions

View File

@@ -110,6 +110,8 @@ class MgrCalibreDB:
self.cursor.execute(strSQL)
self.conn.commit()
"""
def main():
db = MgrCalibreDB("/Users/minarinari/캘리버 서재/metadata.db")
db.init()
@@ -125,6 +127,7 @@ def main():
# For Main Loop
if __name__ == '__main__':
main()
"""
# 테이블 생성

42
UI.py
View File

@@ -3,6 +3,7 @@ import os
import UtilPack as util
import MgrCalibreDB as calDB
import MgrCalibreLibs as calLib
import pupildata as pupil
from io import BytesIO
@@ -13,6 +14,7 @@ from PyQt5.QtGui import QPixmap, QKeyEvent
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
class MyApp(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
@@ -25,8 +27,7 @@ class MyApp(QMainWindow):
def resizeEvent(self, event):
self.GetFitSize(self.label_Image.size())
print( self.label_Image.size() )
super().resizeEvent(event)
def initUI(self):
@@ -58,8 +59,6 @@ class MyApp(QMainWindow):
def MakeUI_Left(self):
self.list_SrcPath = QListWidget()
self.list_SrcPath.setMaximumHeight(400)
self.list_SrcPath.setMaximumWidth(300)
btn_Add = QPushButton("Add", self)
btn_Add.clicked.connect(self.on_click_SrcAdd)
@@ -88,6 +87,20 @@ class MyApp(QMainWindow):
return layout
def MakeUI_Right(self):
self.list_Items = QListWidget(self)
self.list_Items.setFixedWidth(300)
self.list_Items.itemSelectionChanged.connect(self.on_Item_SelChanged_Items)
self.list_BookDetail = QListWidget(self)
layout = QVBoxLayout()
layout.addWidget(self.list_Items, stretch = 2)
layout.addWidget(self.list_BookDetail, stretch = 1)
return layout
def MakeUI(self):
layout_L = self.MakeUI_Left()
@@ -98,15 +111,13 @@ class MyApp(QMainWindow):
pixmap = QPixmap("layoutImg.jpeg")
self.label_Image.setMaximumWidth(self.screen().size().width()-(self.list_ArcList.width()+400))
self.list_Items = QListWidget(self)
self.list_Items.setFixedWidth(300)
self.list_Items.itemSelectionChanged.connect(self.on_Item_SelChanged_Items)
layout_R = self.MakeUI_Right()
# 레이아웃 설정
layout = QHBoxLayout()
layout.addLayout(layout_L)
layout.addWidget(self.label_Image)
layout.addWidget(self.list_Items)
layout.addLayout(layout_L, stretch = 1)
layout.addWidget(self.label_Image, stretch= 4)
layout.addLayout(layout_R, stretch = 1)
return layout
@@ -215,7 +226,6 @@ class MyApp(QMainWindow):
for item in items:
pathTarget = item.data(Qt.UserRole)
print(pathTarget)
if None == pathTarget or False == os.path.exists(pathTarget):
return
@@ -226,6 +236,14 @@ class MyApp(QMainWindow):
# 일단 zip 만...
if fileExt.lower() in [".zip", ".cbz"]:
listContents = util.GetZipContentList(pathTarget)
for item in listContents:
if ".metadata" in item:
pBytes = util.GetZippedFileByte(pathTarget, item)
print(pBytes.decode("utf-8"))
pupildata = pupil.PupuilInfoFile(pBytes.decode("utf-8"))
print(pupildata.GetInfo())
elif fileExt.lower() == ".rar":
listContents = []
elif True == os.path.isdir(pathTarget):
@@ -257,6 +275,8 @@ class MyApp(QMainWindow):
pixmap.load(selItemText)
self.label_Image.setPixmap(pixmap)
scaled_pixmap = pixmap.scaled(self.label_Image.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.label_Image.setPixmap(scaled_pixmap)
if __name__ == '__main__':

View File

@@ -223,7 +223,6 @@ def CreateZIPShell(zipName, *files, bRmvRPath = True):
command += strTemp
# for item in file:
# command += f"\"{item}\" "
@@ -235,6 +234,7 @@ def CreateZIPShell(zipName, *files, bRmvRPath = True):
return bRet
# 특정 확장자만 쉘을 이용해서 압축한다
def CreateZIPShExt(zipName, TrgExt):
command = f"zip -j {zipName} *.{TrgExt}"
@@ -247,6 +247,7 @@ def CreateZIPShExt(zipName, TrgExt):
return bRet
# 압축 파일 내의 모든 파일 및 디렉토리 목록 가져오기
def GetZipContentList(path):
if None == path or not os.path.isfile(path):
@@ -258,6 +259,7 @@ def GetZipContentList(path):
return listRet
def GetZippedFileByte(pathZip, FileName):
if None == pathZip or not os.path.isfile(pathZip):
return None
@@ -285,11 +287,13 @@ def PrintJSONTree(data, indent=0):
else:
print(' ' * indent + str(data))
def IsPathWithin(base_path: str, target_path: str) -> bool:
base = Path(base_path).resolve()
target = Path(target_path).resolve()
return target.is_relative_to(base)
# 랜덤 UUID 생성
def UUIDGenRandom():
random_uuid = uuid.uuid4()

BIN
layoutImg.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

View File

@@ -1,4 +1,5 @@
import json
import os
import UtilPack as util
import DataClass as info
@@ -21,23 +22,35 @@ JTITLE = "japanese_title"
class PupuilInfoFile:
m_data = None
def __init__(self, path):
self.path = path
def __init__(self, argv):
self.argv = argv
def __enter__(self):
self.DBXLSOpen(self.path)
self.PupilJSONOpen(self.argv)
def __exit__(self, ex_type, ex_value, traceback):
self.DBXLSClose()
pass
def PupilJSONOpen(self, path):
with open(path, 'r') as file:
self.m_data = json.load(file)
def PupilJSONOpen(self, argv):
if True == util.IsEmptyStr(argv):
print("PupilData: input Null")
return
if True == os.path.exists(argv):
print("pupildata : file")
with open(argv, "r", encoding="utf-8") as file:
self.m_data = json.load(file)
else:
print("pupildata : text")
self.m_data = json.loads(argv)
# pupil 의 JSON 을 파싱해서 DataClass 에 데이터를 넣어 반환한다.
def GetInfo(self):
if None == self.m_data and None != self.argv:
self.m_data = self.PupilJSONOpen(self.argv)
if None == self.m_data:
return None
return
title = self.m_data[GALINFO]["title"]
url = self.m_data[GALBLOCK]["galleryUrl"]

55
temp.py Normal file
View File

@@ -0,0 +1,55 @@
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLineEdit, QHBoxLayout
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.edit = QLineEdit("", self)
btnOK = QPushButton("OK", self)
btnOK.clicked.connect(self.on_click_btn_OK)
layout1 = QHBoxLayout()
layout1.addWidget(self.edit)
layout1.addWidget(btnOK)
# 버튼 생성
btn1 = QPushButton('Button 1', self)
btn2 = QPushButton('Button 2', self)
# 버튼 클릭 시 발생하는 이벤트 연결
btn1.clicked.connect(self.on_click_btn1)
btn2.clicked.connect(self.on_click_btn2)
# 레이아웃 설정
layout = QVBoxLayout()
layout.addLayout(layout1)
layout.addWidget(btn1)
layout.addWidget(btn2)
# 레이아웃을 윈도우에 적용
self.setLayout(layout)
self.setWindowTitle('My First Application')
self.move(300, 300)
self.resize(400, 200)
self.show()
# 버튼 1 클릭 시 호출되는 메서드
def on_click_btn1(self):
print('Button 1 clicked!')
# 버튼 2 클릭 시 호출되는 메서드
def on_click_btn2(self):
print('Button 2 clicked!')
def on_click_btn_OK(self):
print(self.edit.text())
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
sys.exit(app.exec_())