From 18e89f01968d4d495432a9f0d671fdb730dd7152 Mon Sep 17 00:00:00 2001 From: Jason Park Date: Tue, 3 Jan 2023 02:40:00 +0900 Subject: [PATCH] feat: fixing mistakes --- src/lambda/post-comment/utils.py | 45 -------------------------------- 1 file changed, 45 deletions(-) diff --git a/src/lambda/post-comment/utils.py b/src/lambda/post-comment/utils.py index b4f1509af..dbcd31dd6 100644 --- a/src/lambda/post-comment/utils.py +++ b/src/lambda/post-comment/utils.py @@ -48,48 +48,3 @@ def api_response(code, body): "multiValueHeaders": {"Access-Control-Allow-Methods": ["POST", "OPTIONS", "GET", "PATCH", "DELETE"]}, "body": body } - - -def resp_handler(func=None, headers=None): - def handle(*args, **kwargs): - try: - resp = func(*args, **kwargs) - return api_response(200, resp) - except LookupError: - resp = JsonPayloadBuilder().add_status(False).add_data(None) \ - .add_message("Not found").compile() - return api_response(404, resp) - except Exception as e: - logging.error(str(e)) - resp = JsonPayloadBuilder().add_status(False).add_data(None) \ - .add_message("Internal error, please contact bugs@wasedatime.com.").compile() - return api_response(500, resp) - - return handle - - -def translate_text(text): - src_lang = client.detect_language(request={ - "parent": parent, - "content": text, - "mime_type": "text/plain" - }).languages[0].language_code - - translations = {} - - for lang in langs: - if lang == src_lang: - translations[lang] = text - continue - - translated = client.translate_text(request={ - "parent": parent, - "contents": [text], - "mime_type": "text/plain", - "source_language_code": src_lang, - "target_language_code": lang - }).translations[0].translated_text - - translations[lang] = translated or '' - - return src_lang, translations