API Documentation

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.

tendril.utils.terminal.get_terminal_width()[source]
tendril.utils.terminal.colortext(string, color)[source]
tendril.utils.terminal.render_hline(color=None)[source]
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

tendril.utils.terminal._get_terminal_size_windows()[source]
tendril.utils.terminal._get_terminal_size_tput()[source]
tendril.utils.terminal._get_terminal_size_linux()[source]
tendril.utils.terminal._select_progress_class(preferred, fallback)[source]
class tendril.utils.terminal.WindowsMixin(*args, **kwargs)[source]

Bases: object

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 the next() 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 = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
message = '%(percent)3d%%'
suffix = 'ETA %(eta_td)s'
property term_width
next(n=1, note=None)[source]
writeln(line)[source]
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 = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
message = '%(percent)3d%%'
property term_width
next(n=1, note=None)[source]
update()[source]
writeln(line)[source]
finish()[source]