From 31c800705559d17c2a73a52c867a51569264eafa Mon Sep 17 00:00:00 2001 From: DazedAnon Date: Fri, 27 Sep 2024 11:04:34 -0500 Subject: [PATCH] ruff formatting --- modules/alice.py | 15 +++++++++++---- modules/anim.py | 12 ++++++++++-- modules/csv.py | 12 ++++++++++-- modules/eushully.py | 11 +++++++++-- modules/images.py | 10 ++++++++-- modules/irissoft.py | 15 +++++++++++---- modules/javascript.py | 11 +++++++++-- modules/json.py | 12 ++++++++++-- modules/kansen.py | 11 +++++++++-- modules/lune.py | 12 ++++++++++-- modules/main.py | 6 ++++-- modules/nscript.py | 11 +++++++++-- modules/regex.py | 11 +++++++++-- modules/rpgmakerace.py | 10 +++++++++- modules/rpgmakermvmz.py | 12 ++++++++++-- modules/rpgmakerplugin.py | 11 +++++++++-- modules/tyrano.py | 11 +++++++++-- modules/wolf.py | 10 +++++++++- modules/wolf2.py | 11 +++++++++-- 19 files changed, 174 insertions(+), 40 deletions(-) diff --git a/modules/alice.py b/modules/alice.py index da644d4..5d38bb2 100644 --- a/modules/alice.py +++ b/modules/alice.py @@ -1,5 +1,12 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -89,7 +96,7 @@ def handleAlice(filename, estimate): with LOCK: totalTokens[0] += translatedData[1][0] totalTokens[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' @@ -187,7 +194,7 @@ def translateLines(linesList, pbar): # Check if next line should be merged if insertBool is True: - linesList[i] = re.sub(r'(s\[[0-9]+\]) = \"(.+)\"', rf'\1 = ""', linesList[i]) + linesList[i] = re.sub(r'(s\[[0-9]+\]) = \"(.+)\"', r'\1 = ""', linesList[i]) linesList[i] = linesList[i].replace(';', '') start = i while (len(linesList) > i+1 and re.search(r's\[[0-9]+\] = \"\s+(.*)\"', linesList[i+1]) != None): @@ -196,7 +203,7 @@ def translateLines(linesList, pbar): match = re.findall(r's\[[0-9]+\] = \"\s+(.*)\"', linesList[i]) currentGroup.append(match[0]) if insertBool is True: - linesList[i] = re.sub(r'(s\[[0-9]+\]) = \"\s+(.+)\"', rf'\1 = ""', linesList[i]) + linesList[i] = re.sub(r'(s\[[0-9]+\]) = \"\s+(.+)\"', r'\1 = ""', linesList[i]) linesList[i] = linesList[i].replace(';', '') i += 1 diff --git a/modules/anim.py b/modules/anim.py index 41de255..bab2169 100644 --- a/modules/anim.py +++ b/modules/anim.py @@ -1,5 +1,13 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -89,7 +97,7 @@ def handleAnim(filename, estimate): with LOCK: totalTokens[0] += translatedData[1][0] totalTokens[1] += translatedData[1][1] - except Exception as e: + except Exception: return 'Fail' return getResultString(['', totalTokens, None], end - start, 'TOTAL') diff --git a/modules/csv.py b/modules/csv.py index 83cfdb2..1e4ad49 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -1,6 +1,14 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai, csv -from concurrent.futures import ThreadPoolExecutor, as_completed +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai +import csv from pathlib import Path from colorama import Fore from dotenv import load_dotenv diff --git a/modules/eushully.py b/modules/eushully.py index cb8e3a0..7c291a1 100644 --- a/modules/eushully.py +++ b/modules/eushully.py @@ -1,5 +1,12 @@ # Libraries -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -89,7 +96,7 @@ def handleEushully(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/images.py b/modules/images.py index 6d8864a..2f70a13 100644 --- a/modules/images.py +++ b/modules/images.py @@ -1,7 +1,13 @@ # Libraries from PIL import Image, ImageDraw, ImageFont -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai -from concurrent.futures import ThreadPoolExecutor, as_completed +import json +import os +import re +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv diff --git a/modules/irissoft.py b/modules/irissoft.py index 01059f0..733d081 100644 --- a/modules/irissoft.py +++ b/modules/irissoft.py @@ -1,5 +1,12 @@ # Libraries -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -88,7 +95,7 @@ def handleIris(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' @@ -261,12 +268,12 @@ def translateIris(data, pbar, filename, translatedList): if count != 0: if voice == True: #MSG for each item in the list - data.insert(i, f'#MSGVOICE,\n') + data.insert(i, '#MSGVOICE,\n') i += 1 data.insert(i, f'{voiceVar}') i += 1 else: - data.insert(i, f'#MSG,\n') + data.insert(i, '#MSG,\n') i += 1 if speaker: data[i] = f'\u3000{speaker}\n' diff --git a/modules/javascript.py b/modules/javascript.py index 9b7da5d..8080db0 100644 --- a/modules/javascript.py +++ b/modules/javascript.py @@ -1,5 +1,12 @@ # Libraries -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -88,7 +95,7 @@ def handleJavascript(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/json.py b/modules/json.py index c7524b4..b67431c 100644 --- a/modules/json.py +++ b/modules/json.py @@ -1,5 +1,13 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -81,7 +89,7 @@ def handleJSON(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: return 'Fail' return getResultString(['', TOKENS, None], end - start, 'TOTAL') diff --git a/modules/kansen.py b/modules/kansen.py index 32a778c..fb341bf 100644 --- a/modules/kansen.py +++ b/modules/kansen.py @@ -1,5 +1,12 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -88,7 +95,7 @@ def handleKansen(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/lune.py b/modules/lune.py index ca185a6..879e839 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -1,5 +1,13 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -81,7 +89,7 @@ def handleLune(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: return 'Fail' return getResultString(['', TOKENS, None], end - start, 'TOTAL') diff --git a/modules/main.py b/modules/main.py index 8bf7e24..934f007 100644 --- a/modules/main.py +++ b/modules/main.py @@ -1,4 +1,6 @@ -import sys, os, traceback +import sys +import os +import traceback from concurrent.futures import ThreadPoolExecutor, as_completed from colorama import Fore from tqdm import tqdm @@ -13,7 +15,7 @@ for env in ['api','key','organization','model','language','timeout','fileThreads tqdm.write(Fore.RED + f'Environment variable {env} is not set!') envMissing = True if envMissing: - tqdm.write(Fore.RED + f'Some of the required environment values may not be set correctly. You can set \ + tqdm.write(Fore.RED + 'Some of the required environment values may not be set correctly. You can set \ these values using an .env file, for an example see .env.example') from modules.rpgmakermvmz import handleMVMZ diff --git a/modules/nscript.py b/modules/nscript.py index be59a22..c22b700 100644 --- a/modules/nscript.py +++ b/modules/nscript.py @@ -1,6 +1,13 @@ # Libraries import json -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -98,7 +105,7 @@ def handleOnscripter(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/regex.py b/modules/regex.py index 037d65e..0dccff4 100644 --- a/modules/regex.py +++ b/modules/regex.py @@ -1,5 +1,12 @@ # Libraries -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -88,7 +95,7 @@ def handleRegex(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index c9c96cd..dc5275e 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -1,5 +1,13 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from colorama import Fore diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 9d481b4..fafca94 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -1,5 +1,13 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from colorama import Fore @@ -650,7 +658,7 @@ def searchNames(data, pbar, context): if len(nameList) == len(translatedNameBatch): j = k with open('translations.txt', 'a', encoding='utf-8') as file: - file.write(f'# Items\n') + file.write('# Items\n') while j < i: # Empty Data if data[j] is None or data[j]['name'] == "": diff --git a/modules/rpgmakerplugin.py b/modules/rpgmakerplugin.py index ffc3775..ce4fb36 100644 --- a/modules/rpgmakerplugin.py +++ b/modules/rpgmakerplugin.py @@ -1,6 +1,13 @@ # Libraries import json -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -90,7 +97,7 @@ def handlePlugin(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/tyrano.py b/modules/tyrano.py index d3f2cbe..b63a5d6 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -1,5 +1,12 @@ # Libraries -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -93,7 +100,7 @@ def handleTyrano(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail' diff --git a/modules/wolf.py b/modules/wolf.py index c1c7fe0..f302d8b 100644 --- a/modules/wolf.py +++ b/modules/wolf.py @@ -1,5 +1,13 @@ # Libraries -import json, os, re, textwrap, threading, time, traceback, tiktoken, openai +import json +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from colorama import Fore diff --git a/modules/wolf2.py b/modules/wolf2.py index 582fbb4..aa51a47 100644 --- a/modules/wolf2.py +++ b/modules/wolf2.py @@ -1,6 +1,13 @@ # Libraries import json -import os, re, textwrap, threading, time, traceback, tiktoken, openai +import os +import re +import textwrap +import threading +import time +import traceback +import tiktoken +import openai from pathlib import Path from colorama import Fore from dotenv import load_dotenv @@ -89,7 +96,7 @@ def handleWOLF2(filename, estimate): with LOCK: TOKENS[0] += translatedData[1][0] TOKENS[1] += translatedData[1][1] - except Exception as e: + except Exception: traceback.print_exc() return 'Fail'