flow.record.utils¶
Module Contents¶
Classes¶
Functions¶
Return the stdout stream as binary or text stream. |
|
Return the stdin stream as binary or text stream. |
|
Returns True if |
|
Convert a value to a byte string. |
|
Convert a value to a unicode string. |
|
Convert a value to a base64 string. |
|
Catches KeyboardInterrupt and BrokenPipeError (OSError 22 on Windows). |
|
Convert a string, boolean, or integer to a boolean value. |
Attributes¶
- flow.record.utils.LOGGING_TRACE_LEVEL = 5¶
- 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
fpis the stdout stream.
- 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: collections.abc.Callable[Ellipsis, int]) collections.abc.Callable[Ellipsis, int]¶
Catches KeyboardInterrupt and BrokenPipeError (OSError 22 on Windows).
- class flow.record.utils.EventHandler¶
- handlers = []¶
- add_handler(callback: collections.abc.Callable[Ellipsis, None]) None¶
- remove_handler(callback: collections.abc.Callable[Ellipsis, None]) None¶
- __call__(*args, **kwargs) None¶
- flow.record.utils.boolean_argument(value: str | bool | int) bool¶
Convert a string, boolean, or integer to a boolean value.
This function interprets various string representations of boolean values, such as “true”, “false”, “1”, “0”, “yes”, “no”. It also accepts boolean and integer values directly.
- Parameters:
value – The value to convert. Can be a string, boolean, or integer.
- Returns:
The converted boolean value.
- Return type:
bool
- Raises:
ValueError – If the value cannot be interpreted as a boolean.