From 2c36327ae8b20aee50fec376ed79fa784dcbefd8 Mon Sep 17 00:00:00 2001 From: 15000rpm Date: Sun, 3 Aug 2025 21:03:16 +0900 Subject: [PATCH] Update MgrCalibreDB.py, MgrCalibreUI.py, and 3 more files... python - requirements.txt added --- MgrCalibreDB.py | 6 ++-- MgrCalibreUI.py | 15 ++++++---- MgrPupilColDB.py | 8 ++++++ MgrSQLiteDB.py | 7 +++-- requirements.txt | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 requirements.txt diff --git a/MgrCalibreDB.py b/MgrCalibreDB.py index 275ebad..e36751c 100644 --- a/MgrCalibreDB.py +++ b/MgrCalibreDB.py @@ -4,9 +4,11 @@ import UtilPack as util import MgrSQLiteDB as MyDB class MgrCalibreDB(MyDB.MgrSQLiteDB): - def init(self): - print(f"{self.path} DB Calibre Init") + def __init__(self, path: str): + super().__init__(path) + self.init() + def init(self): # 데이터베이스 연결 (파일이 없으면 새로 생성됨) self.conn = sqlite3.connect(self.path) self.conn.create_function("title_sort", 1, self._title_sort ) diff --git a/MgrCalibreUI.py b/MgrCalibreUI.py index 2aa58a0..4a475ac 100644 --- a/MgrCalibreUI.py +++ b/MgrCalibreUI.py @@ -61,7 +61,7 @@ class MyApp(QMainWindow): if False == os.path.exists(self.pathDB): os.makedirs(self.pathDB, exist_ok=True) - self.pathLastCalibre = settings.value('LastCalibrePath', "~/캘리버 서재", type=str) + self.pathLastCalibre = settings.value('LastCalibrePath', "~/CalibreLibrary", type=str) if False == os.path.exists(self.pathDB): os.makedirs(self.pathDB, exist_ok=True) @@ -100,8 +100,7 @@ class MyApp(QMainWindow): self.DBPupil = MgrPupilColDB.MgrPupilColDB(pathPupilDB) pathCalibreDB = os.path.join(self.pathLastCalibre, self.fileNameCallibreDB) - util.DbgOut(f"Loading Calibre DB from {pathCalibreDB}", True) - self.DBCalibre = MgrCalibreDB.MgrCalibreDB(pathCalibreDB) + self.LoadCalibreDB(pathCalibreDB) # def MakeUI_Left(self): @@ -291,13 +290,17 @@ class MyApp(QMainWindow): ## metadata.db def LoadCalibreDB(self, path:str ) -> None: - pathDB = os.path.join(path, "metadata.db") + pathDB = path + if True == os.path.isdir(path): + pathDB = os.path.join(path, "metadata.db") + print(f"LoadCalibreDB: {pathDB}") + if False == os.path.exists(pathDB): util.DbgOut(f"Calibre DB not found: {pathDB}", True) return - DB = MgrCalibreDB.MgrCalibreDB(pathDB) - listItems = DB.GetBookListforUI_ArcList() + self.DBCalibre = MgrCalibreDB.MgrCalibreDB(pathDB) + listItems = self.DBCalibre.GetBookListforUI_ArcList() for item in listItems: strID = item[4] strTitle = item[0] diff --git a/MgrPupilColDB.py b/MgrPupilColDB.py index 6a4f71f..3786a3b 100644 --- a/MgrPupilColDB.py +++ b/MgrPupilColDB.py @@ -4,6 +4,14 @@ import UtilPack as util import MgrSQLiteDB as MyDB class MgrPupilColDB(MyDB.MgrSQLiteDB): + def __init__(self, path: str): + super().__init__(path) + self.init() + + def init(self): + # 데이터베이스 연결 (파일이 없으면 새로 생성됨) + self.conn = sqlite3.connect(f'file:{self.path}?charset=UTF-8', uri=True) + self.cursor = self.conn.cursor() # ID -> HitomiID, ArchiveID, Title, Authors, Group, Series, Type. Language, Tags, Description, def GetBookByID(self, nID: int) -> dict: diff --git a/MgrSQLiteDB.py b/MgrSQLiteDB.py index ae8c1f3..83c0c82 100644 --- a/MgrSQLiteDB.py +++ b/MgrSQLiteDB.py @@ -1,3 +1,5 @@ +from abc import abstractmethod + import sqlite3 import UtilPack as util @@ -12,10 +14,9 @@ class MgrSQLiteDB: def __exit__(self, ex_type, ex_value, traceback): self.conn.close() + @abstractmethod def init(self): - # 데이터베이스 연결 (파일이 없으면 새로 생성됨) - self.conn = sqlite3.connect(self.path) - self.cursor = self.conn.cursor() + pass # 쿼리를 실행한다. Commit 여부를 선택할 수 있다. def SQLExecute(self, cursor: sqlite3.Cursor, strSQL: str, bCommit: bool = True): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fb5d56d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,73 @@ +appnope==0.1.4 +asgiref==3.8.1 +asttokens==2.4.1 +attrs==23.2.0 +beautifulsoup4==4.12.3 +bs4==0.0.2 +certifi==2024.2.2 +cloudpickle==3.0.0 +comm==0.2.2 +ctype==7.4.2 +debugpy==1.8.1 +decorator==5.1.1 +Django==5.0.4 +et-xmlfile==1.1.0 +executing==2.0.1 +h11==0.14.0 +idna==3.6 +image==1.5.33 +ipykernel==6.29.4 +ipython==8.23.0 +jedi==0.19.1 +jupyter_client==8.6.1 +jupyter_core==5.7.2 +matplotlib-inline==0.1.6 +nest-asyncio==1.6.0 +numpy==1.26.4 +openpyxl==3.1.2 +outcome==1.3.0.post0 +packaging==24.0 +pandas==2.2.2 +parso==0.8.3 +pexpect==4.9.0 +pillow==10.3.0 +platformdirs==4.2.0 +prompt-toolkit==3.0.43 +psutil==5.9.8 +ptyprocess==0.7.0 +pure-eval==0.2.2 +Pygments==2.17.2 +PyQt5==5.15.11 +PyQt5-Qt5==5.15.14 +PyQt5_sip==12.15.0 +PyQt6==6.7.0 +PyQt6-Qt6==6.7.0 +PyQt6-sip==13.6.0 +PySide6==6.6.3.1 +PySide6_Addons==6.6.3.1 +PySide6_Essentials==6.6.3.1 +PySocks==1.7.1 +python-dateutil==2.9.0.post0 +pytz==2024.1 +pyzmq==25.1.2 +rarfile==4.2 +selenium==4.19.0 +shiboken6==6.6.3.1 +six==1.16.0 +sniffio==1.3.1 +sortedcontainers==2.4.0 +soupsieve==2.5 +spyder-kernels==2.5.1 +sqlparse==0.5.0 +stack-data==0.6.3 +tk==0.1.0 +tornado==6.4 +traitlets==5.14.2 +trio==0.25.0 +trio-websocket==0.11.1 +typing_extensions==4.10.0 +tzdata==2024.1 +urllib3==2.2.1 +wcwidth==0.2.13 +wsproto==1.2.0 +wurlitzer==3.0.3