[bug fix] 增加兼容性

This commit is contained in:
msincenselee 2022-01-26 10:07:59 +08:00
parent 7104a2fe0b
commit 47e8bb16c7

View File

@ -145,14 +145,17 @@ class MainEngine:
print(msg, file=sys.stderr) print(msg, file=sys.stderr)
def get_gateway(self, gateway_name: str) -> BaseGateway: def get_gateway(self, gateway_name: str) -> BaseGateway:
""" """
Return gateway object by name. Return gateway object by name.
""" """
gateway = self.gateways.get(gateway_name, None) gateway = self.gateways.get(gateway_name, None)
if not gateway: if not gateway:
self.write_error(f"找不到底层接口:{gateway_name}") # 增加兼容得写法如果没有输入gateway_name但当前只有一个gateway时就使用当前gateway
if len(self.gateways.keys()) == 1:
return self.gateways.values()[0]
self.write_error(f"{self.gateways.keys()}中找不到底层接口:{gateway_name}")
return gateway return gateway
def get_engine(self, engine_name: str) -> "BaseEngine": def get_engine(self, engine_name: str) -> "BaseEngine":