add shutil instad of os libary for get_terminal_size()& code merges

This commit is contained in:
eli fessler 2022-09-28 11:21:14 -10:00
parent 709a067445
commit f663ff01e7

26
s3s.py
View File

@ -1004,17 +1004,23 @@ def monitor_battles(which, secs, isblackout, istestrun):
print("Bye!")
class SquidProgress:
def __init__(self):
self.count = 0
'''Display animation while waiting.'''
def __call__(self):
lineend = shutil.get_terminal_size()[0] - 4
ika = '>=> ' if self.count % 2 == 0 else '===>'
sys.stdout.write(f"\r{' '*self.count}{ika}{' '*(lineend - self.count)}")
sys.stdout.flush()
self.count += 1
if self.count > lineend:
self.count = 0
def __init__(self):
self.count = 0
def __call__(self):
lineend = shutil.get_terminal_size()[0] - 5 # 5 = ('>=> ' or '===>') + blank 1
ika = '>=> ' if self.count % 2 == 0 else '===>'
sys.stdout.write(f"\r{' '*self.count}{ika}{' '*(lineend - self.count)}")
sys.stdout.flush()
self.count += 1
if self.count > lineend:
self.count = 0
def __del__(self):
sys.stdout.write(f"\r{' '*(os.get_terminal_size()[0] - 1)}\r")
sys.stdout.flush()
def main():
'''Main process, including I/O and setup.'''