embutils.utils.stream module

Stream utilities.

date

2021

author

Christian Wiche

contact

cwichel@gmail.com

license

The MIT License (MIT)

class embutils.utils.stream.StreamRedirect(name: str, stream_in: IO, stream_out: IO)[source]

Bases: object

Stream redirect utility implementation. Allows storing and redirect a given stream.

Class initialization.

Parameters
  • name (str) – Stream redirection name (used for naming threads).

  • stream_in (IO[AnyStr]) – Input stream. Will be stored on buffer and redirected to output.

  • stream_out (IO[AnyStr]) – Output stream.

_read() None[source]

Parses and copies every line of the input stream.

_write() None[source]

Writes every line into the output stream and buffer.

property buffer: str

Stream buffer.

join() None[source]

Waits until the stream is finished to continue.

embutils.utils.stream.unclosable(file: io.IOBase) Iterator[io.IOBase][source]

Makes file unclosable during the context execution.

Parameters

file (io.IOBase) – File to protect during context.