From 045a321a4f169944998a3637a86c92eb8479e90d Mon Sep 17 00:00:00 2001 From: Dazed Date: Sun, 23 Apr 2023 12:53:47 -0500 Subject: [PATCH] build: Create start script to make things easier to start --- README.md | 2 +- src/csvtl.py | 2 +- src/main.py | 17 ++++++++--------- start.py | 3 +++ 4 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 start.py diff --git a/README.md b/README.md index fa948a6..193ae41 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Currently in development. Goal is to eventually have ChatGPT nicely translate al 2. Add your API key and Organization Key to a .env file. An example can be found in the repo. 3. Add a prompt.txt file using prompt.example as a template. (See ChatGPT Prompt Section) 4. Untranslated JSON files go in `/files`. Anything translated will end up in `/translated` -5. Run `main.py` script either with VSCode or by running `.\main.py` in a CLI. +5. Run `start.py` script either with VSCode or by running `python .\start.py` in a CLI. ## ChatGPT Prompt: diff --git a/src/csvtl.py b/src/csvtl.py index 77a92fd..85f1d7e 100644 --- a/src/csvtl.py +++ b/src/csvtl.py @@ -20,8 +20,8 @@ from tqdm import tqdm load_dotenv() openai.organization = os.getenv('org') openai.api_key = os.getenv('key') -APICOST = .002 # Depends on the model https://openai.com/pricing +APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = 20 LOCK = threading.Lock() diff --git a/src/main.py b/src/main.py index 996ac72..5560396 100644 --- a/src/main.py +++ b/src/main.py @@ -4,17 +4,17 @@ import traceback from colorama import Fore import os -from rpgmakermvmz import handleMVMZ -from rpgmakerace import handleACE -from csvtl import handleCSV +from src.rpgmakermvmz import handleMVMZ +from src.rpgmakerace import handleACE +from src.csvtl import handleCSV THREADS = 20 # Info Message -print(Fore.LIGHTYELLOW_EX + "Do not close while translation is in progress. If a file fails or gets stuck, \ -Translated lines will remain translated so you don't have to worry about being charged \ -twice. You can simply copy the file generated in /translations back over to /files and \ -start the script again. It will skip over any translated text." + Fore.RESET, end='\n\n') +print(Fore.LIGHTYELLOW_EX + "WARNING: Once a translation starts do not close it unless you want to lose your\ +translated data. If a file fails or gets stuck, translated lines will remain translated so you don't have \ +to worry about being charged twice. You can simply copy the file generated in /translations back over to \ +/files and start the script again. It will skip over any translated text." + Fore.RESET, end='\n\n') def main(): estimate = '' @@ -65,6 +65,7 @@ def main(): for future in as_completed(futures): try: totalCost = future.result() + except Exception as e: tracebackLineNo = str(traceback.extract_tb(sys.exc_info()[2])[-1].lineno) print(Fore.RED + str(e) + '|' + tracebackLineNo + Fore.RESET) @@ -85,5 +86,3 @@ def deleteFolderFiles(folderPath): file_path = os.path.join(folderPath, filename) if file_path.endswith('.json'): os.remove(file_path) - -main() diff --git a/start.py b/start.py new file mode 100644 index 0000000..93efc80 --- /dev/null +++ b/start.py @@ -0,0 +1,3 @@ +from src.main import main + +main() \ No newline at end of file