duck.utils.ansi¶
Utilities for removing ANSI escape codes from strings and collections of strings.
These helpers are useful when processing terminal output, log messages, or any text containing ANSI color and formatting sequences.
Module Contents¶
Functions¶
Remove ANSI escape codes from multiple strings. |
|
Remove ANSI escape codes from a string. |
Data¶
API¶
- duck.utils.ansi.ANSI_REMOVAL_PATTERN¶
‘compile(…)’
- duck.utils.ansi.remove_ansi_escape_codes(lines: Union[list[str], tuple[str, ...], set[str]]) list[str][source]¶
Remove ANSI escape codes from multiple strings.
- Parameters:
lines – A list, tuple, or set containing strings with optional ANSI escape codes.
- Returns:
A list of strings with ANSI escape codes removed.
- Raises:
TypeError – If
linesis not a list, tuple, or set.TypeError – If any item in
linesis not a string.