diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-06-03 17:22:57 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-06-03 17:22:57 +0300 |
commit | 57d78a5f4030846bf78829b3f2916f4543e1874f (patch) | |
tree | b026a1886af7f49c8b6566974666f0d4e864f2b9 | |
parent | 7016d5fd00b6c1960a531f796dddf1afdf2aecf0 (diff) | |
download | python-ttystatus-57d78a5f4030846bf78829b3f2916f4543e1874f.tar.gz |
Add: TerminalStatus.hide method
-rw-r--r-- | example.py | 3 | ||||
-rw-r--r-- | ttystatus/status.py | 14 |
2 files changed, 17 insertions, 0 deletions
@@ -57,6 +57,9 @@ def main(): if os.path.islink(pathname): ts['symlink'] = pathname ts.notify('Symlink! %s' % pathname) + ts.hide() + sys.stdout.write('THIS IS STDOUT!\n') + ts.flush() elif 'error' in pathname: ts.error('Error in pathname: %s' % pathname) ts['done'] += 1 diff --git a/ttystatus/status.py b/ttystatus/status.py index 77f0b18..a5c40d1 100644 --- a/ttystatus/status.py +++ b/ttystatus/status.py @@ -118,7 +118,21 @@ class TerminalStatus(object): if self._m.enabled and self._m.time_to_write(): self._write() + def hide(self): # pragma: no cover + '''Hide current progress report. + + Use .flush() to make it visible again. Hiding is useful if you + want to write things to stdout/stderr that might get mixed + with progress output. The .notify() and .error() methods get + disabled if progress reporting gets disabled, but .hide() + doesn't. + + ''' + + self._m.clear() + def flush(self): + '''Force an update of current state to the screen. This happens even if it is not yet time to output the screen. |