Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/ghunt/objects/utils.py
252 views
1
from ghunt.helpers.utils import *
2
from ghunt.errors import *
3
from ghunt.objects.base import SmartObj
4
5
from typing import *
6
7
8
from rich.console import Console
9
10
class TMPrinter():
11
"""
12
Print temporary text, on the same line.
13
"""
14
def __init__(self, rc: Console=Console(highlight=False)):
15
self.max_len = 0
16
self.rc = rc
17
18
def out(self, text: str, style: str=""):
19
if len(text) > self.max_len:
20
self.max_len = len(text)
21
else:
22
text += (" " * (self.max_len - len(text)))
23
self.rc.print(text, end='\r', style=style)
24
def clear(self):
25
self.rc.print(" " * self.max_len, end="\r")
26