Strips the last '\r' or '\n' or '\r\n' string at the end of the input string. This is typically used to strip ``stdout`` and ``stderr`` streams of those characters. :param input_str: Input string to be stripped. :type input_str: ``str`` :rtype: ``str``
(input_str)
| 94 | |
| 95 | |
| 96 | def strip_shell_chars(input_str): |
| 97 | """ |
| 98 | Strips the last '\r' or '\n' or '\r\n' string at the end of |
| 99 | the input string. This is typically used to strip ``stdout`` |
| 100 | and ``stderr`` streams of those characters. |
| 101 | |
| 102 | :param input_str: Input string to be stripped. |
| 103 | :type input_str: ``str`` |
| 104 | |
| 105 | :rtype: ``str`` |
| 106 | """ |
| 107 | stripped_str = rstrip_last_char(input_str, "\n") |
| 108 | stripped_str = rstrip_last_char(stripped_str, "\r") |
| 109 | return stripped_str |
| 110 | |
| 111 | |
| 112 | def rstrip_last_char(input_str, char_to_strip): |