some test changes

This commit is contained in:
2023-08-26 20:41:53 +03:00
parent 21a54e1585
commit f6312f7207
3 changed files with 16 additions and 7 deletions

Binary file not shown.

View File

@@ -1,10 +1,13 @@
#!/usr/bin/pyhton3 #!/usr/bin/pyhton3
import requests import requests
import time import time
from random import randint
def translate(_input, lang='RU'): def translate(_input, lang='RU'):
url = "https://www2.deepl.com/jsonrpc" url = "https://www2.deepl.com/jsonrpc"
_id = randint(10000000, 99999999)
r = requests.post( r = requests.post(
url, url,
@@ -29,8 +32,14 @@ def translate(_input, lang='RU'):
"commonJobParams": {}, "commonJobParams": {},
"timestamp": int(round(time.time() * 1000)) "timestamp": int(round(time.time() * 1000))
}, },
"id": 40890009 "id": 40890008
} }
) )
print(r.json()) print(_id)
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence'] try:
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
except:
print(r.json())

8
main.py Normal file → Executable file
View File

@@ -9,6 +9,7 @@ from lib.translate import translate
# path = "C:\Users\riksl\PycharmProjects\weapon-project-extended" # path = "C:\Users\riksl\PycharmProjects\weapon-project-extended"
name = "weapongenerator.lua" name = "weapongenerator.lua"
_tmp :str = ""
def _lister(_path) -> list: def _lister(_path) -> list:
@@ -31,7 +32,6 @@ def parsing_file(f):
for _str in _list: for _str in _list:
if _str.find('%_t') != -1 or _str.find('%_T') != -1: if _str.find('%_t') != -1 or _str.find('%_T') != -1:
print(_str)
_to_translate.append(_str) _to_translate.append(_str)
return _to_translate return _to_translate
@@ -45,9 +45,9 @@ def parsing_file(f):
for _str in parsing_file(name): for _str in parsing_file(name):
print(_str) print(_str)
test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str) test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str)
time.sleep(5) _tmp = _tmp + test[0][0] + '\n'
print(test)
print(translate(test[0][0]), test[0][0]) print(translate(_tmp))
def all_to_translate(): def all_to_translate():
pass pass