def parseString(self, str):

        if self.prepend:
            str = self.prepend + str
            self.prepend = ''
        parts = str.split('\x1B')
        
        if len(parts) == 1:
            self.writeString(self.formatText(parts[0]))
        else:
            self.writeString(self.formatText(parts[0]))
            for s in parts[1:]:
                L = len(s)
                i = 0 
                type = None
                while i < L:
                    if s[i] not in string.digits+'[;?':
                        break
                    i+=1
                if not s:
                    self.prepend = '\x1b'
                    return
                if s[0]!='[':
                    self.writeString(self.formatText(s[i+1:]))
                    continue
                else:
                    s=s[1:]
                    i-=1
                if i==L-1:
                    self.prepend = '\x1b['
                    return
                type = _setmap.get(s[i], None)
                if type is None:
                    continue 

                if type == AnsiParser.COLOR_SET:
                    self.parseColor(s[:i + 1])
                    s = s[i + 1:]
                    self.writeString(self.formatText(s))
                elif type == AnsiParser.CURSOR_SET:
                    cursor, s = s[:i+1], s[i+1:]
                    self.parseCursor(cursor)
                    self.writeString(self.formatText(s))
                elif type == AnsiParser.ERASE_SET:
                    erase, s = s[:i+1], s[i+1:]
                    self.parseErase(erase)
                    self.writeString(self.formatText(s))
                elif type == AnsiParser.MODE_SET:
                    mode, s = s[:i+1], s[i+1:]
                    #self.parseErase('2J')
                    self.writeString(self.formatText(s))
                elif i == L:
                    self.prepend = '\x1B[' + s
                else:
                    log.msg('Unhandled ANSI control type: %c' % (s[i],))
                    s = s[i + 1:]
                    self.writeString(self.formatText(s))
Patch package source strings for version, e.g. Debian 'stable'
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/conch/ui/ansi.py/AnsiParser.parseString--crossover with--dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/distribution.py/_add_source_versions