nidhal baccouri
commited on
Commit
·
a0b5eac
1
Parent(s):
0d1a764
removed relative imports
Browse files- deep_translator/__init__.py +14 -13
- deep_translator/deepl.py +2 -2
- 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/pons.py +2 -2
- deep_translator/qcri.py +3 -2
- deep_translator/yandex.py +2 -2
deep_translator/__init__.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
"""Top-level package for Deep Translator"""
|
2 |
|
3 |
# TODO: Discussion: Do these need to be in __init__.py? Are they intended to be exportable?
|
4 |
-
from
|
5 |
-
from
|
6 |
-
from
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
10 |
-
from
|
11 |
-
from
|
12 |
-
from
|
13 |
-
from
|
14 |
-
from
|
15 |
|
16 |
# TODO: Discussion: These should be declared in setup.cfg, setting them here is redundant
|
17 |
__author__ = """Nidhal Baccouri"""
|
@@ -27,7 +27,8 @@ __all__ = [
|
|
27 |
"MicrosoftTranslator",
|
28 |
"QCRI",
|
29 |
"DeepL",
|
30 |
-
"LibreTranslator"
|
|
|
31 |
"single_detection",
|
32 |
"batch_detection"
|
33 |
-
|
|
|
1 |
"""Top-level package for Deep Translator"""
|
2 |
|
3 |
# TODO: Discussion: Do these need to be in __init__.py? Are they intended to be exportable?
|
4 |
+
from google_trans import GoogleTranslator
|
5 |
+
from pons import PonsTranslator
|
6 |
+
from linguee import LingueeTranslator
|
7 |
+
from mymemory import MyMemoryTranslator
|
8 |
+
from yandex import YandexTranslator
|
9 |
+
from qcri import QCRI
|
10 |
+
from deepl import DeepL
|
11 |
+
from detection import single_detection, batch_detection
|
12 |
+
from microsoft import MicrosoftTranslator
|
13 |
+
from papago import PapagoTranslator
|
14 |
+
from libre import LibreTranslator
|
15 |
|
16 |
# TODO: Discussion: These should be declared in setup.cfg, setting them here is redundant
|
17 |
__author__ = """Nidhal Baccouri"""
|
|
|
27 |
"MicrosoftTranslator",
|
28 |
"QCRI",
|
29 |
"DeepL",
|
30 |
+
"LibreTranslator",
|
31 |
+
"PapagoTranslator",
|
32 |
"single_detection",
|
33 |
"batch_detection"
|
34 |
+
]
|
deep_translator/deepl.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import requests
|
2 |
-
from
|
3 |
-
from
|
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/libre.py
CHANGED
@@ -3,9 +3,9 @@ LibreTranslate API
|
|
3 |
"""
|
4 |
|
5 |
import requests
|
6 |
-
from
|
7 |
-
from
|
8 |
-
from
|
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
|
6 |
-
from
|
7 |
TranslationNotFound,
|
8 |
NotValidPayload,
|
9 |
ElementNotFoundInGetRequest,
|
10 |
RequestError,
|
11 |
TooManyRequests)
|
12 |
-
from
|
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
|
5 |
-
from
|
6 |
-
from
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
10 |
-
from
|
11 |
-
from
|
12 |
-
from
|
13 |
-
from
|
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
|
8 |
-
from
|
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
|
8 |
-
from
|
9 |
TranslationNotFound,
|
10 |
LanguageNotSupportedException,
|
11 |
RequestError,
|
12 |
TooManyRequests)
|
13 |
-
from
|
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
|
6 |
-
from
|
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/pons.py
CHANGED
@@ -3,8 +3,8 @@ pons translator API
|
|
3 |
"""
|
4 |
from bs4 import BeautifulSoup
|
5 |
import requests
|
6 |
-
from
|
7 |
-
from
|
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,8 @@
|
|
1 |
|
2 |
import requests
|
3 |
-
from
|
4 |
-
from
|
|
|
5 |
|
6 |
class QCRI(object):
|
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):
|
8 |
"""
|
deep_translator/yandex.py
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Yandex translator API
|
3 |
"""
|
4 |
import requests
|
5 |
-
from
|
6 |
-
from
|
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):
|