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.Writerprotocol that can print status.See
StatusWriter.tqdm()andStatusWriter.trange(). IfStatusWriter.status_streamis eithersys.stdoutorsys.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
withblock 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
tqdmstatus messages and progress should be suppressed.
- flush(final=False)
Flushes this writer.
If
finalisTrue, any extra bytes will be flushed along with a final newline.
- quiet
Whether or not
tqdmstatus messages and progress should be suppressed.
- tqdm(*args, **kwargs) tqdm
Returns a
tqdm.tqdmobject.
- trange(*args, **kwargs) trange
Returns a
tqdm.trangeobject.
- 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() )