From 81e883209b9d8aa55699f19afc123838e79e4d10 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 19 Oct 2023 13:32:34 +0800 Subject: general update, istr -> i2str --- stdlib.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'stdlib.py') diff --git a/stdlib.py b/stdlib.py index ab8bf62..9a43dc0 100755 --- a/stdlib.py +++ b/stdlib.py @@ -4,7 +4,6 @@ from rich.console import Console as console from rich.syntax import Syntax as syntax from rich import print as rprint -from configparser import ConfigParser as config from argparse import ArgumentParser as arg @@ -65,7 +64,7 @@ class ascii: white = "\033[1;37m" # white # convert iterable into string -def istr(value): +def i2str(value): return str(''.join(map(str, value))) # convert color types @@ -108,7 +107,7 @@ def ascii2rgb(ascii_value: int) -> list: # print but formatly without newline and will flush stream def printf(*value: str): - print(str(istr(value)), end='', flush=True) + print(str(i2str(value)), end='', flush=True) # mixly(shuffle) join a list to another def shufflejoin(str1: str, str2: str, *others): @@ -130,10 +129,9 @@ def limitstring(string: str, limit: int): return string # animated print -def aprintf(*value: str, end=None): +def aprintf(*value: str, interval=0.01, end=None): from time import sleep - waitime = 0.01 - value = istr(list(value)) + value = i2str(list(value)) ani=True if len(value) >= 8*32: ani = ainputf("Print string is bigger, fast animation(Y/n): ") @@ -142,7 +140,7 @@ def aprintf(*value: str, end=None): for i in value: printf(i) if ani: - sleep(waitime) + sleep(interval) if end == None: printf('\n') else: @@ -168,7 +166,7 @@ def ainputf(str: str, end='', ccolor=ascii.color.purple): return input() def askinput(str: str, inputter=ainputf, ccolor=ascii.color.blue): - inputter(f"{ccolor}[?] {str}{ascii.color.reset}") + return inputter(f"{ccolor}[?] {str}{ascii.color.reset}") # animated countdown from @timeoutsec def countdown(timeoutsec: int): -- cgit v1.2.3