1570ba320c style: 代码格式化和字符串处理优化
- 优化代码缩进和换行,提高可读性
- 统一使用单引号或双引号,保持一致性
- 移除冗余的空格和括号,精简代码
2025-02-15 21:30:24 +08:00

38 lines
796 B
Python

from asyncio import sleep
from random import uniform
from rich import print
from rich.text import Text
from .static import INFO
def retry(function):
async def inner(self, *args, **kwargs):
if result := await function(self, *args, **kwargs):
return result
for _ in range(self.retry):
if result := await function(self, *args, **kwargs):
return result
return result
return inner
def logging(log, text, style=INFO):
string = Text(text, style=style)
if log:
log.write(
string,
scroll_end=True,
)
else:
print(string)
async def sleep_time(
min_time: int | float = 0.5,
max_time: int | float = 1.5,
):
await sleep(uniform(min_time, max_time))