JoeanAmier 13707c425a perf: 更新程序交互界面
1. 更新英语翻译
2. 更新界面文本
3. 更新界面主题
2024-12-28 17:55:16 +08:00

35 lines
760 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, animate=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))