nidhal baccouri
commited on
Commit
·
b8fcb92
1
Parent(s):
050157d
fixed relative imports bug
Browse files- deep_translator/deepl.py +2 -2
- deep_translator/google_trans.py +3 -7
- deep_translator/libre.py +3 -3
- deep_translator/linguee.py +3 -3
- deep_translator/main.py +10 -10
- deep_translator/microsoft.py +2 -2
- deep_translator/mymemory.py +3 -3
- deep_translator/papago.py +2 -2
- deep_translator/parent.py +1 -1
- deep_translator/pons.py +2 -2
- deep_translator/qcri.py +2 -2
- deep_translator/yandex.py +2 -2
deep_translator/deepl.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import requests
|
2 |
-
from constants import BASE_URLS, DEEPL_LANGUAGE_TO_CODE
|
3 |
-
from exceptions import (ServerException,
|
4 |
TranslationNotFound,
|
5 |
LanguageNotSupportedException,
|
6 |
AuthorizationException)
|
|
|
1 |
import requests
|
2 |
+
from .constants import BASE_URLS, DEEPL_LANGUAGE_TO_CODE
|
3 |
+
from .exceptions import (ServerException,
|
4 |
TranslationNotFound,
|
5 |
LanguageNotSupportedException,
|
6 |
AuthorizationException)
|
deep_translator/google_trans.py
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
google translator API
|
3 |
"""
|
4 |
|
5 |
-
from constants import BASE_URLS, GOOGLE_LANGUAGES_TO_CODES, GOOGLE_LANGUAGES_SECONDARY_NAMES
|
6 |
-
from exceptions import TooManyRequests, LanguageNotSupportedException, TranslationNotFound, NotValidPayload, RequestError
|
7 |
-
from parent import BaseTranslator
|
8 |
from bs4 import BeautifulSoup
|
9 |
import requests
|
10 |
from time import sleep
|
@@ -198,7 +198,3 @@ class GoogleTranslator(BaseTranslator):
|
|
198 |
arr.append(translated)
|
199 |
return arr
|
200 |
|
201 |
-
|
202 |
-
if __name__ == '__main__':
|
203 |
-
res = GoogleTranslator('es', 'en').translate_file('./test.txt')
|
204 |
-
print("res: ", res)
|
|
|
2 |
google translator API
|
3 |
"""
|
4 |
|
5 |
+
from .constants import BASE_URLS, GOOGLE_LANGUAGES_TO_CODES, GOOGLE_LANGUAGES_SECONDARY_NAMES
|
6 |
+
from .exceptions import TooManyRequests, LanguageNotSupportedException, TranslationNotFound, NotValidPayload, RequestError
|
7 |
+
from .parent import BaseTranslator
|
8 |
from bs4 import BeautifulSoup
|
9 |
import requests
|
10 |
from time import sleep
|
|
|
198 |
arr.append(translated)
|
199 |
return arr
|
200 |
|
|
|
|
|
|
|
|
deep_translator/libre.py
CHANGED
@@ -3,9 +3,9 @@ LibreTranslate API
|
|
3 |
"""
|
4 |
|
5 |
import requests
|
6 |
-
from parent import BaseTranslator
|
7 |
-
from constants import BASE_URLS,LIBRE_LANGUAGES_TO_CODES, LIBRE_CODES_TO_LANGUAGES
|
8 |
-
from exceptions import (ServerException,
|
9 |
TranslationNotFound,
|
10 |
LanguageNotSupportedException,
|
11 |
AuthorizationException,
|
|
|
3 |
"""
|
4 |
|
5 |
import requests
|
6 |
+
from .parent import BaseTranslator
|
7 |
+
from .constants import BASE_URLS,LIBRE_LANGUAGES_TO_CODES, LIBRE_CODES_TO_LANGUAGES
|
8 |
+
from .exceptions import (ServerException,
|
9 |
TranslationNotFound,
|
10 |
LanguageNotSupportedException,
|
11 |
AuthorizationException,
|
deep_translator/linguee.py
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
linguee translator API
|
3 |
"""
|
4 |
|
5 |
-
from constants import BASE_URLS, LINGUEE_LANGUAGES_TO_CODES, LINGUEE_CODE_TO_LANGUAGE
|
6 |
-
from exceptions import (LanguageNotSupportedException,
|
7 |
TranslationNotFound,
|
8 |
NotValidPayload,
|
9 |
ElementNotFoundInGetRequest,
|
10 |
RequestError,
|
11 |
TooManyRequests)
|
12 |
-
from parent import BaseTranslator
|
13 |
from bs4 import BeautifulSoup
|
14 |
import requests
|
15 |
from requests.utils import requote_uri
|
|
|
2 |
linguee translator API
|
3 |
"""
|
4 |
|
5 |
+
from .constants import BASE_URLS, LINGUEE_LANGUAGES_TO_CODES, LINGUEE_CODE_TO_LANGUAGE
|
6 |
+
from .exceptions import (LanguageNotSupportedException,
|
7 |
TranslationNotFound,
|
8 |
NotValidPayload,
|
9 |
ElementNotFoundInGetRequest,
|
10 |
RequestError,
|
11 |
TooManyRequests)
|
12 |
+
from .parent import BaseTranslator
|
13 |
from bs4 import BeautifulSoup
|
14 |
import requests
|
15 |
from requests.utils import requote_uri
|
deep_translator/main.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
"""Console script for deep_translator."""
|
2 |
|
3 |
import click
|
4 |
-
from google_trans import GoogleTranslator
|
5 |
-
from mymemory import MyMemoryTranslator
|
6 |
-
from deepl import DeepL
|
7 |
-
from qcri import QCRI
|
8 |
-
from linguee import LingueeTranslator
|
9 |
-
from pons import PonsTranslator
|
10 |
-
from yandex import YandexTranslator
|
11 |
-
from microsoft import MicrosoftTranslator
|
12 |
-
from papago import PapagoTranslator
|
13 |
-
from libre import LibreTranslator
|
14 |
|
15 |
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
16 |
@click.group()
|
|
|
1 |
"""Console script for deep_translator."""
|
2 |
|
3 |
import click
|
4 |
+
from .google_trans import GoogleTranslator
|
5 |
+
from .mymemory import MyMemoryTranslator
|
6 |
+
from .deepl import DeepL
|
7 |
+
from .qcri import QCRI
|
8 |
+
from .linguee import LingueeTranslator
|
9 |
+
from .pons import PonsTranslator
|
10 |
+
from .yandex import YandexTranslator
|
11 |
+
from .microsoft import MicrosoftTranslator
|
12 |
+
from .papago import PapagoTranslator
|
13 |
+
from .libre import LibreTranslator
|
14 |
|
15 |
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
16 |
@click.group()
|
deep_translator/microsoft.py
CHANGED
@@ -4,8 +4,8 @@ import requests
|
|
4 |
import logging
|
5 |
import sys
|
6 |
|
7 |
-
from constants import BASE_URLS, MICROSOFT_CODES_TO_LANGUAGES
|
8 |
-
from exceptions import LanguageNotSupportedException, ServerException, MicrosoftAPIerror
|
9 |
|
10 |
|
11 |
class MicrosoftTranslator:
|
|
|
4 |
import logging
|
5 |
import sys
|
6 |
|
7 |
+
from .constants import BASE_URLS, MICROSOFT_CODES_TO_LANGUAGES
|
8 |
+
from .exceptions import LanguageNotSupportedException, ServerException, MicrosoftAPIerror
|
9 |
|
10 |
|
11 |
class MicrosoftTranslator:
|
deep_translator/mymemory.py
CHANGED
@@ -4,13 +4,13 @@ mymemory translator API
|
|
4 |
import logging
|
5 |
import warnings
|
6 |
|
7 |
-
from constants import BASE_URLS, GOOGLE_LANGUAGES_TO_CODES
|
8 |
-
from exceptions import (NotValidPayload,
|
9 |
TranslationNotFound,
|
10 |
LanguageNotSupportedException,
|
11 |
RequestError,
|
12 |
TooManyRequests)
|
13 |
-
from parent import BaseTranslator
|
14 |
import requests
|
15 |
from time import sleep
|
16 |
|
|
|
4 |
import logging
|
5 |
import warnings
|
6 |
|
7 |
+
from .constants import BASE_URLS, GOOGLE_LANGUAGES_TO_CODES
|
8 |
+
from .exceptions import (NotValidPayload,
|
9 |
TranslationNotFound,
|
10 |
LanguageNotSupportedException,
|
11 |
RequestError,
|
12 |
TooManyRequests)
|
13 |
+
from .parent import BaseTranslator
|
14 |
import requests
|
15 |
from time import sleep
|
16 |
|
deep_translator/papago.py
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
google translator API
|
3 |
"""
|
4 |
import json
|
5 |
-
from constants import BASE_URLS, PAPAGO_LANGUAGE_TO_CODE
|
6 |
-
from exceptions import LanguageNotSupportedException, TranslationNotFound, NotValidPayload
|
7 |
import requests
|
8 |
import warnings
|
9 |
import logging
|
|
|
2 |
google translator API
|
3 |
"""
|
4 |
import json
|
5 |
+
from .constants import BASE_URLS, PAPAGO_LANGUAGE_TO_CODE
|
6 |
+
from .exceptions import LanguageNotSupportedException, TranslationNotFound, NotValidPayload
|
7 |
import requests
|
8 |
import warnings
|
9 |
import logging
|
deep_translator/parent.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
"""parent translator class"""
|
2 |
|
3 |
-
from exceptions import NotValidPayload, NotValidLength, InvalidSourceOrTargetLanguage
|
4 |
from abc import ABC, abstractmethod
|
5 |
import string
|
6 |
|
|
|
1 |
"""parent translator class"""
|
2 |
|
3 |
+
from .exceptions import NotValidPayload, NotValidLength, InvalidSourceOrTargetLanguage
|
4 |
from abc import ABC, abstractmethod
|
5 |
import string
|
6 |
|
deep_translator/pons.py
CHANGED
@@ -3,8 +3,8 @@ pons translator API
|
|
3 |
"""
|
4 |
from bs4 import BeautifulSoup
|
5 |
import requests
|
6 |
-
from constants import BASE_URLS, PONS_LANGUAGES_TO_CODES, PONS_CODES_TO_LANGUAGES
|
7 |
-
from exceptions import (LanguageNotSupportedException,
|
8 |
TranslationNotFound,
|
9 |
NotValidPayload,
|
10 |
ElementNotFoundInGetRequest,
|
|
|
3 |
"""
|
4 |
from bs4 import BeautifulSoup
|
5 |
import requests
|
6 |
+
from .constants import BASE_URLS, PONS_LANGUAGES_TO_CODES, PONS_CODES_TO_LANGUAGES
|
7 |
+
from .exceptions import (LanguageNotSupportedException,
|
8 |
TranslationNotFound,
|
9 |
NotValidPayload,
|
10 |
ElementNotFoundInGetRequest,
|
deep_translator/qcri.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
import requests
|
3 |
-
from constants import BASE_URLS, QCRI_LANGUAGE_TO_CODE
|
4 |
-
from exceptions import (ServerException, TranslationNotFound)
|
5 |
|
6 |
|
7 |
class QCRI(object):
|
|
|
1 |
|
2 |
import requests
|
3 |
+
from .constants import BASE_URLS, QCRI_LANGUAGE_TO_CODE
|
4 |
+
from .exceptions import (ServerException, TranslationNotFound)
|
5 |
|
6 |
|
7 |
class QCRI(object):
|
deep_translator/yandex.py
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Yandex translator API
|
3 |
"""
|
4 |
import requests
|
5 |
-
from constants import BASE_URLS
|
6 |
-
from exceptions import (RequestError, ServerException, TranslationNotFound, TooManyRequests)
|
7 |
|
8 |
|
9 |
class YandexTranslator(object):
|
|
|
2 |
Yandex translator API
|
3 |
"""
|
4 |
import requests
|
5 |
+
from .constants import BASE_URLS
|
6 |
+
from .exceptions import (RequestError, ServerException, TranslationNotFound, TooManyRequests)
|
7 |
|
8 |
|
9 |
class YandexTranslator(object):
|