From fceedc8135bdbb08ffb771d456d35613f2e72a80 Mon Sep 17 00:00:00 2001 From: dazedanon Date: Tue, 17 Jun 2025 12:20:00 -0500 Subject: [PATCH] Fix total time issue --- modules/regex.py | 2 ++ modules/rpgmakerace.py | 8 +++++++- modules/rpgmakermvmz.py | 8 +++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/regex.py b/modules/regex.py index b78fc8d..2ee5540 100644 --- a/modules/regex.py +++ b/modules/regex.py @@ -43,6 +43,7 @@ IGNORETLTEXT = False # Ignores all translated text. MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong) FILENAME = None TIMETOTAL = 0 # Total Time Taken for all translations +TIMETOTAL = 0 # Total Time Taken for all translations # tqdm Globals BAR_FORMAT = "{l_bar}{bar:10}{r_bar}{bar:-10b}" @@ -114,6 +115,7 @@ def handleRegex(filename, estimate): def getResultString(translatedData, translationTime, filename): + global TIMETOTAL # File Print String totalTokenstring = ( Fore.YELLOW + "[Input: " + str(translatedData[1][0]) + "]" diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index b8f4515..074ac8e 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -49,6 +49,7 @@ IGNORETLTEXT = True # Ignores all translated text. MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong) PBAR = None FILENAME = None +TIMETOTAL = 0 # Total Time Taken for all translations # Regex - Need to change this if you want to translate from/to other languages. Default is Japanese Regex LANGREGEX = r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+" @@ -226,6 +227,7 @@ def openFiles(filename): def getResultString(translatedData, translationTime, filename): + global TIMETOTAL # File Print String totalTokenstring = ( Fore.YELLOW + "[Input: " + str(translatedData[1][0]) + "]" @@ -234,7 +236,11 @@ def getResultString(translatedData, translationTime, filename): + "]" "[Cost: ${:,.4f}".format(((translatedData[1][0] / 1000000) * INPUTAPICOST) + ((translatedData[1][1] / 1000000) * OUTPUTAPICOST)) + "]" ) - timeString = Fore.BLUE + "[" + str(round(translationTime, 1)) + "s]" + if filename != "TOTAL": + timeString = Fore.BLUE + "[" + str(round(translationTime, 1)) + "s]" + TIMETOTAL += round(translationTime, 1) + else: + timeString = Fore.BLUE + "[" + str(round(TIMETOTAL, 1)) + "s]" if translatedData[2] is None: # Success diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 8288392..4d5f946 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -42,6 +42,7 @@ NAMESLIST = [] MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong) PBAR = None FILENAME = None +TIMETOTAL = 0 # Total Time Taken for all translations # Regex - Need to change this if you want to translate from/to other languages. Default is Japanese Regex LANGREGEX = r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+" @@ -208,6 +209,7 @@ def openFiles(filename): def getResultString(translatedData, translationTime, filename): + global TIMETOTAL # File Print String totalTokenstring = ( Fore.YELLOW + "[Input: " + str(translatedData[1][0]) + "]" @@ -216,7 +218,11 @@ def getResultString(translatedData, translationTime, filename): + "]" "[Cost: ${:,.4f}".format(((translatedData[1][0] / 1000000) * INPUTAPICOST) + ((translatedData[1][1] / 1000000) * OUTPUTAPICOST)) + "]" ) - timeString = Fore.BLUE + "[" + str(round(translationTime, 1)) + "s]" + if filename != "TOTAL": + timeString = Fore.BLUE + "[" + str(round(translationTime, 1)) + "s]" + TIMETOTAL += round(translationTime, 1) + else: + timeString = Fore.BLUE + "[" + str(round(TIMETOTAL, 1)) + "s]" if translatedData[2] is None: # Success