代码拉取完成,页面将自动刷新
# *_*coding:utf-8 *_*
# @Author : Reggie
# @Time : 2022/5/9 14:10
import abc
from version import VERSION
class ResultNotFoundError(Exception):
pass
class BaseResult(object):
@abc.abstractmethod
def to_dict(self, *args, **kwargs):
return NotImplemented
class Result(BaseResult):
def __init__(self, action, code, params, message, data):
self.action = action
self.code = code
self.params = params
self.message = message
self.data = data
def to_dict(self):
return {
"action": self.action,
"params": self.params,
"code": self.code,
"data": self.data,
"message": self.message
}
@property
def dict(self):
return self.to_dict()
def __repr__(self):
result = ""
dict_info = self.to_dict()
keys = sorted(dict_info.keys(), key=lambda x: x)
for k in keys:
result += "%s:\t%s\n" % (k, dict_info[k])
return result
version_result = {
VERSION: Result
}
def result(*args, version=VERSION, **kwargs):
try:
return version_result[version](*args, **kwargs)
except KeyError:
raise ResultNotFoundError("version result not found")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。