progressbar.utils module¶
-
class
progressbar.utils.
AttributeDict
[source]¶ Bases:
dict
A dict that can be accessed with .attribute
>>> attrs = AttributeDict(spam=123)
# Reading
>>> attrs['spam'] 123 >>> attrs.spam 123
# Read after update using attribute
>>> attrs.spam = 456 >>> attrs['spam'] 456 >>> attrs.spam 456
# Read after update using dict access
>>> attrs['spam'] = 123 >>> attrs['spam'] 123 >>> attrs.spam 123
# Read after update using dict access
>>> del attrs.spam >>> attrs['spam'] Traceback (most recent call last): ... KeyError: 'spam' >>> attrs.spam Traceback (most recent call last): ... AttributeError: No such attribute: spam >>> del attrs.spam Traceback (most recent call last): ... AttributeError: No such attribute: spam
-
class
progressbar.utils.
StreamWrapper
[source]¶ Bases:
object
Wrap stdout and stderr globally
-
capturing
= 0¶
-
wrapped_excepthook
= 0¶
-
wrapped_stderr
= 0¶
-
wrapped_stdout
= 0¶
-
-
class
progressbar.utils.
WrappingIO
(target: base.IO, capturing: bool = False, listeners: types.Optional[types.Set[ProgressBar]] = None)[source]¶ Bases:
object
-
needs_clear
= False¶
-
-
progressbar.utils.
deltas_to_seconds
(*deltas, default: types.Optional[types.Type[ValueError]] = <class 'ValueError'>) → int | float | None[source]¶ Convert timedeltas and seconds as int to seconds as float while coalescing
>>> deltas_to_seconds(datetime.timedelta(seconds=1, milliseconds=234)) 1.234 >>> deltas_to_seconds(123) 123.0 >>> deltas_to_seconds(1.234) 1.234 >>> deltas_to_seconds(None, 1.234) 1.234 >>> deltas_to_seconds(0, 1.234) 0.0 >>> deltas_to_seconds() Traceback (most recent call last): ... ValueError: No valid deltas passed to `deltas_to_seconds` >>> deltas_to_seconds(None) Traceback (most recent call last): ... ValueError: No valid deltas passed to `deltas_to_seconds` >>> deltas_to_seconds(default=0.0) 0.0
-
progressbar.utils.
env_flag
(name: str, default: bool | None = None) → bool | None[source]¶ Accepts environt variables formatted as y/n, yes/no, 1/0, true/false, on/off, and returns it as a boolean
If the environment variable is not defined, or has an unknown value, returns default