flow.record.utils

Module Contents

Classes

Functions

get_stdout

Return the stdout stream as binary or text stream.

get_stdin

Return the stdin stream as binary or text stream.

is_stdout

Returns True if fp is the stdout stream.

to_bytes

Convert a value to a byte string.

to_str

Convert a value to a unicode string.

to_native_str

to_base64

Convert a value to a base64 string.

catch_sigpipe

Catches KeyboardInterrupt and BrokenPipeError (OSError 22 on Windows).

flow.record.utils.get_stdout(binary: bool = False) TextIO | BinaryIO

Return the stdout stream as binary or text stream.

This function is the preferred way to get the stdout stream in flow.record.

Parameters:

binary – Whether to return the stream as binary stream.

Returns:

The stdout stream.

flow.record.utils.get_stdin(binary: bool = False) TextIO | BinaryIO

Return the stdin stream as binary or text stream.

This function is the preferred way to get the stdin stream in flow.record.

Parameters:

binary – Whether to return the stream as binary stream.

Returns:

The stdin stream.

flow.record.utils.is_stdout(fp: TextIO | BinaryIO) bool

Returns True if fp is the stdout stream.

flow.record.utils.to_bytes(value: Any) bytes

Convert a value to a byte string.

flow.record.utils.to_str(value: Any) str

Convert a value to a unicode string.

flow.record.utils.to_native_str(value: str) str
flow.record.utils.to_base64(value: str) str

Convert a value to a base64 string.

flow.record.utils.catch_sigpipe(func: Callable[Ellipsis, int]) Callable[Ellipsis, int]

Catches KeyboardInterrupt and BrokenPipeError (OSError 22 on Windows).

class flow.record.utils.EventHandler
handlers = []
add_handler(callback: Callable[Ellipsis, None]) None
remove_handler(callback: Callable[Ellipsis, None]) None
__call__(*args, **kwargs) None