ProgressBarOrSpinner#
- class astropy.utils.console.ProgressBarOrSpinner(total, msg, color='default', file=None)[source]#
Bases:
object
A class that displays either a
ProgressBar
orSpinner
depending on whether the total size of the operation is known or not.It is designed to be used with the
with
statement:if file.has_length(): length = file.get_length() else: length = None bytes_read = 0 with ProgressBarOrSpinner(length) as bar: while file.read(blocksize): bytes_read += blocksize bar.update(bytes_read)
- Parameters:
- total
int
orNone
If an int, the number of increments in the process being tracked and a
ProgressBar
is displayed. IfNone
, aSpinner
is displayed.- msg
str
The message to display above the
ProgressBar
or alongside theSpinner
.- color
str
, optional The color of
msg
, if any. Must be an ANSI terminal color name. Must be one of: black, red, green, brown, blue, magenta, cyan, lightgrey, default, darkgrey, lightred, lightgreen, yellow, lightblue, lightmagenta, lightcyan, white.- filewritable file-like object file-like object, optional
The file to write the to. Defaults to
sys.stdout
. Iffile
is not a tty (as determined by calling itsisatty
member, if any), onlymsg
will be displayed: theProgressBar
orSpinner
will be silent.
- total
Methods Summary
update
(value)Update the progress bar to the given value (out of the total given to the constructor.
Methods Documentation