The Terminal Utils Module (tendril.utils.terminal
)¶
This module provides utils for rendering basic UI elements on the terminal.
TendrilProgressBar
can be used to produce animated progress bars
on the terminal. This class (and the code related to it) is essentially a
copy of pip’s progressbar implementation in pip.utils.ui.
-
class
tendril.utils.terminal.
DummyProgressBar
(*args, **kwargs)[source]¶ Bases:
tendril.utils.terminal.WindowsMixin
,progress.bar.IncrementalBar
This class can be used from other modules to provide a dummy progress bar like object, with interfaces consistent with
TendrilProgressBar
.-
file
= <open file '<stdout>', mode 'w'>¶
-
message
= '%(percent)3d%%'¶
-
term_width
¶
-
-
class
tendril.utils.terminal.
TendrilProgressBar
(*args, **kwargs)[source]¶ Bases:
tendril.utils.terminal.WindowsMixin
,progress.bar.IncrementalBar
This class can be used from other modules to provide a consistent feel to progress bars across tendril. It adds a
note
keyword argument to thenext()
function, and renders the note after the suffix of the progress bar.Usage
>>> from tendril.utils.terminal import TendrilProgressBar >>> pb = TendrilProgressBar(max=100) >>> for i in range(100): ... pb.next(note=i)
-
file
= <open file '<stdout>', mode 'w'>¶
-
message
= '%(percent)3d%%'¶
-
suffix
= 'ETA %(eta_td)s'¶
-
term_width
¶
-
-
tendril.utils.terminal.
get_terminal_size
()[source]¶ getTerminalSize()
- get width and height of console
- works on linux,os x,windows,cygwin(windows)
Taken from https://gist.github.com/jtriley/1108174