mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-22 07:51:00 +00:00
Run ruff
This commit is contained in:
parent
522b8b03d7
commit
3fd2abc1f9
2 changed files with 7 additions and 6 deletions
|
@ -1,15 +1,15 @@
|
||||||
import linguars
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
|
import linguars
|
||||||
|
|
||||||
|
|
||||||
class Language:
|
class Language:
|
||||||
def __init__(self, code, confidence):
|
def __init__(self, code, confidence):
|
||||||
self.code = code
|
self.code = code
|
||||||
self.confidence = float(confidence)
|
self.confidence = float(confidence)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ("code: {:<9} confidence: {:>5.1f} ".format(
|
return (f"code: {self.code:<9} confidence: {self.confidence:>5.1f} ")
|
||||||
self.code,
|
|
||||||
self.confidence))
|
|
||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def load_detector(langcodes = ()):
|
def load_detector(langcodes = ()):
|
||||||
|
@ -17,7 +17,7 @@ def load_detector(langcodes = ()):
|
||||||
for lc in langcodes:
|
for lc in langcodes:
|
||||||
try:
|
try:
|
||||||
languages.append(linguars.Language.from_iso_code_639_1(lc))
|
languages.append(linguars.Language.from_iso_code_639_1(lc))
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(f"{lc} is not supported by lingua")
|
print(f"{lc} is not supported by lingua")
|
||||||
pass # Not supported
|
pass # Not supported
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from argostranslate import translate
|
from argostranslate import translate
|
||||||
from functools import lru_cache
|
|
||||||
|
|
||||||
from libretranslate.detect import Detector
|
from libretranslate.detect import Detector
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue