ProgressBarOrSpinner#
- class astropy.utils.console.ProgressBarOrSpinner(total, msg, color='default', file=None)[source]#
Bases:
objectA class that displays either a
ProgressBarorSpinnerdepending on whether the total size of the operation is known or not.It is designed to be used with the
withstatement: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
intorNone If an int, the number of increments in the process being tracked and a
ProgressBaris displayed. IfNone, aSpinneris displayed.- msg
str The message to display above the
ProgressBaror 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. Iffileis not a tty (as determined by calling itsisattymember, if any), onlymsgwill be displayed: theProgressBarorSpinnerwill 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