From 7b24cdee4e83a9f36ce4f42ebebb3a990026f5d9 Mon Sep 17 00:00:00 2001 From: dtlnor Date: Wed, 11 Jan 2023 11:41:15 +0900 Subject: [PATCH] move down the worker --- main.py | 70 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/main.py b/main.py index 68fa9ba..c93c267 100644 --- a/main.py +++ b/main.py @@ -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 \ @@ -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',