#NEWLINE# def ansi_strip( text , readline_hints = True ) : #NEWLINE# #INDENT# '\n    Strip ANSI escape sequences from the given string.\n\n    :param text: The text from which ANSI escape sequences should be removed (a\n                 string).\n    :param readline_hints: If :data:`True` then :func:`readline_strip()` is\n                           used to remove `readline hints`_ from the string.\n    :returns: The text without ANSI escape sequences (a string).\n    ' #NEWLINE# pattern = ( '%s.*?%s' % ( re . escape ( ANSI_CSI ) , re . escape ( ANSI_SGR ) ) ) #NEWLINE# text = re . sub ( pattern , '' , text ) #NEWLINE# if readline_hints : #NEWLINE# #INDENT# text = readline_strip ( text ) #NEWLINE# #UNINDENT# return text