Skip to content

Commit

Permalink
move down the worker
Browse files Browse the repository at this point in the history
  • Loading branch information
dtlnor committed Jan 11, 2023
1 parent 6f472ce commit 7b24cde
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,41 +55,6 @@ def DebugTest(msg, filenameFull):
REMSGUtil.searchAttrTy(msg, filenameFull, -1)
REMSGUtil.searchSameGuid(msg, filenameFull)

def worker(item, mode = "csv", modFile: str = None, lang : int = REMSGUtil.SHORT_LANG_LU["ja"], attrSum=""):
try:
filenameFull = os.path.abspath(item)
print("processing:"+filenameFull)

msg = REMSGUtil.importMSG(filenameFull)
# DebugTest(msg,filenameFull)

if mode == "csv":
if modFile is None:
REMSGUtil.exportCSV(msg, filenameFull+'.'+mode)
else:
REMSGUtil.exportMSG(msg=REMSGUtil.importCSV(msg, modFile), filename=filenameFull+'.new')

elif mode == "txt":
if modFile is None:
REMSGUtil.exportTXT(msg, filenameFull+'.'+mode, lang)
else:
REMSGUtil.exportMSG(msg=REMSGUtil.importTXT(msg, modFile, lang), filename=filenameFull+'.new')

elif mode == "json":
if modFile is None:
REMSGUtil.exportJson(msg, filenameFull+'.'+mode)
else:
REMSGUtil.exportMSG(msg=REMSGUtil.importJson(msg, modFile), filename=filenameFull+'.new')

elif mode == "dump":
REMSGUtil.exportMHRTextDump(msg, filenameFull+'.txt')


except Exception as e:
print(f'error with file {item}')
# print(traceback.format_exc())
logger.exception(e)

def isValidMsgName(name: str) -> bool:
return ".msg" in name.lower() and \
not name.lower().endswith(".txt") and \
Expand Down Expand Up @@ -127,6 +92,41 @@ def fillList(path: str, filetype = 'msg'):
else:
return []

def worker(item, mode = "csv", modFile: str = None, lang : int = REMSGUtil.SHORT_LANG_LU["ja"], attrSum=""):
try:
filenameFull = os.path.abspath(item)
print("processing:"+filenameFull)

msg = REMSGUtil.importMSG(filenameFull)
# DebugTest(msg,filenameFull)

if mode == "csv":
if modFile is None:
REMSGUtil.exportCSV(msg, filenameFull+'.'+mode)
else:
REMSGUtil.exportMSG(msg=REMSGUtil.importCSV(msg, modFile), filename=filenameFull+'.new')

elif mode == "txt":
if modFile is None:
REMSGUtil.exportTXT(msg, filenameFull+'.'+mode, lang)
else:
REMSGUtil.exportMSG(msg=REMSGUtil.importTXT(msg, modFile, lang), filename=filenameFull+'.new')

elif mode == "json":
if modFile is None:
REMSGUtil.exportJson(msg, filenameFull+'.'+mode)
else:
REMSGUtil.exportMSG(msg=REMSGUtil.importJson(msg, modFile), filename=filenameFull+'.new')

elif mode == "dump":
REMSGUtil.exportMHRTextDump(msg, filenameFull+'.txt')


except Exception as e:
print(f'error with file {item}')
# print(traceback.format_exc())
logger.exception(e)

def main():
parser = argparse.ArgumentParser(
prog = 'REMSG_Converter.exe',
Expand Down

0 comments on commit 7b24cde

Please sign in to comment.