utility class added
자료 저장 구조 고민중...
This commit is contained in:
126
StoreXLS.py
126
StoreXLS.py
@@ -1,30 +1,120 @@
|
||||
import os
|
||||
import time
|
||||
from openpyxl import Workbook
|
||||
from openpyxl import load_workbook
|
||||
from openpyxl.utils import get_column_letter
|
||||
from openpyxl import opyxl
|
||||
from openpyxl.utils import xlsUtils
|
||||
|
||||
import DataClass as stManga
|
||||
import UtilPack as util
|
||||
|
||||
|
||||
xls_name = "mangaDB.xlsx"
|
||||
list_MetaInfo = []
|
||||
m_wb = None
|
||||
|
||||
sheetName_Mangainfo = "MangaInfo"
|
||||
sheetName_Artists = "Artists"
|
||||
sheetName_Tags = "Tags"
|
||||
|
||||
strMngSht = "MngInfo"
|
||||
strArtSht = "ArtInfo"
|
||||
strTagSht = "TagInfo"
|
||||
|
||||
#
|
||||
def GetCurrentTime():
|
||||
# 현재 시간을 구하고 구조체로 변환
|
||||
current_time_struct = time.localtime()
|
||||
|
||||
# 구조체에서 연, 월, 일, 시간, 분, 초를 추출
|
||||
year = current_time_struct.tm_year
|
||||
month = current_time_struct.tm_mon
|
||||
day = current_time_struct.tm_mday
|
||||
hour = current_time_struct.tm_hour
|
||||
minute = current_time_struct.tm_min
|
||||
second = current_time_struct.tm_sec
|
||||
def DBXLSOpen(path):
|
||||
xls_path = GetXLSPath(path)
|
||||
util.DbgOut(xls_path)
|
||||
|
||||
strRet = (f"{year}/{month}/{day}_{hour}:{minute}:{second}")
|
||||
try:
|
||||
wb = opyxl(xls_path)
|
||||
util.DbgOut("xls Open Successed")
|
||||
except FileNotFoundError:
|
||||
wb = opyxl()
|
||||
util.DbgOut("xls Created")
|
||||
|
||||
if wb is None:
|
||||
util.DbgOut("XLS Open Something Wrong...")
|
||||
return
|
||||
|
||||
m_wb = wb
|
||||
|
||||
ws = wb.active
|
||||
# time, title, url, tags (comma)
|
||||
ws['A1'] = "Modified Time"
|
||||
ws['B1'] = int(time.time())
|
||||
|
||||
|
||||
if 'list' not in wb.sheetnames:
|
||||
ws1 = wb.create_sheet(title='list')
|
||||
print('list sheet created')
|
||||
|
||||
wb.save(xls_path)
|
||||
|
||||
ws2 = wb['list']
|
||||
print(str(index) + " searched")
|
||||
|
||||
|
||||
def DBXLSClose():
|
||||
if m_wb is None:
|
||||
return
|
||||
|
||||
m_wb.save(xls_path)
|
||||
m_wb.close()
|
||||
|
||||
m_wb = None
|
||||
|
||||
|
||||
#
|
||||
def WriteMangaInfos(*listInfos):
|
||||
if False == isinstance(listInfos, list):
|
||||
return
|
||||
|
||||
ws_mng = getSheet(strMngSht)
|
||||
if None == ws_mng:
|
||||
return
|
||||
|
||||
#for item in listInfos:
|
||||
# 클래스 타잎을 확인해야 하지만만.. 생략.
|
||||
# title, url, artist, group, series(parady), type, tags, hitomi ID, hitomi file, eh ID, eh tor
|
||||
|
||||
def AddTagInfo(tagInfo):
|
||||
pass
|
||||
|
||||
return strRet
|
||||
def AddTagInfo(strTag, strUrl):
|
||||
pass
|
||||
|
||||
def AddArtistInfo(artistInfo):
|
||||
pass
|
||||
|
||||
def AddArAddArtistInfo(strArtist, strUrl):
|
||||
pass
|
||||
|
||||
def AddSeriesInfo(SeriesInfo):
|
||||
pass
|
||||
|
||||
def AddSeriesInfo(strSerires, strUrl):
|
||||
pass
|
||||
|
||||
def AddTypeInfo(typeInfo):
|
||||
pass
|
||||
|
||||
def AddTypeInfo(strType, strUrl):
|
||||
pass
|
||||
|
||||
|
||||
def getSheet(sheetName):
|
||||
if None == m_wb:
|
||||
return
|
||||
|
||||
if sheetName in m_wb.sheetnames:
|
||||
return m_wb[sheetName]
|
||||
|
||||
return m_wb.create_sheet(title=sheetName)
|
||||
|
||||
#
|
||||
def GetXLSPath(path):
|
||||
retPath = path
|
||||
if False == os.path.exists(path):
|
||||
retPath = os.path.abspath(__file__)
|
||||
|
||||
return retPath + xls_name
|
||||
|
||||
|
||||
# #
|
||||
|
||||
Reference in New Issue
Block a user