Method: rich.control.escape_control_codes
Calls: 24, Exceptions: 0, Paths: 1Back
Path 1: 24 calls (1.0)
'int([x]) -> integer\nint(x, base=10) -> integer' (3) '' (1) 'foo\rbar' (1) 'Fear is the mind killer' (1) 'Foo test' (1) 'constructor docs.' (1) 'Mult...
{7: '\\a', 8: '\\b', 11: '\\v', 12: '\\f', 13: '\\r'} (24)
'int([x]) -> integer\nint(x, base=10) -> integer' (3) '' (1) 'foo\\rbar' (1) 'Fear is the mind killer' (1) 'Foo test' (1) 'constructor docs.' (1) 'Mul...
1def escape_control_codes(
2 text: str,
3 _translate_table: Dict[int, str] = CONTROL_ESCAPE,
4) -> str:
5 """Replace control codes with their "escaped" equivalent in the given text.
6 (e.g. "\b" becomes "\\b")
7
8 Args:
9 text (str): A string possibly containing control codes.
10
11 Returns:
12 str: String with control codes replaced with their escaped version.
13 """
14 return text.translate(_translate_table)