glue.text_progress_bar module

Text-mode progress bars

class glue.text_progress_bar.ProgressBar(text='Working', max=1, value=0, textwidth=24, fid=None, theme=None)[source]

Bases: object

Display a text progress bar.

A final line feed is printed when the ProgressBar is garbage collected. Explicitly deleting the object can force a line feed when desired. As an alternative, using the ProgressBar as a context manager will ensure a final line feed is printed when the code block within which the ProgressBar is being used exits.

Example:

>>> with ProgressBar(max=3) as pb:
...    pb.update(1)
...    pb.update(2)
...    pb.update(3)
...
increment(delta=1, text=None)[source]

Redraw the progress bar, incrementing the value by delta (default=1) and optionally changing the text. Returns the ProgressBar’s new value. See also .update().

iterate(iterable, format='%s', print_every=1)[source]

Use as a target of a for-loop to issue a progress update for every iteration. For example:

progress = ProgressBar() for text in progress.iterate([“foo”, “bar”, “bat”]):

linefeed()[source]
show()[source]

Redraw the text progress bar.

update(value=None, text=None)[source]

Redraw the progress bar, optionally changing the value and text and return the (possibly new) value. For I/O performance, the progress bar might not be written to the terminal if the text does not change and the value changes by too little. Use .show() to force a redraw.

class glue.text_progress_bar.ProgressBarTheme(sequence, twiddle_sequence, left_border, right_border)[source]

Bases: _ProgressBarTheme

is_compatible_with_encoding(coding)[source]
is_compatible_with_stream(stream)[source]