#!/usr/bin/python3 import sys class OutputManager: def __init__(self): self.last_line_length = 0 self.echo_output = True def line_break(self): if self.echo_output: sys.stdout.write('\n') sys.stdout.flush() return self def error(self, string): if self.echo_output: self._erase_line() string = '[-] ' + string self.last_line_length = len(string) sys.stdout.write(string) sys.stdout.flush() return self def normal(self, string): if self.echo_output: self._erase_line() self.last_line_length = len(string) sys.stdout.write(string) sys.stdout.flush() return self def _erase_line(self): sys.stdout.write('\r' + ' ' * self.last_line_length + '\r') return self