graphtage.progress
A module for printing status messages and progress bars to the command line.
progress classes
StatusWriter
- class graphtage.progress.StatusWriter(out_stream: TextIO | None = None, quiet: bool = False)
-
A writer compatible with the
graphtage.printer.Writer
protocol that can print status.See
StatusWriter.tqdm()
andStatusWriter.trange()
. IfStatusWriter.status_stream
is eithersys.stdout
orsys.stderr
, then bytes printed to this writer will be buffered. For each full line buffered, a call totqdm.write()
will be made.A status writer whose lifetime is not controlled by instantiation in a
with
block must be manually flushed withStatusWriter.flush(final=True)
after its final write, or else the last line written may be lost.- __init__(out_stream: TextIO | None = None, quiet: bool = False)
Initializes a status writer.
- Parameters:
out_stream – An optional stream to which to write. If omitted this defaults to
sys.stdout
.quiet – Whether or not
tqdm
status messages and progress should be suppressed.
- flush(final=False)
Flushes this writer.
If
final
isTrue
, any extra bytes will be flushed along with a final newline.
- quiet
Whether or not
tqdm
status messages and progress should be suppressed.
- tqdm(*args, **kwargs) tqdm
Returns a
tqdm.tqdm
object.
- trange(*args, **kwargs) trange
Returns a
tqdm.trange
object.
- write_raw
If
True
, this writer will not buffer output and usetqdm.write()
.This defaults to:
self.write_raw = self.quiet or ( out_stream.fileno() != sys.stderr.fileno() and out_stream.fileno() != sys.stdout.fileno() )