summaryrefslogtreecommitdiffstats
path: root/progress.py
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2017-06-28 04:24:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-06-28 04:24:03 +0000
commit259f16520acafbe85ee68deb43fa74ae56e1c617 (patch)
tree4d02a1ae04b78863e7e295dff8b949a00e719b21 /progress.py
parent8419ab22d69ed0d89809f322aef16105ad6bb127 (diff)
parent913327f10c73c53edca6421a48c116b87b207b15 (diff)
downloadgit-repo-259f16520acafbe85ee68deb43fa74ae56e1c617.tar.gz
Merge "Add a newline after "Fetching projects" progress output"
Diffstat (limited to 'progress.py')
-rw-r--r--progress.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/progress.py b/progress.py
index d948654f..b08f52e5 100644
--- a/progress.py
+++ b/progress.py
@@ -21,7 +21,7 @@ from trace import IsTrace
21_NOT_TTY = not os.isatty(2) 21_NOT_TTY = not os.isatty(2)
22 22
23class Progress(object): 23class Progress(object):
24 def __init__(self, title, total=0, units=''): 24 def __init__(self, title, total=0, units='', print_newline=False):
25 self._title = title 25 self._title = title
26 self._total = total 26 self._total = total
27 self._done = 0 27 self._done = 0
@@ -29,6 +29,7 @@ class Progress(object):
29 self._start = time() 29 self._start = time()
30 self._show = False 30 self._show = False
31 self._units = units 31 self._units = units
32 self._print_newline = print_newline
32 33
33 def update(self, inc=1): 34 def update(self, inc=1):
34 self._done += inc 35 self._done += inc
@@ -52,11 +53,12 @@ class Progress(object):
52 53
53 if self._lastp != p: 54 if self._lastp != p:
54 self._lastp = p 55 self._lastp = p
55 sys.stderr.write('\r%s: %3d%% (%d%s/%d%s) ' % ( 56 sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % (
56 self._title, 57 self._title,
57 p, 58 p,
58 self._done, self._units, 59 self._done, self._units,
59 self._total, self._units)) 60 self._total, self._units,
61 "\n" if self._print_newline else ""))
60 sys.stderr.flush() 62 sys.stderr.flush()
61 63
62 def end(self): 64 def end(self):