simplify to print(...., flush=True)

This commit is contained in:
Thomas Waldmann 2015-12-14 22:58:32 +01:00
parent fe8762ad28
commit 6a5629226f
1 changed files with 4 additions and 8 deletions

View File

@ -210,8 +210,7 @@ class Statistics:
msg += "{0:<{space}}".format(path, space=space) msg += "{0:<{space}}".format(path, space=space)
else: else:
msg = ' ' * columns msg = ' ' * columns
print(msg, file=stream or sys.stderr, end="\r") print(msg, file=stream or sys.stderr, end="\r", flush=True)
(stream or sys.stderr).flush()
def get_keys_dir(): def get_keys_dir():
@ -934,8 +933,7 @@ def yes(msg=None, retry_msg=None, false_msg=None, true_msg=None,
# no retries wanted, we just return the default # no retries wanted, we just return the default
return default return default
if retry_msg: if retry_msg:
print(retry_msg, file=ofile, end='') print(retry_msg, file=ofile, end='', flush=True)
ofile.flush()
class ProgressIndicatorPercent: class ProgressIndicatorPercent:
@ -973,8 +971,7 @@ class ProgressIndicatorPercent:
return self.output(pct) return self.output(pct)
def output(self, percent): def output(self, percent):
print(self.msg % percent, file=self.file, end='\r' if self.same_line else '\n') # python 3.3 gives us flush=True print(self.msg % percent, file=self.file, end='\r' if self.same_line else '\n', flush=True)
self.file.flush()
def finish(self): def finish(self):
if self.same_line: if self.same_line:
@ -1008,8 +1005,7 @@ class ProgressIndicatorEndless:
return self.output(self.triggered) return self.output(self.triggered)
def output(self, triggered): def output(self, triggered):
print('.', end='', file=self.file) # python 3.3 gives us flush=True print('.', end='', file=self.file, flush=True)
self.file.flush()
def finish(self): def finish(self):
print(file=self.file) print(file=self.file)