From cd55c7901ff556b0593c129536e258554d5165d0 Mon Sep 17 00:00:00 2001 From: Alain Leufroy Date: Thu, 15 Mar 2012 13:37:49 +0100 Subject: [shellutil] add argument to ``ProgressBar.update`` to tune cursor progression (closes #88981) --- shellutils.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'shellutils.py') diff --git a/shellutils.py b/shellutils.py index c713913..749cbac 100644 --- a/shellutils.py +++ b/shellutils.py @@ -315,9 +315,22 @@ class ProgressBar(object): text = property(_get_text, _set_text, _del_text) - def update(self): - """Update the progression bar.""" - self._current += 1 + def update(self, offset=1, exact=False): + """Move FORWARD to new cursor position (cursor will never go backward). + + :offset: fraction of ``size`` + + :exact: + + - False: offset relative to current cursor position if True + - True: offset as an asbsolute position + + """ + if exact: + self._current = offset + else: + self._current += offset + progress = int((float(self._current)/float(self._total))*self._size) if progress > self._progress: self._progress = progress -- cgit v1.2.1