Implement write using \r instead of \b

This is to appease PyCharm that doesn't implement \b.
This commit is contained in:
Georgios Verigakis
2018-07-10 13:32:05 +03:00
parent 1f19b5b61c
commit 6553b7b207

View File

@@ -37,9 +37,8 @@ class WriteMixin(object):
def write(self, s):
if self.file and self.is_tty():
b = '\b' * self._width
c = s.ljust(self._width)
print(b + c, end='', file=self.file)
line = self.message + s.ljust(self._width)
print('\r' + line, end='', file=self.file)
self._width = max(self._width, len(s))
self.file.flush()