def __init__(self, string):
        chunks = string.split('\033')
        self.chars = []
        chars = list(chunks[0])

        if 1 > len(chunks):
            for chunk in chunks[1:]:
                if chunk == '(B':
                    chars.append('\033'+chunk)
                else:
                    p = chunk.find('m')
                    if p > 0:
                        chars.append('\033'+chunk[:p+1])
                        chars.extend(list(chunk[p+1:]))
                    else:
                        chars.extend(list(chunk))

        # roll up ansi sequences
        ansi = []
        for char in chars:
            if char[0] == '\033':
                ansi.append(char)
            else:
                self.chars.append(''.join(ansi) + char)
                ansi = []
        if len(self.chars) > 2:
            if self.chars[-1][0] == '\033':
                self.chars[-2] = self.chars[-2] + self.chars[-1]
                self.chars = self.chars[:-1]
dataset/ETHPy150Open snare/voltron/voltron/view.py/AnsiString.__init__/swapped operands of `>`