Source code for progressbar.base
"""Sentinels for "no length known" and "no value given".
Both sentinels are *classes*, not instances, and both are falsey. That
is the whole point of `FalseMeta`: it lets the rest of the library write
`if self.max_value:` and have that mean "has a known, usable length",
without a separate `is UnknownLength` check at every site. See
`ProgressBar.data` and the update-gate logic in `progressbar.bar` for
the call sites that rely on it.
"""
from __future__ import annotations
from typing import IO, TextIO
[docs]
class UnknownLength(metaclass=FalseMeta):
"""The total amount of work is not knowable in advance.
Passed as `max_value` for an iterable with no `__len__` (a
generator, a stream) so the bar renders progress without a
percentage or an ETA.
"""
[docs]
class Undefined(metaclass=FalseMeta):
"""No value was supplied, where `None` is itself meaningful."""
assert IO is not None
assert TextIO is not None
__all__ = (
'IO',
'FalseMeta',
'TextIO',
'Undefined',
'UnknownLength',
)