@classmethod
    def parse_ansi_colors(cls, source):
        # note: strips all control sequences, even if not SGRs.
        colors = []
        plain = ''
        last = 0
        curclr = 0
        for match in ansi_seq.finditer(source):
            prevsegment = source[last:match.start()]
            plain += prevsegment
            colors.extend([curclr] * len(prevsegment))
            if match.group('final') == ansi_cmd_SGR:
                try:
                    curclr = cls.parse_sgr_param(curclr, match.group('params'))
                except __HOLE__:
                    pass
            last = match.end()
        prevsegment = source[last:]
        plain += prevsegment
        colors.extend([curclr] * len(prevsegment))
        return ''.join(plain), colors
dataset/ETHPy150Open francelabs/datafari/cassandra/pylib/cqlshlib/test/ansi_colors.py/ColoredText.parse_ansi_colors