code: def colorize(text, ansi=True):
      
      if ansi:
          text = text.replace('^^', '\x00')
          for token, code in _ANSI_CODES:
              text = text.replace(token, code)
          text = text.replace('\x00', '^')
      else:
          text = strip_caret_codes(text)
      return text
docs: If the client wants ansi, replace the tokens with ansi sequences --
      otherwise, simply strip them out.