164 lines
3.1 KiB
Python
164 lines
3.1 KiB
Python
import os
|
|
from openpyxl import opyxl
|
|
from openpyxl.utils import xlsUtils
|
|
|
|
import DataClass as stManga
|
|
import UtilPack as util
|
|
|
|
|
|
xls_name = "mangaDB.xlsx"
|
|
m_wb = None
|
|
|
|
sheetName_Mangainfo = "MangaInfo"
|
|
sheetName_Artists = "Artists"
|
|
sheetName_Tags = "Tags"
|
|
|
|
strMngSht = "MngInfo"
|
|
strArtSht = "ArtInfo"
|
|
strTagSht = "TagInfo"
|
|
|
|
#
|
|
def DBXLSOpen(path):
|
|
xls_path = GetXLSPath(path)
|
|
util.DbgOut(xls_path)
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
# #
|
|
# def XLSWriteMangainfo(title, url, *tags):
|
|
# #
|
|
# try:
|
|
# wb = load_workbook(xls_path)
|
|
# print("Open Successed")
|
|
# except FileNotFoundError:
|
|
# wb = Workbook()
|
|
# print("xls Created")
|
|
|
|
# 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']
|
|
|
|
# # 폴더 경로
|
|
# folder_path = '/media/gerd/test/hiyobi_temp/'
|
|
|
|
# # 폴더 내의 파일 및 폴더 목록 가져오기
|
|
# items = os.listdir(folder_path)
|
|
|
|
# index = 2
|
|
# # 파일 및 폴더 목록 출력
|
|
# for item in items:
|
|
# pos = 'A' + str(index)
|
|
# ws2[pos] = item
|
|
# index += 1
|
|
# #print(item)
|
|
|
|
# print(str(index) + " searched")
|
|
# wb.save(xls_path)
|
|
|
|
# wb.close()
|
|
|
|
|