@@ -114,8 +114,8 @@ def alive_bar(total: Optional[int] = None, *, calibrate: Optional[int] = None, *
114
114
unit (str): any text that labels your entities
115
115
scale (any): the scaling to apply to units: 'SI', 'IEC', 'SI2'
116
116
precision (int): how many decimals do display when scaling
117
-
118
117
"""
118
+
119
119
try :
120
120
config = config_handler (** options )
121
121
except Exception as e :
@@ -341,7 +341,7 @@ def bar_update_hook():
341
341
342
342
bar_handle = __AliveBarHandle (pause_monitoring , set_title , set_text ,
343
343
current , lambda : run .monitor_text , lambda : run .rate_text ,
344
- lambda : run .eta_text )
344
+ lambda : run .eta_text , lambda : run . elapsed )
345
345
set_text (), set_title ()
346
346
start_monitoring ()
347
347
try :
@@ -391,6 +391,8 @@ def __call__(self):
391
391
392
392
393
393
class _ReadOnlyProperty : # pragma: no cover
394
+ """A read-only descriptor that calls a getter function."""
395
+
394
396
def __set_name__ (self , owner , name ):
395
397
self .prop = f'_{ name } '
396
398
@@ -402,13 +404,17 @@ def __set__(self, obj, value):
402
404
403
405
404
406
class _GatedFunction (_ReadOnlyProperty ): # pragma: no cover
407
+ """A gated descriptor that calls a getter function, but only if the handle is set."""
408
+
405
409
def __get__ (self , obj , objtype = None ):
406
410
if obj ._handle :
407
411
return getattr (obj , self .prop )
408
412
return _noop
409
413
410
414
411
415
class _GatedAssignFunction (_GatedFunction ): # pragma: no cover
416
+ """A gated descriptor that calls a setter function, but only if the handle is set."""
417
+
412
418
def __set__ (self , obj , value ):
413
419
self .__get__ (obj )(value )
414
420
@@ -421,11 +427,14 @@ class __AliveBarHandle:
421
427
monitor = _ReadOnlyProperty ()
422
428
rate = _ReadOnlyProperty ()
423
429
eta = _ReadOnlyProperty ()
430
+ elapsed = _ReadOnlyProperty ()
424
431
425
- def __init__ (self , pause , set_title , set_text , get_current , get_monitor , get_rate , get_eta ):
432
+ def __init__ (self , pause , set_title , set_text , get_current , get_monitor , get_rate , get_eta ,
433
+ get_elapsed ):
426
434
self ._handle , self ._pause , self ._current = None , pause , get_current
427
435
self ._title , self ._text = set_title , set_text
428
436
self ._monitor , self ._rate , self ._eta = get_monitor , get_rate , get_eta
437
+ self ._elapsed = get_elapsed
429
438
430
439
# support for disabling the bar() implementation.
431
440
def __call__ (self , * args , ** kwargs ):
0 commit comments