Update MgrCalibreDB.py, UI.py, and 4 more files...
This commit is contained in:
@@ -110,6 +110,8 @@ class MgrCalibreDB:
|
|||||||
self.cursor.execute(strSQL)
|
self.cursor.execute(strSQL)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
def main():
|
def main():
|
||||||
db = MgrCalibreDB("/Users/minarinari/캘리버 서재/metadata.db")
|
db = MgrCalibreDB("/Users/minarinari/캘리버 서재/metadata.db")
|
||||||
db.init()
|
db.init()
|
||||||
@@ -125,6 +127,7 @@ def main():
|
|||||||
# For Main Loop
|
# For Main Loop
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
# 테이블 생성
|
# 테이블 생성
|
||||||
|
|||||||
42
UI.py
42
UI.py
@@ -3,6 +3,7 @@ import os
|
|||||||
import UtilPack as util
|
import UtilPack as util
|
||||||
import MgrCalibreDB as calDB
|
import MgrCalibreDB as calDB
|
||||||
import MgrCalibreLibs as calLib
|
import MgrCalibreLibs as calLib
|
||||||
|
import pupildata as pupil
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ from PyQt5.QtGui import QPixmap, QKeyEvent
|
|||||||
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
|
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
|
||||||
|
|
||||||
class MyApp(QMainWindow):
|
class MyApp(QMainWindow):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.initUI()
|
self.initUI()
|
||||||
@@ -25,8 +27,7 @@ class MyApp(QMainWindow):
|
|||||||
|
|
||||||
|
|
||||||
def resizeEvent(self, event):
|
def resizeEvent(self, event):
|
||||||
self.GetFitSize(self.label_Image.size())
|
super().resizeEvent(event)
|
||||||
print( self.label_Image.size() )
|
|
||||||
|
|
||||||
|
|
||||||
def initUI(self):
|
def initUI(self):
|
||||||
@@ -58,8 +59,6 @@ class MyApp(QMainWindow):
|
|||||||
|
|
||||||
def MakeUI_Left(self):
|
def MakeUI_Left(self):
|
||||||
self.list_SrcPath = QListWidget()
|
self.list_SrcPath = QListWidget()
|
||||||
self.list_SrcPath.setMaximumHeight(400)
|
|
||||||
self.list_SrcPath.setMaximumWidth(300)
|
|
||||||
|
|
||||||
btn_Add = QPushButton("Add", self)
|
btn_Add = QPushButton("Add", self)
|
||||||
btn_Add.clicked.connect(self.on_click_SrcAdd)
|
btn_Add.clicked.connect(self.on_click_SrcAdd)
|
||||||
@@ -88,6 +87,20 @@ class MyApp(QMainWindow):
|
|||||||
return layout
|
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):
|
def MakeUI(self):
|
||||||
layout_L = self.MakeUI_Left()
|
layout_L = self.MakeUI_Left()
|
||||||
|
|
||||||
@@ -98,15 +111,13 @@ class MyApp(QMainWindow):
|
|||||||
pixmap = QPixmap("layoutImg.jpeg")
|
pixmap = QPixmap("layoutImg.jpeg")
|
||||||
self.label_Image.setMaximumWidth(self.screen().size().width()-(self.list_ArcList.width()+400))
|
self.label_Image.setMaximumWidth(self.screen().size().width()-(self.list_ArcList.width()+400))
|
||||||
|
|
||||||
self.list_Items = QListWidget(self)
|
layout_R = self.MakeUI_Right()
|
||||||
self.list_Items.setFixedWidth(300)
|
|
||||||
self.list_Items.itemSelectionChanged.connect(self.on_Item_SelChanged_Items)
|
|
||||||
|
|
||||||
# 레이아웃 설정
|
# 레이아웃 설정
|
||||||
layout = QHBoxLayout()
|
layout = QHBoxLayout()
|
||||||
layout.addLayout(layout_L)
|
layout.addLayout(layout_L, stretch = 1)
|
||||||
layout.addWidget(self.label_Image)
|
layout.addWidget(self.label_Image, stretch= 4)
|
||||||
layout.addWidget(self.list_Items)
|
layout.addLayout(layout_R, stretch = 1)
|
||||||
|
|
||||||
return layout
|
return layout
|
||||||
|
|
||||||
@@ -215,7 +226,6 @@ class MyApp(QMainWindow):
|
|||||||
for item in items:
|
for item in items:
|
||||||
pathTarget = item.data(Qt.UserRole)
|
pathTarget = item.data(Qt.UserRole)
|
||||||
|
|
||||||
print(pathTarget)
|
|
||||||
if None == pathTarget or False == os.path.exists(pathTarget):
|
if None == pathTarget or False == os.path.exists(pathTarget):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -226,6 +236,14 @@ class MyApp(QMainWindow):
|
|||||||
# 일단 zip 만...
|
# 일단 zip 만...
|
||||||
if fileExt.lower() in [".zip", ".cbz"]:
|
if fileExt.lower() in [".zip", ".cbz"]:
|
||||||
listContents = util.GetZipContentList(pathTarget)
|
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":
|
elif fileExt.lower() == ".rar":
|
||||||
listContents = []
|
listContents = []
|
||||||
elif True == os.path.isdir(pathTarget):
|
elif True == os.path.isdir(pathTarget):
|
||||||
@@ -257,6 +275,8 @@ class MyApp(QMainWindow):
|
|||||||
pixmap.load(selItemText)
|
pixmap.load(selItemText)
|
||||||
|
|
||||||
self.label_Image.setPixmap(pixmap)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -223,7 +223,6 @@ def CreateZIPShell(zipName, *files, bRmvRPath = True):
|
|||||||
|
|
||||||
command += strTemp
|
command += strTemp
|
||||||
|
|
||||||
|
|
||||||
# for item in file:
|
# for item in file:
|
||||||
# command += f"\"{item}\" "
|
# command += f"\"{item}\" "
|
||||||
|
|
||||||
@@ -235,6 +234,7 @@ def CreateZIPShell(zipName, *files, bRmvRPath = True):
|
|||||||
|
|
||||||
return bRet
|
return bRet
|
||||||
|
|
||||||
|
|
||||||
# 특정 확장자만 쉘을 이용해서 압축한다
|
# 특정 확장자만 쉘을 이용해서 압축한다
|
||||||
def CreateZIPShExt(zipName, TrgExt):
|
def CreateZIPShExt(zipName, TrgExt):
|
||||||
command = f"zip -j {zipName} *.{TrgExt}"
|
command = f"zip -j {zipName} *.{TrgExt}"
|
||||||
@@ -247,6 +247,7 @@ def CreateZIPShExt(zipName, TrgExt):
|
|||||||
|
|
||||||
return bRet
|
return bRet
|
||||||
|
|
||||||
|
|
||||||
# 압축 파일 내의 모든 파일 및 디렉토리 목록 가져오기
|
# 압축 파일 내의 모든 파일 및 디렉토리 목록 가져오기
|
||||||
def GetZipContentList(path):
|
def GetZipContentList(path):
|
||||||
if None == path or not os.path.isfile(path):
|
if None == path or not os.path.isfile(path):
|
||||||
@@ -258,6 +259,7 @@ def GetZipContentList(path):
|
|||||||
|
|
||||||
return listRet
|
return listRet
|
||||||
|
|
||||||
|
|
||||||
def GetZippedFileByte(pathZip, FileName):
|
def GetZippedFileByte(pathZip, FileName):
|
||||||
if None == pathZip or not os.path.isfile(pathZip):
|
if None == pathZip or not os.path.isfile(pathZip):
|
||||||
return None
|
return None
|
||||||
@@ -285,11 +287,13 @@ def PrintJSONTree(data, indent=0):
|
|||||||
else:
|
else:
|
||||||
print(' ' * indent + str(data))
|
print(' ' * indent + str(data))
|
||||||
|
|
||||||
|
|
||||||
def IsPathWithin(base_path: str, target_path: str) -> bool:
|
def IsPathWithin(base_path: str, target_path: str) -> bool:
|
||||||
base = Path(base_path).resolve()
|
base = Path(base_path).resolve()
|
||||||
target = Path(target_path).resolve()
|
target = Path(target_path).resolve()
|
||||||
return target.is_relative_to(base)
|
return target.is_relative_to(base)
|
||||||
|
|
||||||
|
|
||||||
# 랜덤 UUID 생성
|
# 랜덤 UUID 생성
|
||||||
def UUIDGenRandom():
|
def UUIDGenRandom():
|
||||||
random_uuid = uuid.uuid4()
|
random_uuid = uuid.uuid4()
|
||||||
|
|||||||
BIN
layoutImg.jpeg
Normal file
BIN
layoutImg.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 KiB |
29
pupildata.py
29
pupildata.py
@@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
import UtilPack as util
|
import UtilPack as util
|
||||||
import DataClass as info
|
import DataClass as info
|
||||||
@@ -21,23 +22,35 @@ JTITLE = "japanese_title"
|
|||||||
class PupuilInfoFile:
|
class PupuilInfoFile:
|
||||||
m_data = None
|
m_data = None
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, argv):
|
||||||
self.path = path
|
self.argv = argv
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.DBXLSOpen(self.path)
|
self.PupilJSONOpen(self.argv)
|
||||||
|
|
||||||
def __exit__(self, ex_type, ex_value, traceback):
|
def __exit__(self, ex_type, ex_value, traceback):
|
||||||
self.DBXLSClose()
|
pass
|
||||||
|
|
||||||
def PupilJSONOpen(self, path):
|
def PupilJSONOpen(self, argv):
|
||||||
with open(path, 'r') as file:
|
if True == util.IsEmptyStr(argv):
|
||||||
self.m_data = json.load(file)
|
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 에 데이터를 넣어 반환한다.
|
# pupil 의 JSON 을 파싱해서 DataClass 에 데이터를 넣어 반환한다.
|
||||||
def GetInfo(self):
|
def GetInfo(self):
|
||||||
|
if None == self.m_data and None != self.argv:
|
||||||
|
self.m_data = self.PupilJSONOpen(self.argv)
|
||||||
|
|
||||||
if None == self.m_data:
|
if None == self.m_data:
|
||||||
return None
|
return
|
||||||
|
|
||||||
title = self.m_data[GALINFO]["title"]
|
title = self.m_data[GALINFO]["title"]
|
||||||
url = self.m_data[GALBLOCK]["galleryUrl"]
|
url = self.m_data[GALBLOCK]["galleryUrl"]
|
||||||
|
|||||||
55
temp.py
Normal file
55
temp.py
Normal 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_())
|
||||||
Reference in New Issue
Block a user