添加注释

This commit is contained in:
洛水居室 2022-06-28 00:20:51 +08:00
parent 374abb29c2
commit a4d9764855
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
3 changed files with 42 additions and 0 deletions

View File

@ -5,6 +5,12 @@ from enum import Enum
class ArtworkImage: class ArtworkImage:
def __init__(self, art_id: int, page: int = 0, is_error: bool = False, data: bytes = b""): def __init__(self, art_id: int, page: int = 0, is_error: bool = False, data: bytes = b""):
"""
:param art_id: 插画ID
:param page: 页数
:param is_error: 插画是否有问题
:param data: 插画数据
"""
self.art_id = art_id self.art_id = art_id
self.data = data self.data = data
self.is_error = is_error self.is_error = is_error
@ -15,6 +21,10 @@ class ArtworkImage:
class BaseResponseData: class BaseResponseData:
def __init__(self, response=None, error_message: str = ""): def __init__(self, response=None, error_message: str = ""):
"""
:param response: 相应
:param error_message: 错误信息
"""
if response is None: if response is None:
self.error: bool = True self.error: bool = True
self.message: str = error_message self.message: str = error_message
@ -42,6 +52,15 @@ class Stat:
class ArtworkInfo: class ArtworkInfo:
def __init__(self, post_id: int = 0, subject: str = "", tags=None, def __init__(self, post_id: int = 0, subject: str = "", tags=None,
image_url_list=None, stat: Stat = None, uid: int = 0, created_at: int = 0): image_url_list=None, stat: Stat = None, uid: int = 0, created_at: int = 0):
"""
:param post_id: post_id
:param subject: 标题
:param tags: 标签
:param image_url_list: 图片URL列表
:param stat: 统计
:param uid: 用户UID
:param created_at: 创建时间
"""
if tags is None: if tags is None:
self.tags = [] self.tags = []
else: else:
@ -58,6 +77,11 @@ class ArtworkInfo:
class HyperionResponse: class HyperionResponse:
"""
:param response: 相应
:param error_message: 错误信息
"""
def __init__(self, response=None, error_message: str = ""): def __init__(self, response=None, error_message: str = ""):
if response is None: if response is None:
self.error: bool = True self.error: bool = True
@ -117,9 +141,15 @@ class HyperionResponse:
) )
def __bool__(self): def __bool__(self):
"""
:return: 是否错误
"""
return self.error return self.error
def __len__(self): def __len__(self):
"""
:return: 插画连接数量
"""
return len(self.results.image_url_list) return len(self.results.image_url_list)

View File

@ -236,7 +236,16 @@ class YuanShen:
return BaseResponseData(req.json()) return BaseResponseData(req.json())
async def __aenter__(self): async def __aenter__(self):
"""
:return:
"""
pass pass
async def __aexit__(self, exc_type, exc, tb): async def __aexit__(self, exc_type, exc, tb):
"""
:param exc_type:
:param exc:
:param tb:
:return:
"""
await self.client.aclose() await self.client.aclose()

View File

@ -13,6 +13,9 @@ class MT19937_Random:
""" """
def __init__(self): def __init__(self):
"""
创建随机数生成器
"""
self.send_time = time.time() self.send_time = time.time()
self.generator = Generator(MT19937(int(self.send_time))) self.generator = Generator(MT19937(int(self.send_time)))