def printable(text):

    ansi = re.compile(r'\x1b\[[^Jm]*[Jm]')
    return ansi.sub('', text).rstrip()
Convert text to only printable characters, as a user would see it.
dataset/ETHPy150Open d11wtq/dockerpty/tests/util.py/printable