Skip to content

Commit

Permalink
fix: 兼容python3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhldr committed Sep 6, 2024
1 parent 5aa506d commit 4803060
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
25 changes: 15 additions & 10 deletions lfy/api/constant.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
'常量,尽可能不引用其他文件'
from lfy.api.server import (Server, aliyun, baidu, bing, com, google, huoshan,
tencent)
from lfy.api.server.aliyun import AliYunServer
from lfy.api.server.baidu import BaiduServer
from lfy.api.server.bing import BingServer
from lfy.api.server.com import AllServer
from lfy.api.server.google import GoogleServer
from lfy.api.server.huoshan import HuoShanServer
from lfy.api.server.tencent import TencentServer

SERVERS: list[Server] = [
com.AllServer(),
google.GoogleServer(),
bing.BingServer(),
baidu.BaiduServer(),
tencent.TencentServer(),
aliyun.AliYunServer(),
huoshan.HuoShanServer(),
SERVERS = [
AllServer(),
GoogleServer(),
BingServer(),
BaiduServer(),
TencentServer(),
AliYunServer(),
HuoShanServer(),
]


Expand Down
12 changes: 6 additions & 6 deletions lfy/api/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_lang(self, j=0):
return self.langs[0]
return self.langs[j]

def check_translate(self, api_key_s: str) -> tuple[bool, str]:
def check_translate(self, api_key_s: str):
"""实现检查翻译的参数
Args:
Expand All @@ -121,7 +121,7 @@ def check_translate(self, api_key_s: str) -> tuple[bool, str]:
print(api_key_s)
return True, "success"

def translate_text(self, text: str, lang_to: str, lang_from: str = "auto") -> tuple[bool, str]:
def translate_text(self, text: str, lang_to: str, lang_from: str = "auto"):
"""实现文本翻译的逻辑
Args:
Expand All @@ -135,15 +135,15 @@ def translate_text(self, text: str, lang_to: str, lang_from: str = "auto") -> tu
print(f"lang_to={lang_to} text={text}")
return True, "test"

def get_api_key_s(self) -> str | None:
def get_api_key_s(self):
"""字符串apikey
Returns:
_type_: _description_
"""
return None

def ocr_image(self, img_path: str) -> tuple[bool, str]:
def ocr_image(self, img_path: str):
"""图片识别
Args:
Expand All @@ -156,7 +156,7 @@ def ocr_image(self, img_path: str) -> tuple[bool, str]:
text = ""
return ok, text

def check_ocr(self, api_key_ocr_s) -> tuple[bool, str]:
def check_ocr(self, api_key_ocr_s):
"""_summary_
Args:
Expand All @@ -167,7 +167,7 @@ def check_ocr(self, api_key_ocr_s) -> tuple[bool, str]:
"""
return True, "success"

def get_ocr_api_key_s(self) -> str | None:
def get_ocr_api_key_s(self):
"""图片识别的字符串apikey
Returns:
Expand Down

0 comments on commit 4803060

Please sign in to comment.