harry
commited on
Commit
·
0b2a8ae
1
Parent(s):
46d68d5
update tencent env var name
Browse files
deep_translator/constants.py
CHANGED
@@ -7,8 +7,8 @@ LIBRE_ENV_VAR = "LIBRE_API_KEY"
|
|
7 |
MSFT_ENV_VAR = "MICROSOFT_API_KEY"
|
8 |
QCRI_ENV_VAR = "QCRI_API_KEY"
|
9 |
YANDEX_ENV_VAR = "YANDEX_API_KEY"
|
10 |
-
|
11 |
-
|
12 |
|
13 |
|
14 |
BASE_URLS = {
|
|
|
7 |
MSFT_ENV_VAR = "MICROSOFT_API_KEY"
|
8 |
QCRI_ENV_VAR = "QCRI_API_KEY"
|
9 |
YANDEX_ENV_VAR = "YANDEX_API_KEY"
|
10 |
+
TENCENT_SECRET_ID_ENV_VAR = "TENCENT_SECRET_ID"
|
11 |
+
TENCENT_SECRET_KEY_ENV_VAR = "TENCENT_SECRET_KEY"
|
12 |
|
13 |
|
14 |
BASE_URLS = {
|
deep_translator/tencent.py
CHANGED
@@ -16,9 +16,9 @@ import requests
|
|
16 |
from deep_translator.base import BaseTranslator
|
17 |
from deep_translator.constants import (
|
18 |
BASE_URLS,
|
19 |
-
TENCENT_ID_VAR,
|
20 |
-
TENCENT_KEY_VAR,
|
21 |
TENCENT_LANGUAGE_TO_CODE,
|
|
|
|
|
22 |
)
|
23 |
from deep_translator.exceptions import (
|
24 |
ApiKeyException,
|
@@ -39,8 +39,10 @@ class TencentTranslator(BaseTranslator):
|
|
39 |
self,
|
40 |
source: str = "en",
|
41 |
target: str = "zh",
|
42 |
-
secret_id: Optional[str] = os.getenv(
|
43 |
-
secret_key: Optional[str] = os.getenv(
|
|
|
|
|
44 |
**kwargs
|
45 |
):
|
46 |
"""
|
@@ -51,10 +53,10 @@ class TencentTranslator(BaseTranslator):
|
|
51 |
@param target: target language
|
52 |
"""
|
53 |
if not secret_id:
|
54 |
-
raise ApiKeyException(env_var=
|
55 |
|
56 |
if not secret_key:
|
57 |
-
raise ApiKeyException(env_var=
|
58 |
|
59 |
self.secret_id = secret_id
|
60 |
self.secret_key = secret_key
|
|
|
16 |
from deep_translator.base import BaseTranslator
|
17 |
from deep_translator.constants import (
|
18 |
BASE_URLS,
|
|
|
|
|
19 |
TENCENT_LANGUAGE_TO_CODE,
|
20 |
+
TENCENT_SECRET_ID_ENV_VAR,
|
21 |
+
TENCENT_SECRET_KEY_ENV_VAR,
|
22 |
)
|
23 |
from deep_translator.exceptions import (
|
24 |
ApiKeyException,
|
|
|
39 |
self,
|
40 |
source: str = "en",
|
41 |
target: str = "zh",
|
42 |
+
secret_id: Optional[str] = os.getenv(TENCENT_SECRET_ID_ENV_VAR, None),
|
43 |
+
secret_key: Optional[str] = os.getenv(
|
44 |
+
TENCENT_SECRET_KEY_ENV_VAR, None
|
45 |
+
),
|
46 |
**kwargs
|
47 |
):
|
48 |
"""
|
|
|
53 |
@param target: target language
|
54 |
"""
|
55 |
if not secret_id:
|
56 |
+
raise ApiKeyException(env_var=TENCENT_SECRET_ID_ENV_VAR)
|
57 |
|
58 |
if not secret_key:
|
59 |
+
raise ApiKeyException(env_var=TENCENT_SECRET_KEY_ENV_VAR)
|
60 |
|
61 |
self.secret_id = secret_id
|
62 |
self.secret_key = secret_key
|