Files
CollectMangaInfo/StoreXLS.py
Lee Young Hoon e9f8a7323c Update DataClass.py, GetArc_Ehentai.py, and 7 more files...
데이터 클래스 정의, 퍼필 다운로더 json 파서...
2024-05-13 21:48:40 +09:00

117 lines
3.0 KiB
Python

import os
from openpyxl import opyxl
from openpyxl.utils import xlsUtils
import DataClass as stManga
import UtilPack as util
class DBXLStorage:
xls_name = "mangaDB.xlsx"
xls_path = ""
m_wb = None
sheetName_Mangainfo = "MangaInfo"
sheetName_Artists = "Artists"
sheetName_Tags = "Tags"
strMngSht = "MngInfo"
strArtSht = "ArtInfo"
strTagSht = "TagInfo"
m_openedXLS = ""
def __init__(self, path):
self.path = path
def __enter__(self):
self.DBXLSOpen(self.path)
def __exit__(self, ex_type, ex_value, traceback):
self.DBXLSClose()
def DBXLSOpen(self, path):
xls_path = self.GetXLSPath(path)
util.DbgOut(xls_path)
try:
m_wb = opyxl(xls_path)
util.DbgOut("xls Open Successed")
except FileNotFoundError:
m_wb = opyxl()
util.DbgOut("xls Created")
if m_wb is None:
util.DbgOut("XLS Open Something Wrong...")
m_openedXLS = ""
m_wb = None
return
def DBXLSClose(self):
if self.m_wb is None or self.m_openedXLS is None:
util.DbgOut("XLS Close something wrong...")
return
self.m_wb.save(self.m_openedXLS)
self.m_wb.close()
self.m_wb = None
#
def WriteMangaInfos(self, *listInfos):
if False == isinstance(listInfos, list):
return
ws_mng = self.getSheet(self.strMngSht)
if None == ws_mng:
return
#for item in listInfos:
# 클래스 타잎을 확인해야 하지만만.. 생략.
# ttist, group, series(parady), type, tags, hitomi ID, hitomi file, eh ID, eh tor
def AddTagInfo(self, tagInfo):
pass
def AddTagInfo(self, strTag, strUrl):
pass
def AddArtistInfo(self, artistInfo):
pass
def AddArAddArtistInfo(self, strArtist, strUrl):
pass
def AddSeriesInfo(self, SeriesInfo):
pass
def AddSeriesInfo(self, strSerires, strUrl):
pass
def AddTypeInfo(self, typeInfo):
pass
def AddTypeInfo(self, strType, strUrl):
pass
# 시트를 가져온다. 엑셀 파일이 안 열려 있으면 None, 있으면 반환하고, 없으면 만들어서.
def getSheet(self, sheetName):
retSheet = None
if self.m_wb:
if sheetName in self.m_wb.sheetnames:
retSheet = self.m_wb[sheetName]
else:
retSheet = self.m_wb.create_sheet(title=sheetName)
return retSheet
# 데이터베이스용 엑셀 파일의 전체 경로를 얻어온다.
def GetXLSPath(self, path):
retPath = path
if False == os.path.exists(path):
retPath = os.path.abspath(__file__)
return os.path.join(retPath, self.xls_name)