Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 修正部分文档字符串 #55

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kirami/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ def extract_plain_text(message: Message) -> str:
message: 消息对象

### 返回
艾特用户列表
纯文本消息
"""
return message.extract_plain_text().strip()
15 changes: 11 additions & 4 deletions kirami/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
from tenacity import AsyncRetrying, RetryError, stop_after_attempt

from kirami.config import BOT_DIR, RES_DIR
from kirami.exception import FileNotExistError, NetworkError, ReadFileError
from kirami.exception import (
FileNotExistError,
FileTypeError,
NetworkError,
ReadFileError,
)

from .renderer import Renderer
from .request import Request
Expand Down Expand Up @@ -66,9 +71,11 @@ def load_data(file: str | Path) -> dict[str, Any]:
解析后的数据

### 异常
FileNotFoundError: 文件不存在
FileNotExistError: 文件不存在

ValueError: 文件格式不支持
FileTypeError: 文件格式不支持

ReadFileError: 文件内容为空
"""
data_path = get_path(file, depth=1)
if not data_path.exists():
Expand All @@ -83,7 +90,7 @@ def load_data(file: str | Path) -> dict[str, Any]:
elif file_type == "toml":
file_data = tomllib.loads(data)
else:
raise ReadFileError(f"不支持的文件类型: {file_type}, 只能是 json、yaml 或 toml")
raise FileTypeError(f"不支持的文件类型: {file_type}, 只能是 json、yaml 或 toml")

if file_data is None:
raise ReadFileError(f"文件内容为空: {data_path}")
Expand Down