From f6312f7207fbe28d3aeeaf09674e10bac542e1cd Mon Sep 17 00:00:00 2001 From: beacon Date: Sat, 26 Aug 2023 20:41:53 +0300 Subject: [PATCH] some test changes --- lib/__pycache__/translate.cpython-310.pyc | Bin 0 -> 1039 bytes lib/translate.py | 15 ++++++++++++--- main.py | 8 ++++---- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 lib/__pycache__/translate.cpython-310.pyc mode change 100644 => 100755 main.py diff --git a/lib/__pycache__/translate.cpython-310.pyc b/lib/__pycache__/translate.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e2f6dc3f1abf033206f6ec91b85eec73fad9e452 GIT binary patch literal 1039 zcmZ8f&ubJh6izak+3C-FWXg%3GXHE<$K9{U!I(p7$rD<93R3*PRM6xoE;t- z_fYh8R6u}cWbJgNYZPskvD{npD1iVt_;2VM2f9j{wL`>{l_s?{6&H{e#paQzb3|+FkDf*wNI)i{O}VaZ4MaPxGINMz6U*DNHqF5DmuUgEuHx-T6p}F7XF91W~f}J*-(kC3Ln;%JD~MkANopG$ToL5Ss#-wjJo8A z@of;LMOhiuaKT=sGV4VtSgJk{bpw4zw_6)B7cG1o|D>f=(mIpcLPr!r#mI9jOV|IN zh{bXT85ouzLcB*WqvCXwa>gig;-L&@aKuO4p8sM#qtldsXVd&^a2#G_^ePR|qZTl{ wNl(AiS69$d*H9s0*lIE#6h8nBvOc43I#hTkmr!Nmu47WWd_o%1aXQI=12v8@8UO$Q literal 0 HcmV?d00001 diff --git a/lib/translate.py b/lib/translate.py index 0c9715c..8b3b1e5 100644 --- a/lib/translate.py +++ b/lib/translate.py @@ -1,10 +1,13 @@ #!/usr/bin/pyhton3 import requests import time +from random import randint + def translate(_input, lang='RU'): url = "https://www2.deepl.com/jsonrpc" + _id = randint(10000000, 99999999) r = requests.post( url, @@ -29,8 +32,14 @@ def translate(_input, lang='RU'): "commonJobParams": {}, "timestamp": int(round(time.time() * 1000)) }, - "id": 40890009 + "id": 40890008 } ) - print(r.json()) - return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence'] + print(_id) + try: + return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence'] + except: + print(r.json()) + + + diff --git a/main.py b/main.py old mode 100644 new mode 100755 index d4dc982..0b5c604 --- a/main.py +++ b/main.py @@ -9,6 +9,7 @@ from lib.translate import translate # path = "C:\Users\riksl\PycharmProjects\weapon-project-extended" name = "weapongenerator.lua" +_tmp :str = "" def _lister(_path) -> list: @@ -31,7 +32,6 @@ def parsing_file(f): for _str in _list: if _str.find('%_t') != -1 or _str.find('%_T') != -1: - print(_str) _to_translate.append(_str) return _to_translate @@ -45,9 +45,9 @@ def parsing_file(f): for _str in parsing_file(name): print(_str) test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str) - time.sleep(5) - print(test) - print(translate(test[0][0]), test[0][0]) + _tmp = _tmp + test[0][0] + '\n' + +print(translate(_tmp)) def all_to_translate(): pass