Option C Tools
Loading...
Searching...
No Matches
progress.Dashboard Class Reference

Public Member Functions

None __init__ (self, *, TextIO|None stream=None, bool quiet=False)
None render (self, list[str] lines, *, int footer_line=-1, int tasks_total=0)
None update_line (self, int index, str text)
None set_task (self, str name)
None complete_task (self)
None finish (self)

Protected Member Functions

None _timer_loop (self)
None _update_footer (self)

Protected Attributes

 _stream = stream or sys.stdout
 _quiet = quiet
 _is_tty = hasattr(self._stream, "isatty") and self._stream.isatty()
 _lock = threading.Lock()
list _lines = []
int _line_count = 0
int _footer_line = -1
str|None _task_name = None
float _task_start = 0.0
float _overall_start = 0.0
int _tasks_done = 0
int _tasks_total = 0
 _stop_event = threading.Event()
threading.Thread|None _timer_thread = None

Detailed Description

Fixed-size terminal display with in-place line updates and live timer.

Prints a full template on render(), then overwrites individual lines via
ANSI cursor movement as data becomes available.  A background daemon thread
refreshes the footer line every second so elapsed-time counters stay live.

On non-TTY streams the template is NOT printed during render(); instead,
update_line() silently accumulates changes and finish() prints the final
state in one shot — clean output for CI and pipes.

Definition at line 194 of file progress.py.

Constructor & Destructor Documentation

◆ __init__()

None progress.Dashboard.__init__ ( self,
* ,
TextIO | None stream = None,
bool quiet = False )

Definition at line 206 of file progress.py.

Member Function Documentation

◆ _timer_loop()

None progress.Dashboard._timer_loop ( self)
protected

Definition at line 292 of file progress.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _update_footer()

None progress.Dashboard._update_footer ( self)
protected

Definition at line 298 of file progress.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ complete_task()

None progress.Dashboard.complete_task ( self)
Increment done counter and clear the current task name.

Definition at line 268 of file progress.py.

◆ finish()

None progress.Dashboard.finish ( self)
Stop the timer thread and render final state.

Definition at line 274 of file progress.py.

Here is the call graph for this function:

◆ render()

None progress.Dashboard.render ( self,
list[str] lines,
* ,
int footer_line = -1,
int tasks_total = 0 )
Print all lines.  *footer_line* is the index auto-updated by the
background timer (default: third-from-last).

Definition at line 227 of file progress.py.

Here is the call graph for this function:

◆ set_task()

None progress.Dashboard.set_task ( self,
str name )
Set current task name and reset the per-task elapsed timer.

Definition at line 261 of file progress.py.

Here is the call graph for this function:

◆ update_line()

None progress.Dashboard.update_line ( self,
int index,
str text )
Replace the line at *index* with *text*.

Definition at line 248 of file progress.py.

Here is the caller graph for this function:

Member Data Documentation

◆ _footer_line

progress.Dashboard._footer_line = -1
protected

Definition at line 218 of file progress.py.

◆ _is_tty

progress.Dashboard._is_tty = hasattr(self._stream, "isatty") and self._stream.isatty()
protected

Definition at line 214 of file progress.py.

◆ _line_count

int progress.Dashboard._line_count = 0
protected

Definition at line 217 of file progress.py.

◆ _lines

list progress.Dashboard._lines = []
protected

Definition at line 216 of file progress.py.

◆ _lock

progress.Dashboard._lock = threading.Lock()
protected

Definition at line 215 of file progress.py.

◆ _overall_start

float progress.Dashboard._overall_start = 0.0
protected

Definition at line 221 of file progress.py.

◆ _quiet

progress.Dashboard._quiet = quiet
protected

Definition at line 213 of file progress.py.

◆ _stop_event

progress.Dashboard._stop_event = threading.Event()
protected

Definition at line 224 of file progress.py.

◆ _stream

progress.Dashboard._stream = stream or sys.stdout
protected

Definition at line 212 of file progress.py.

◆ _task_name

str | None progress.Dashboard._task_name = None
protected

Definition at line 219 of file progress.py.

◆ _task_start

float progress.Dashboard._task_start = 0.0
protected

Definition at line 220 of file progress.py.

◆ _tasks_done

int progress.Dashboard._tasks_done = 0
protected

Definition at line 222 of file progress.py.

◆ _tasks_total

int progress.Dashboard._tasks_total = 0
protected

Definition at line 223 of file progress.py.

◆ _timer_thread

threading.Thread | None progress.Dashboard._timer_thread = None
protected

Definition at line 225 of file progress.py.


The documentation for this class was generated from the following file: