app/docs/dev/api/utils.md

60 lines
734 B
Markdown
Raw Normal View History

2024-08-19 09:43:46 +08:00
---
title: liteyuki.utils
order: 1
icon: laptop-code
category: API
---
### ***def*** `is_coroutine_callable(call: Callable[..., Any]) -> bool`
判断是否为协程可调用对象
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
call: 可调用对象
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
bool: 是否为协程可调用对象
### ***def*** `run_coroutine() -> None`
运行协程
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
coro:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
### ***def*** `path_to_module_name(path: Path) -> str`
转换路径为模块名
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
path: 路径a/b/c/d -> a.b.c.d
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
str: 模块名
### ***def*** `async_wrapper(func: Callable[..., Any]) -> Callable[..., Coroutine]`
异步包装器
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
func: Sync Callable
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Coroutine: Asynchronous Callable
### ***async def*** `wrapper() -> None`