Moved blame.Blame.output_progress to terminal.output_progress.

This enables us to output progress from multiple modules.
This commit is contained in:
Adam Waldenberg 2015-10-29 03:25:45 +01:00
parent 6606d8b13c
commit ce91c4176a
2 changed files with 9 additions and 8 deletions

View File

@ -141,19 +141,14 @@ class Blame(object):
thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row), self.blames, row.strip()) thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row), self.blames, row.strip())
thread.daemon = True thread.daemon = True
thread.start() thread.start()
Blame.output_progress(i, len(lines))
if format.is_interactive_format():
terminal.output_progress(_(PROGRESS_TEXT), i, len(lines))
# Make sure all threads have completed. # Make sure all threads have completed.
for i in range(0, NUM_THREADS): for i in range(0, NUM_THREADS):
__thread_lock__.acquire() __thread_lock__.acquire()
@staticmethod
def output_progress(pos, length):
if sys.stdout.isatty() and format.is_interactive_format():
terminal.clear_row()
print(_(PROGRESS_TEXT).format(100 * pos / length), end="")
sys.stdout.flush()
@staticmethod @staticmethod
def is_revision(string): def is_revision(string):
revision = re.search("([0-9a-f]{40})", string) revision = re.search("([0-9a-f]{40})", string)

View File

@ -145,3 +145,9 @@ def ljust(string, pad):
def rjust(string, pad): def rjust(string, pad):
return string.rjust(pad - get_excess_column_count(string)) return string.rjust(pad - get_excess_column_count(string))
def output_progress(text, pos, length):
if sys.stdout.isatty():
clear_row()
print(text.format(100 * pos / length), end="")
sys.stdout.flush()