MCPcopy Create free account
hub / github.com/StackStorm/st2 / strip_shell_chars

Function strip_shell_chars

st2common/st2common/util/misc.py:96–109  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

94
95
96def 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
112def rstrip_last_char(input_str, char_to_strip):

Callers 5

_runMethod · 0.90
_consume_stdoutMethod · 0.90
_consume_stderrMethod · 0.90
sanitize_outputFunction · 0.85

Calls 1

rstrip_last_charFunction · 0.85

Tested by 1