dotools_py.utility.live_display#
- dotools_py.utility.live_display(console=None, current=None, total=None, msg=None)[source]#
Decorator that displays a live status line and execution time for a function.
Note
This decorator is best suited for single-step or phase-based tasks.
- Parameters:
- console
None(default:None) The Rich Console to use for output. If set to
Nonea default console is used.- current
int|None(default:None) The current step index.
- total
int|None(default:None) The total number of steps
- msg
str|None(default:None) Message to display. If not set, the name of the function will be displayed.
- console
- Returns:
Returns a decorator that wraps the target function.
Examples
>>> import dotools_py as do >>> import time >>> @do.utility.live_display(current=1, total=2) ... def step1(): ... time.sleep(2) >>> @do.utility.live_display(current=2, total=2) ... def step2(): ... time.sleep(3) >>> def testing(): ... step1() ... step2() >>> testing() (1/2) step1 ... (1/2) step1 ✔ (0:00:02.001059) (2/2) step2 ... (2/2) step2 ✔ (0:00:03.000399)