TeeContext

class glotaran.utils.tee.TeeContext[source]

Bases: object

Context manager that allows to work with string written to stdout.

This context manager behaves similar to the tee shell command. https://linuxize.com/post/linux-tee-command

Create new StringIO buffer and save reference to original sys.stdout.

Methods Summary

flush

Flush values in the buffer.

read

Return values written to buffer.

write

Write to buffer and original sys.stdout.

Methods Documentation

flush() None[source]

Flush values in the buffer.

read() str[source]

Return values written to buffer.

Returns:

Text written to buffer.

Return type:

str

write(data: str) None[source]

Write to buffer and original sys.stdout.

Parameters:

data (str) – String to write to stdout and buffer.