diff options
Diffstat (limited to 'progress.py')
-rw-r--r-- | progress.py | 8 |
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 | ||
23 | class Progress(object): | 23 | class 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): |